diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index 44415810dff07372c4ea8cfa927273dcc304bf9f..58631e5eee4a8cb73246ebd5833902a5103acad8 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -3979,7 +3979,7 @@ static void _add_transfinite(int dim) if(ib == 'e') { switch (dim) { case 2: - if(p.size() == 3 + 1 || p.size() == 4 + 1) + if(p.size() == 0 + 1 || p.size() == 3 + 1 || p.size() == 4 + 1) add_trsfsurf(p, CTX.filename, WID->context_mesh_choice[1]->text()); else diff --git a/Geo/GEdgeLoop.h b/Geo/GEdgeLoop.h index e086c7b202ccc8e5696c1938bd9a578f79245ab7..7e7ce636e1aba4bcde18498f7aa04cbf61332c56 100644 --- a/Geo/GEdgeLoop.h +++ b/Geo/GEdgeLoop.h @@ -37,6 +37,7 @@ class GEdgeLoop inline iter end() { return loop.end(); } inline citer begin() const { return loop.begin(); } inline citer end() const { return loop.end(); } + inline void erase(iter it){ loop.erase(it); } int count(GEdge*) const; int count() const { return loop.size(); } }; diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index a36735c2aec2495c3072acec3ff38f852fc4d03d..6dfaf1e5d115cc9a2626e2584bc4eae4b5e9063d 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -53,6 +53,35 @@ GFace::~GFace() delete va_geom_triangles; } +void GFace::delFreeEdge(GEdge *e) +{ + // delete the edge from the edge list and the orientation list + std::list<GEdge*>::iterator ite = l_edges.begin(); + std::list<int>::iterator itd = l_dirs.begin(); + while(ite != l_edges.end()){ + if(e == *ite){ + Msg::Debug("Erasing edge %d from edge list in face %d", e->tag(), tag()); + l_edges.erase(ite); + if(itd != l_dirs.end()) l_dirs.erase(itd); + break; + } + ite++; + if(itd != l_dirs.end()) itd++; + } + + // delete the edge from the edge loops + for(std::list<GEdgeLoop>::iterator it = edgeLoops.begin(); + it != edgeLoops.end(); it++){ + for(GEdgeLoop::iter it2 = it->begin(); it2 != it->end(); it2++){ + if(e == it2->ge){ + Msg::Debug("Erasing edge %d from edge loop in face %d", e->tag(), tag()); + it->erase(it2); + break; + } + } + } +} + void GFace::deleteMesh() { for(unsigned int i = 0; i < mesh_vertices.size(); i++) delete mesh_vertices[i]; diff --git a/Geo/GFace.h b/Geo/GFace.h index d58780d47b9b21d7265cb6fa0676ba39499dcd8f..3cd5497d2fd2ec434013c4bb3b1871a73fe4a851 100644 --- a/Geo/GFace.h +++ b/Geo/GFace.h @@ -67,6 +67,10 @@ class GFace : public GEntity void addEmbeddedVertex(GVertex *v){ embedded_vertices.push_back(v); } void addEmbeddedEdge(GEdge *e){ embedded_edges.push_back(e); } + // delete the edge from the face (the edge is supposed to be a free + // edge in the face, not part of any edge loops--use with caution!) + void delFreeEdge(GEdge *e); + // edge orientations virtual std::list<int> orientations() const { return l_dirs; } diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 478816d790e1d874faffa3de50a9ab945d03d857..a5c489df2871e02f60a0ea89f431ebbfaad59a97 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -670,6 +670,9 @@ static void applyOCCMeshConstraints(GModel *m, const void *constraints) if(shape.IsSame(*shape2)){ Msg::Debug("... embedding edge in face %d", gf->tag()); gf->addEmbeddedEdge(ge); + // the surface might have this edge as an open wire: make + // sure to remove it + gf->delFreeEdge(ge); } } } diff --git a/Geo/GeoStringInterface.cpp b/Geo/GeoStringInterface.cpp index 5cd8176e42d6595dae32801c004c5142196b2900..72a8d43cbd29466fe29847e96bb937f34cf354ac 100644 --- a/Geo/GeoStringInterface.cpp +++ b/Geo/GeoStringInterface.cpp @@ -162,15 +162,18 @@ void add_trsfline(std::vector<int> &l, std::string filename, std::string type, void add_trsfsurf(std::vector<int> &l, std::string filename, std::string dir) { std::ostringstream sstream; - sstream << "Transfinite Surface {" << l[0] << "} = {"; - for(unsigned int i = 1; i < l.size(); i++) { - if(i > 1) sstream << ", "; - sstream << l[i]; + sstream << "Transfinite Surface {" << l[0] << "}"; + if(l.size() > 1){ + sstream << " = {"; + for(unsigned int i = 1; i < l.size(); i++) { + if(i > 1) sstream << ", "; + sstream << l[i]; + } + sstream << "}"; } - if(dir == "Left") - sstream << "};"; - else - sstream << "} " << dir << ";"; + if(dir != "Left") + sstream << " " << dir; + sstream << ";"; add_infile(sstream.str(), filename); } diff --git a/Geo/OCCFace.cpp b/Geo/OCCFace.cpp index 301f6a9afb0980d1b00838a81a7b00a28cceb4ed..3cf99a6c2ec444c93da32c4289836caee93332c9 100644 --- a/Geo/OCCFace.cpp +++ b/Geo/OCCFace.cpp @@ -33,54 +33,43 @@ OCCFace::OCCFace(GModel *m, TopoDS_Face _s, int num, TopTools_IndexedMapOfShape TopExp_Explorer exp2, exp3; for(exp2.Init(s, TopAbs_WIRE); exp2.More(); exp2.Next()){ 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){ - Msg::Error("Unknown edge %d in face %d", index, num); - } - else if(std::find(embedded_edges.begin(), embedded_edges.end(), e) != - embedded_edges.end()){ - Msg::Debug("OCC Face %d - Skipping embedded edge in loop", num); - } - else{ - 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); - } - } - } - - 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); + 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){ + Msg::Error("Unknown edge %d in face %d", index, num); + } + else{ + 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); } } - edgeLoops.push_back(el); + } + + 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); } - BRepAdaptor_Surface surface( s ); + + BRepAdaptor_Surface surface(s); _periodic[0] = surface.IsUPeriodic(); _periodic[1] = surface.IsVPeriodic(); diff --git a/Geo/OCCIncludes.h b/Geo/OCCIncludes.h index 8afa09a496337ff5bc4f8501ec50efdb6acec0d2..43626856dcacf7c36aa22914e6eda2d015e0cf34 100644 --- a/Geo/OCCIncludes.h +++ b/Geo/OCCIncludes.h @@ -93,7 +93,6 @@ 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"