
Thu, 12/04/2008 - 12:02
Forums:
A box contains 8 vertex (points). I used x,y,z,l,w,b to create a box.
BRepPrimAPI_MakeBox mkBox( gp_Pnt(x, y ,z),l, h ,w);
TopoDS_Shape ResultShape = mkBox.Shape();
int count=0;
TopExp_Explorer ex;
for (ex.Init(ResultShape, TopAbs_VERTEX); ex.More(); ex.Next())
{
count++;
TopoDS_Vertex vertex = TopoDS::Vertex(ex.Current());
gp_Pnt pt = BRep_Tool::Pnt(vertex);
}
After debugging the above code i am getting the count value as 48. why it is coming as 48. How can i get the 8 vertices.
Thanks in Advance,
Vidhyan
Thu, 12/04/2008 - 12:07
Hi Vidhyan,
use TopTools_IndexedMapOfShape instead. TopExp_Explorer might visit - as you see - the vertices more than once.
Regards
Pawel
Thu, 12/04/2008 - 12:11
Thanks a lot Pawel
Thu, 12/04/2008 - 12:22
Can you able to send the code for it
Thu, 12/04/2008 - 14:05
TopTools_IndexedMapOfShape vertices;
TopExp::MapShapes(ResultShape, TopAbs_VERTEX, vertices);
Standard_Integer TotalNoOfVertex = vertices.Extent();
Thu, 12/04/2008 - 14:06
Thanks a lot for your reply
Thu, 12/04/2008 - 15:06
Paul Jimenez, now how to get the all 8 vertices Points ?
Thu, 12/04/2008 - 15:47
To retrieve each shape [I from 1 to Extent()]:
const TopoDS_Shape & TopTools_IndexedMapOfShape::operator() (const Standard_Integer I) const
To convert the TopoDS_Shape to TopoDS_Vertex:
static const TopoDS_Vertex & TopoDS::Vertex(const TopoDS_Shape &S)
To retrieve the point of a vertex:
static gp_Pnt BRep_Tool::Pnt(const TopoDS_Vertex &V)
You should really consider downloading the Reference Documentation and also reading the Technical Overview to get an idea of how to do all those things.
Thu, 12/04/2008 - 15:53
Thanks it helped me a lot