Skip to content

GeomFill_CorrectedFrenet hangs in some cases #370

Open
@snoyer

Description

@snoyer

Description

GeomFill_CorrectedFrenet law is not usable on some curves because its initialization never terminates.

Expected Behavior

law.SetCurve(curve) terminates properly and we can proceed to use the object.

Actual Behavior

This loop does not terminate:

while (Param < Last)

Sample Code or DRAW Tcl Script

#include <BRepAdaptor_CompCurve.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <GC_MakeSegment.hxx>
#include <GeomFill_CorrectedFrenet.hxx>
#include <GeomFill_Frenet.hxx>
#include <ShapeExtend_WireData.hxx>
#include <TopoDS_Wire.hxx>
#include <gp_Pnt.hxx>

#include <vector>

int main() {
  const std::vector<gp_Pnt> points = {
      gp_Pnt(-1, -1, 0),
      gp_Pnt(0, -2, 0),
      gp_Pnt(0, -2, -1),
      gp_Pnt(0, -1, -1),
  };

  ShapeExtend_WireData extend;
  for (size_t i = 1; i < points.size(); ++i)
    extend.Add(BRepBuilderAPI_MakeEdge(GC_MakeSegment(points[i - 1], points[i]).Value()).Edge());

  BRepAdaptor_CompCurve adaptor(extend.WireAPIMake());

  GeomFill_Frenet law1;
  law1.SetCurve(adaptor.ShallowCopy()); // ok

  GeomFill_CorrectedFrenet law2;
  law2.SetCurve(adaptor.ShallowCopy()); // infinite loop in GeomFill_CorrectedFrenet::InitInterval

  return 0;
}

Operating System

Linux

Compiler

GCC

Bitness

64-bit

OCCT Version

latest

Additional Files

I do not know if the following change is the correct fix but it does allow the loop to terminate in the provided sample so it may be a starting point for someone who properly understand the algorithm (I don't)

diff --git a/src/GeomFill/GeomFill_CorrectedFrenet.cxx b/src/GeomFill/GeomFill_CorrectedFrenet.cxx
index 6487645dfe..17baef679f 100644
--- a/src/GeomFill/GeomFill_CorrectedFrenet.cxx
+++ b/src/GeomFill/GeomFill_CorrectedFrenet.cxx
@@ -540,7 +540,7 @@ Standard_Boolean GeomFill_CorrectedFrenet::InitInterval(const Standard_Real
     if (currParam > DLast)
     {
       currStep  = DLast - Param;
-      currParam = Last;
+      currParam = Param = Last;
     }
     if (isPlanar)
       currParam = Last;

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. NewThe issue was created, but not updated by maintainer. Waiting for updates labels and categories1. ModelingBoolean operations, offsets, primitives, any conversion, brep builders and etc...2. BugSomething isn't working

    Type

    Projects

    • Status

      Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions