Discretizing an edge using GCPnts_UniformDeflection

I'm discretizing an edge in this way:

BRepAdaptor_Curve curve_adaptor(edge);
GCPnts_UniformDeflection discretizer;
discretizer.Initialize(curve_adaptor, tol);
for (int i = 0; i gp_Pnt pt = curve_adaptor.Value(discretizer.Parameter(i + 1));
... do something with pt ...

The problem is that with some shapes (imported step files) when I triangulate the faces using BRep::Mesh the edges are offset from the faces. I can tell the face triangulation is correct but the edge points are not.

I don't want to triangulate faces first and then get the edge points from for performance reasons.

I've tried getting the TopLoc_Location of the edge and doing pt.Transformed(loc) but that doesn't seem to make a difference.

Any suggestions?

wayne606's picture

Just solved the problem. I got the transformation from the edge using

gp_Trsf trans = edge.Location().Transformation();

and then inverted it

trans.Invert();

Then transforming the points with pt.Transformed(trans) does the trick.

However, I don't understand why this works...