
Wed, 10/23/2002 - 14:44
Forums:
How can I save more than one selected TopoDS_Shapes from interactive context into one brep file?
I found that the example launched with the sdk only demonstrates how to save the first TopoDS_Shape in the TopTools_HSequenceOfShape.
Any help is appreciated!
Vicart!
Wed, 10/23/2002 - 17:35
Hi !
You can build a TopoDS_Compound containing all your shapes and store this compound ...
mbd_forever
Thu, 10/24/2002 - 06:13
Hi,
Now I have already read it from the file as a whole TopoDS_Shape.
The problem is how to downcast TopoDS_Shape to TopoDS_Compound and how to
decompound the TopoDS_Compound to the seperated TopoDS_Shape.
Thanks!
Thu, 10/24/2002 - 08:19
Hi,
//To downcast to compound:
TopoDS_Shape aResultShape; //The shape from file
TopoDS_Compound aCompound;
if(aResultShape.ShapeType() == TopAbs_COMPOUND) {
aCompound = TopoDS::Compound(aResultShape);
//To iterate a compound to find for example faces
TopExp_Explorer anExp(aCompound, TopAbs_FACE);
for(; anExp.More(); anExp.Next()) {
TopoDS_Face aFace = TopoDS::Face(anExp.Current());
}
//To iterate all shapes in the compound
TopoDS_Iterator anIter(aCompound);
for(; anIter.More(); anIter.Next()) {
TopoDS_Shape aSh = anIter.Value();
}
}
Just don't forget the necessary header files.
One more point: you don't need to downcast to TopoDS_Compound to use Explorer and Iterator,
it was possible to pass aResultShape directly and got
the same result.
Regards
Thu, 10/24/2002 - 14:39
Thanks to mbd_forever and Grey !