How to iterate TopTools_IndexedMapOfShape
In OpenCASCADE, you can get e.g. a list of edges for a TopoDS_Shape
using
iterate_indexedmap.cpp
TopTools_IndexedMapOfShape edges;
TopExp::MapShapes (shape, TopAbs_EDGE, edges);
How can you iterate edges
?
The easiest way is to use indexing like this:
iterate_indexedmap.cpp
for (size_t i = 1; i <= edges.Extent(); i++) {
TopoDS_Shape& edge = edges(i);
/* ... */
}
If you want to get the TopoDS_Edge
from the TopoDS_Shape
in the above example, use TopoDS::Edge(edge)
inside the loop.
edge_usage.cpp
TopoDS_Edge anEdge = TopoDS::Edge(edge);
Check out similar posts by category:
C/C++, OpenCASCADE
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow