From 980641a4369b35cfd453aafca59d6611aa2324bf Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 26 Aug 2011 12:36:13 +0000 Subject: [PATCH] don't exit if edges are not ordered in addPlanarSurface but only issue a warning (this way we can use it with a geo obtained from createTopologyFromMesh, which does not currently reorder line loops) --- Geo/GModelFactory.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Geo/GModelFactory.cpp b/Geo/GModelFactory.cpp index ad54023c7b..4577c3b3c0 100644 --- a/Geo/GModelFactory.cpp +++ b/Geo/GModelFactory.cpp @@ -61,15 +61,18 @@ GEdge *GeoFactory::addLine(GModel *gm, GVertex *start, GVertex *end) GFace *GeoFactory::addPlanarFace(GModel *gm, std::vector< std::vector<GEdge *> > edges) { - //create line loops + // create line loops + // FIXME: having non-ordered lines in the loop triggers a warning; we should + // eventually return an error, but createTopolpgyFromMesh() does not currently + // sort edges in loops; once it does, we can be stricter here. std::vector<EdgeLoop *> vecLoops; int nLoops = edges.size(); - for (int i=0; i< nLoops; i++){ + for (int i = 0; i< nLoops; i++){ int numl = gm->getMaxElementaryNumber(1) + i; while (FindEdgeLoop(numl)){ numl++; } - int nl=(int)edges[i].size(); + int nl = (int)edges[i].size(); const GEdge &e0 = *edges[i][0]; const GVertex *frontV = e0.getBeginVertex(); List_T *iListl = List_Create(nl, nl, sizeof(int)); @@ -78,8 +81,8 @@ GFace *GeoFactory::addPlanarFace(GModel *gm, std::vector< std::vector<GEdge *> > if (e0.getEndVertex() != e1.getBeginVertex() && e0.getEndVertex() != e1.getEndVertex()) { frontV = e0.getEndVertex(); if (e0.getBeginVertex() != e1.getBeginVertex() && e0.getBeginVertex() != e1.getEndVertex()) { - Msg::Error("Invalid line loop"); - return NULL; + Msg::Warning("Edges 0 and 1 not consecutive in line loop %d", i); + //return NULL; } } } @@ -89,20 +92,22 @@ GFace *GeoFactory::addPlanarFace(GModel *gm, std::vector< std::vector<GEdge *> > int numEdge = e.tag(); if (frontV == e.getBeginVertex()) { frontV = e.getEndVertex(); - } else if (frontV == e.getEndVertex()){ + } + else if (frontV == e.getEndVertex()){ frontV = e.getBeginVertex(); numEdge = -numEdge; - } else { - Msg::Error("Invalid line loop"); - List_Delete(iListl); - return NULL; + } + else { + Msg::Warning("Edge %d out of order in line loop %d", j, i); + //List_Delete(iListl); + //return NULL; } List_Add(iListl, &numEdge); } if (firstV != frontV) { - Msg::Error("Invalid line loop"); - List_Delete(iListl); - return NULL; + Msg::Warning("Unordered line loop %d", i); + //List_Delete(iListl); + //return NULL; } EdgeLoop *l = Create_EdgeLoop(numl, iListl); vecLoops.push_back(l); -- GitLab