Hi, after using BRep_Builder::Add and Remove, how can I know a compound is empty or not? (has subshapes or not)
Thanks
Hugues Delorme Tue, 02/17/2009 - 15:45
One way (maybe not very efficient) is to use a TopExp_Explorer like this :
TopoDS_Shape shape = ...;
TopExp_Explorer exp(shape, TopAbs_VERTEX); // If there are vertices do there are sub-shapes (faces, edges, ...)
if (!exp.More())
// shape is empty
else
// shape has sub-shapes
if (!aCompound.IsNull() && TopoDS_Iterator(aCompound).More()) {
//aCompound has subshapes
...
}
Hugues' code will work just fine in most cases unless there are corner cases such as a tree of compounds where the leaves are empty. In this case there are no vertices but original compound is not truly empty.
Tue, 02/17/2009 - 15:45
One way (maybe not very efficient) is to use a TopExp_Explorer like this :
TopoDS_Shape shape = ...;
TopExp_Explorer exp(shape, TopAbs_VERTEX); // If there are vertices do there are sub-shapes (faces, edges, ...)
if (!exp.More())
// shape is empty
else
// shape has sub-shapes
Tue, 02/17/2009 - 16:22
if (!aCompound.IsNull() && TopoDS_Iterator(aCompound).More()) {
//aCompound has subshapes
...
}
Hugues' code will work just fine in most cases unless there are corner cases such as a tree of compounds where the leaves are empty. In this case there are no vertices but original compound is not truly empty.
Hope this helps.
Roman
---
opencascade.blogspot.com - blog on Open CASCADE