DiscussionsIssue archiveOther usage issues

Archived discussion

Vertex on Edge?

Other usage issuesTue, 05/23/2000 - 14:233 replies

Browse this forum
QuestionAuthor

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

Discussion

3 archived replies

Posts are displayed in their archived order.

01Commenter-1

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, Commenter-1

02Commenter-2

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 << Milieu.X() << " " << Milieu.Y() << " " << Milieu.Z();

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

Do you have a solution?

03Commenter-1

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, Commenter-1