How to get vertices of box.

Hello, everyone:

I've created a box, and I want to get the location of each vertex of the box. However, all I get is 0,0,0. Can someone please direct me to a solution. I currently have something like this:

TopoDS_Shape box = BRepPrimAPI_MakeBox (200.,150.,100.);
.
.
.
// 'S' is an edge, I find 24 on the box:
Ex.Init(S, TopAbs_VERTEX);
for (; Ex.More(); Ex.Next(), i++){
TopoDS_Vertex vert = TopoDS::Vertex(Ex.Current());
TopLoc_Location vertLoc = vert.Location();
Handle(TopLoc_Datum3D) dat = new TopLoc_Datum3D((gp_Trsf)vertLoc);
gp_Trsf vertTrsf = dat->Transformation();
gp_XYZ vertTrans = vertTrsf.TranslationPart();

// Print it:
printf("\nX: %f Y: %f Z: %f", vertTrans.X(), vertTrans.Y(), vertTrans.Z());
}

Stephane Routelous's picture

Hi,

did you try using
gp_Pnt P = BRep_Tool::Vertex(vert) instead of getting the position using your way ?

Stephane
http://www.exotk.org

mriley's picture

Stephane,
Thank you for the help.

Mike