For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Vertex on Edge?

Anonymous's picture
Forums: 

How can we create a vertex in the middle of an edge and recuperate its coordinates?

Thomas Moreau's picture

You need to get the Geometry attached to your edge.

Standard_Real First, Last; TopoDS_Edge edge; Handle(Geom_Curve) curve; curve = BRep_Tool::Curve(edge, First, Last);

Then, you can use the method Geom_Curve::Value() to get the point (gp_Pnt) on your curve.

Regards, Thomas

Sarah Benoliel's picture

We wrote

Standard_Real First=1, Last=3;

gp_Pnt P1(0, 0, 0), P2(10, 0, 0);

TopoDS_Edge edge;

edge=BRepBuilderAPI_MakeEdge(P1,P2);

Handle(Geom_Curve) curve;

curve = BRep_Tool::Curve(edge, First, Last);

gp_Pnt Milieu = curve.Value(2);

OS

We obtain the following error during the compilation: no matching function for call to `Handle_Geom_Curve::Value (double)'.

Do you have a solution?

Thomas Moreau's picture

The class Geom_Curve is manipulate by Handle (pointer). So, you have to use: curve->Value(double).

For your example, you can define First and Last but it will be changed by the method Value(). The method Value() will give you the right values to use for First and Last. So, just use: Value((First+Last)/2.0);

Regards, Thomas