How to get the length between edge start and a point on the edge?

Hi there,

I have some topo_edges (that can be of different types, line segments, arc, circles, ellipse, hyperbolas, bspline ...)

So for each edge I have a vector of points that are at at random position on the edge.

My goal is to sort this vector using their distance from the edge start. (see enclosed picture).

  • So my question is how to get the length following the edge between edge start and a point on the edge?

  • How to get a point on an edge at a certain length? For example I want to insert a new point between two points.

For lines/arcs it's very straight forward. But for b splines I have no ideas how to do manually. Besides I thought there might be some general OCC tool.

Thanks !

sort points

Attachments: 
Kirill Gavrilov's picture

If your points defined in curve 1D parametric space, then their sorting is more or less straightforward, otherwise your would need first finding a projection of 3D point onto a curve.

As for lengths, I think GCPnts_AbscissaPoint is what you are looking for - it has static methods computing a length between two points, as well as interface to find point at specific distance.

PaddleStroke's picture

Thanks for your reply!
I'm not sure what 'defined in curve 1D parametric space' means.

I have the points coordinates (that can be turned into TopoDS_Vertex), and the TopoDS_Edge.
Also I'm sure that the point is on the line because it is the intersection between the TopoDS_Edge and another edge (calculated with BRepExtrema_DistShapeShape .PointOnShape1() ).

GCPnts_AbscissaPoint seems to be exactly what I need to find points at a certain length.
However it doesn't seem like it can measure from one point to the other. It seems it can only measure the entire edge.

Any additional insights ? :)
Thanks

Kirill Gavrilov's picture

I'm not sure what 'defined in curve 1D parametric space' means.
...
Also I'm sure that the point is on the line because it is the intersection between the TopoDS_Edge and another edge (calculated with BRepExtrema_DistShapeShape .PointOnShape1() ).

It means working with parameters on 3D curve/edge, like a value returned by BRepExtrema_DistShapeShape::ParOnEdgeS1(), I guess.

GCPnts_AbscissaPoint seems to be exactly what I need to find points at a certain length.
However it doesn't seem like it can measure from one point to the other. It seems it can only measure the entire edge.

My version of GCPnts_AbscissaPoint has Length() methods taking U1/U2 range within the curve - which could define an entire Edge or it's part.

PaddleStroke's picture

Thanks for the feedback again!
I see now. So by using ParOnEdgeS1 I can then use Length() function.

Sorry for the additional noob question, but how can I get the parameter of the start point and end point of the edges? Is it :
'Standard_Boolean ShapeAnalysis_Edge::Curve3d'

Mikhail Sazonov's picture