diff --git a/Geo/OCCFace.cpp b/Geo/OCCFace.cpp index 055364158fb7bba77b4ec0ed0f43c77fee541f2a..5ba119fe0154c508e015cee529148e6add83f468 100644 --- a/Geo/OCCFace.cpp +++ b/Geo/OCCFace.cpp @@ -30,45 +30,51 @@ extern Context_T CTX; OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num, TopTools_IndexedMapOfShape &emap) : GFace(m, num), s(_s) { - TopExp_Explorer exp0, exp01, exp1, exp2, exp3; + TopExp_Explorer exp2, exp3; for(exp2.Init(s, TopAbs_WIRE); exp2.More(); exp2.Next()){ - TopoDS_Shape wire = exp2.Current(); - Msg::Debug("OCC Face %d - New Wire", num); - std::list<GEdge*> l_wire; - for(exp3.Init(wire, TopAbs_EDGE); exp3.More(); exp3.Next()){ - TopoDS_Edge edge = TopoDS::Edge(exp3.Current()); - int index = emap.FindIndex(edge); - GEdge *e = m->getEdgeByTag(index); - if(e){ - l_wire.push_back(e); - Msg::Debug("Edge %d ori %d", e->tag(), edge.Orientation()); - e->addFace(this); - if(!e->is3D()){ - OCCEdge *occe = (OCCEdge*)e; - occe->setTrimmed(this); - } - } - else{ - Msg::Error("Unknown edge %d in face %d", index, num); - } - } - - GEdgeLoop el(l_wire); + TopoDS_Wire wire = TopoDS::Wire(exp2.Current()); + ShapeAnalysis_Wire check(wire, s, 0.); + // only add closed wires (yes, the test is correct: CheckClosed + // returns false when the wire is closed) + if(check.CheckClosed()){ + Msg::Debug("OCC Face %d - Skipping open Wire", num); + } + else{ + Msg::Debug("OCC Face %d - New Wire", num); + std::list<GEdge*> l_wire; + for(exp3.Init(wire, TopAbs_EDGE); exp3.More(); exp3.Next()){ + TopoDS_Edge edge = TopoDS::Edge(exp3.Current()); + int index = emap.FindIndex(edge); + GEdge *e = m->getEdgeByTag(index); + if(e){ + l_wire.push_back(e); + Msg::Debug("Edge %d ori %d", e->tag(), edge.Orientation()); + e->addFace(this); + if(!e->is3D()){ + OCCEdge *occe = (OCCEdge*)e; + occe->setTrimmed(this); + } + } + else{ + Msg::Error("Unknown edge %d in face %d", index, num); + } + } - for(GEdgeLoop::citer it = el.begin(); it != el.end(); ++it){ - l_edges.push_back(it->ge); - l_dirs.push_back(it->_sign); - if (el.count() == 2){ - it->ge->meshAttributes.minimumMeshSegments = - std::max(it->ge->meshAttributes.minimumMeshSegments,2); - } - if (el.count() == 1){ - it->ge->meshAttributes.minimumMeshSegments = - std::max(it->ge->meshAttributes.minimumMeshSegments,3); + GEdgeLoop el(l_wire); + for(GEdgeLoop::citer it = el.begin(); it != el.end(); ++it){ + l_edges.push_back(it->ge); + l_dirs.push_back(it->_sign); + if (el.count() == 2){ + it->ge->meshAttributes.minimumMeshSegments = + std::max(it->ge->meshAttributes.minimumMeshSegments,2); + } + if (el.count() == 1){ + it->ge->meshAttributes.minimumMeshSegments = + std::max(it->ge->meshAttributes.minimumMeshSegments,3); + } } + edgeLoops.push_back(el); } - - edgeLoops.push_back(el); } BRepAdaptor_Surface surface( s ); _periodic[0] = surface.IsUPeriodic(); diff --git a/Geo/OCCIncludes.h b/Geo/OCCIncludes.h index 43626856dcacf7c36aa22914e6eda2d015e0cf34..8afa09a496337ff5bc4f8501ec50efdb6acec0d2 100644 --- a/Geo/OCCIncludes.h +++ b/Geo/OCCIncludes.h @@ -93,6 +93,7 @@ using std::iostream; #include "ShapeAnalysis_ShapeContents.hxx" #include "ShapeAnalysis_CheckSmallFace.hxx" #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx" +#include "ShapeAnalysis_Wire.hxx" #include "BRepAlgoAPI_Fuse.hxx" #include "BRepCheck_Analyzer.hxx" #include "BRepLib.hxx"