diff --git a/libsrc/occ/occgenmesh.cpp b/libsrc/occ/occgenmesh.cpp index 789cba7b..8bb2ce6a 100644 --- a/libsrc/occ/occgenmesh.cpp +++ b/libsrc/occ/occgenmesh.cpp @@ -374,12 +374,20 @@ namespace netgen } + /* int total = 0; for (int i3 = 1; i3 <= geom.fmap.Extent(); i3++) for (TopExp_Explorer exp2(geom.fmap(i3), TopAbs_WIRE); exp2.More(); exp2.Next()) for (TopExp_Explorer exp3(exp2.Current(), TopAbs_EDGE); exp3.More(); exp3.Next()) total++; - + */ + int total = 0; + for (auto [i3, face] : Enumerate(geom.fmap)) + for (auto wire : Explore(face, TopAbs_WIRE)) + for (auto edge : Explore(wire, TopAbs_EDGE)) + total++; + + int facenr = 0; // int edgenr = mesh.GetNSeg(); diff --git a/libsrc/occ/occgeom.hpp b/libsrc/occ/occgeom.hpp index a1544b81..c6abf5f1 100644 --- a/libsrc/occ/occgeom.hpp +++ b/libsrc/occ/occgeom.hpp @@ -268,7 +268,38 @@ namespace netgen auto end() { return nullptr; } }; + inline auto Explore (TopoDS_Shape shape, TopAbs_ShapeEnum toFind, TopAbs_ShapeEnum toAvoid = TopAbs_SHAPE) + { + return MyExplorer (shape, toFind, toAvoid); + } + + class IndexMapIterator + { + class Iterator + { + const TopTools_IndexedMapOfShape & indmap; + int i; + public: + Iterator (const TopTools_IndexedMapOfShape & aindmap, int ai) + : indmap(aindmap), i(ai) { ; } + auto operator*() { return tuple(i, indmap(i)); } + Iterator & operator++() { i++; return *this; } + bool operator!= (const Iterator & i2) { return i != i2.i; } + }; + + public: + const TopTools_IndexedMapOfShape & indmap; + IndexMapIterator (const TopTools_IndexedMapOfShape & aindmap) : indmap(aindmap) { } + Iterator begin() { return Iterator(indmap, 1); } + Iterator end() { return Iterator(indmap, indmap.Extent()); } + }; + + inline auto Enumerate (const TopTools_IndexedMapOfShape & indmap) + { + return IndexMapIterator(indmap); + } + class DLL_HEADER OCCGeometry : public NetgenGeometry {