Get extremities of a wire

Hi everybody,

I\'ve got a ShapeExtend_WireData containing some edges (lines and arcs).

Using ShapeFix_Wire, all available fixes have been performed und all edges have been reordered.

If the result is not closed, how can I get the extremities ?

Many thanks for any ideas / suggestions,

S.

Lambda's picture

I found a solution.

The code looks like that:

BRepBuilderAPI_MakeWire mkWire;

Standard_Real tol = 0.0001;

ShapeFix_ShapeTolerance FTol;

Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
sfw->Load(sbwd);
sfw->Perform();
sfw->FixReorder();
sfw->SetMaxTolerance(tol);

for (int i=1; i <= sfw->NbEdges(); i++)
{
edge = sfw->WireData()->Edge(i);
FTol.SetTolerance(edge, tol, TopAbs_VERTEX);
mkWire.Add(edge);
}

TopoDS_Edge edgeFirst = sfw->WireData()->Edge(1);
TopoDS_Edge edgeLast = sfw->WireData()->Edge(sfw->NbEdges());

BRepAdaptor_Curve bracv;

bracv.Initialize(edgeFirst);
gp_Pnt point1;
switch (edgeFirst.Orientation())
{
case TopAbs_FORWARD:
bracv.D0(bracv.FirstParameter(), point1);
break;
case TopAbs_REVERSED:
bracv.D0(bracv.LastParameter(), point1);
break;
case TopAbs_INTERNAL:
break;
case TopAbs_EXTERNAL:
break;
}

bracv.Initialize(edgeLast);
gp_Pnt point2;
switch (edgeLast.Orientation())
{
case TopAbs_FORWARD:
bracv.D0(bracv.LastParameter(), point2);
break;
case TopAbs_REVERSED:
bracv.D0(bracv.FirstParameter(), point2);
break;
case TopAbs_INTERNAL:
break;
case TopAbs_EXTERNAL:
break;
}

if (!point1.IsEqual(point2, tol))
{
Handle(Geom_TrimmedCurve) cv = GC_MakeSegment(point2, point1);

edge = BRepBuilderAPI_MakeEdge(cv);
FTol.SetTolerance(edge, tol, TopAbs_VERTEX);
mkWire.Add(edge);
}

Is it the right way to achieve it?

Is there a smarter say?

Thanks!

S.