How to get the coordinates of a TopoDS_Vertex ?

How to get the coordinates of a TopoDS_Vertex ?
Does anyone know the answer ?
Shall I convert it to something else and how ?

Please help me !

MCV

Dunduk's picture

Use BRep_Tool::Pnt()

BTW, TopoDS_Vertex inherits TopoDS_Shape - easy to see, - hence you can use it directly whenever you need TopoDS_Shape&

MCV's picture

Thank you, that was a great hint and it works well !.

Do you know how to transform a TopoDS_Shape into a TopoDS_Vertex ? DownCast did not make it, or maybe I did something wrong ?

Here is what I try to do:
I transform a gp_Pnt into a TopoDS_Vertex via BRep_Tool and rotate this point (vertex) around an axis using BRepBuilderAPI_GTransform,gp_GTrsf and gp_Trsf.

Now I seek the coordinates of the rotated vertex.
Therefore I ask BRepBuilderAPI_GTransform for the shape (TopoDS_Shape), which is just my rotated vertex, and I need to convert this TopoDS_Shape into a TopoDS_Vertex (for a later conversion to a gp_Pnt).

How ????

Best Regards
MCV

MCV's picture

Okay, I solved it via

TopoDS_Vertex avertex = TopoDS::Vertex(shape);

Thanks

MCV

Jahfer's picture

Hi MCV,

When I tried this conversion "TopoDS_Vertex avertex = TopoDS::Vertex(shape);" it throws an exception.

What may be wrong with me?

I created the "shape" as follows:

/**********************************************************
IGESControl_Reader reader;
IFSelect_ReturnStatus status = reader.ReadFile("filename");

if(status != IFSelect_RetDone)
{
AfxMessageBox("Failed to load IGES file");
return false;
}

reader.TransferRoots();

TopoDS_Shape shape = reader.OneShape();

TopoDS_Vertex vert = TopoDS::Vertex(shape);//Throws exception
/**********************************************************

Regards,
Jahfer V P

Patrik Mueller's picture

Hi,

first look with shape.ShapeType() if your shape is a TopoDS_Vertex. If not take a look at the TopExp_Explorer class or getting the vertices from your shape!

HTH,

Patrik