From 6388e5bd32c007f5f04f0cb02902a8736c88185d Mon Sep 17 00:00:00 2001 From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be> Date: Wed, 8 Jun 2011 12:19:10 +0000 Subject: [PATCH] GModelFactory : orient edges --- Geo/GModelFactory.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/Geo/GModelFactory.cpp b/Geo/GModelFactory.cpp index 06b6889550..673902aa83 100644 --- a/Geo/GModelFactory.cpp +++ b/Geo/GModelFactory.cpp @@ -68,15 +68,42 @@ GFace *GeoFactory::addPlanarFace(GModel *gm, std::vector< std::vector<GEdge *> > int numl = gm->getMaxElementaryNumber(1) + i; while (FindEdgeLoop(numl)){ numl++; - if (!FindEdgeLoop(numl)) break; } 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)); - for(int j = 0; j < nl; j++){ - int numEdge = edges[i][j]->tag(); + if (nl > 1) { + const GEdge &e1 = *edges[i][1]; + 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; + } + } + } + const GVertex *firstV = frontV; + for (int j = 0; j < nl; j++){ + const GEdge &e = *edges[i][j]; + int numEdge = e.tag(); + if (frontV == e.getBeginVertex()) { + frontV = e.getEndVertex(); + } else if (frontV == e.getEndVertex()){ + frontV = e.getBeginVertex(); + numEdge = -numEdge; + } else { + Msg::Error("Invalid line loop"); + List_Delete(iListl); + return NULL; + } List_Add(iListl, &numEdge); } - sortEdgesInLoop(numl, iListl); + if (firstV != frontV) { + Msg::Error("Invalid line loop"); + List_Delete(iListl); + return NULL; + } EdgeLoop *l = Create_EdgeLoop(numl, iListl); vecLoops.push_back(l); Tree_Add(GModel::current()->getGEOInternals()->EdgeLoops, &l); -- GitLab