mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
range-based for for TopExp_Explorer
This commit is contained in:
parent
64e40a25e0
commit
14f32f73c0
@ -779,7 +779,6 @@ namespace netgen
|
||||
|
||||
|
||||
|
||||
|
||||
void OCCGeometry :: BuildFMap()
|
||||
{
|
||||
somap.Clear();
|
||||
@ -881,7 +880,7 @@ namespace netgen
|
||||
TopoDS_Face face = TopoDS::Face(exp2.Current());
|
||||
if (fmap.FindIndex(face) < 1)
|
||||
{
|
||||
fmap.Add (face);
|
||||
fmap.Add (face);
|
||||
|
||||
for (exp3.Init(face, TopAbs_WIRE); exp3.More(); exp3.Next())
|
||||
{
|
||||
@ -913,39 +912,24 @@ namespace netgen
|
||||
|
||||
|
||||
// Free Faces
|
||||
|
||||
for (exp2.Init(shape, TopAbs_FACE, TopAbs_SHELL); exp2.More(); exp2.Next())
|
||||
{
|
||||
TopoDS_Face face = TopoDS::Face(exp2.Current());
|
||||
if (fmap.FindIndex(face) < 1)
|
||||
{
|
||||
for (auto face : MyExplorer(shape, TopAbs_FACE, TopAbs_SHELL))
|
||||
if (fmap.FindIndex(face) < 1)
|
||||
{
|
||||
fmap.Add (face);
|
||||
|
||||
for (exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next())
|
||||
{
|
||||
TopoDS_Wire wire = TopoDS::Wire (exp3.Current());
|
||||
if (wmap.FindIndex(wire) < 1)
|
||||
{
|
||||
for (auto wire : MyExplorer(face, TopAbs_WIRE))
|
||||
if (wmap.FindIndex(wire) < 1)
|
||||
{
|
||||
wmap.Add (wire);
|
||||
|
||||
for (exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next())
|
||||
{
|
||||
TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
|
||||
if (emap.FindIndex(edge) < 1)
|
||||
{
|
||||
for (auto edge : MyExplorer(wire, TopAbs_EDGE))
|
||||
if (emap.FindIndex(edge) < 1)
|
||||
{
|
||||
emap.Add (edge);
|
||||
for (exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next())
|
||||
{
|
||||
TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
|
||||
if (vmap.FindIndex(vertex) < 1)
|
||||
vmap.Add (vertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto vertex : MyExplorer(edge, TopAbs_VERTEX))
|
||||
if (vmap.FindIndex(vertex) < 1)
|
||||
vmap.Add (vertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Free Wires
|
||||
|
@ -243,6 +243,32 @@ namespace netgen
|
||||
bool inverse;
|
||||
string name;
|
||||
};
|
||||
|
||||
|
||||
class MyExplorer
|
||||
{
|
||||
class Iterator
|
||||
{
|
||||
TopExp_Explorer exp;
|
||||
public:
|
||||
Iterator (TopoDS_Shape ashape, TopAbs_ShapeEnum atoFind, TopAbs_ShapeEnum atoAvoid)
|
||||
: exp(ashape, atoFind, atoAvoid) { }
|
||||
auto operator*() { return exp.Current(); }
|
||||
Iterator & operator++() { exp.Next(); return *this; }
|
||||
bool operator!= (nullptr_t nu) { return exp.More(); }
|
||||
};
|
||||
|
||||
public:
|
||||
TopoDS_Shape shape;
|
||||
TopAbs_ShapeEnum toFind;
|
||||
TopAbs_ShapeEnum toAvoid;
|
||||
MyExplorer (TopoDS_Shape ashape, TopAbs_ShapeEnum atoFind, TopAbs_ShapeEnum atoAvoid = TopAbs_SHAPE)
|
||||
: shape(ashape), toFind(atoFind), toAvoid(atoAvoid) { ; }
|
||||
Iterator begin() { return Iterator(shape, toFind, toAvoid); }
|
||||
auto end() { return nullptr; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class DLL_HEADER OCCGeometry : public NetgenGeometry
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user