From 3adbfd718c6681047e85ce1e1d92ad6ef431fd1f Mon Sep 17 00:00:00 2001 From: Emilie Marchandise <emilie.marchandise@uclouvain.be> Date: Fri, 23 Oct 2009 20:52:46 +0000 Subject: [PATCH] --- Geo/GFaceCompound.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++ Geo/GFaceCompound.h | 1 + Mesh/meshGFace.cpp | 1 + 3 files changed, 53 insertions(+) diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index 1acc2a23c5..7e5788b6d2 100644 --- a/Geo/GFaceCompound.cpp +++ b/Geo/GFaceCompound.cpp @@ -1446,6 +1446,57 @@ bool GFaceCompound::checkAspectRatio() const } +void GFaceCompound::coherenceNormals() +{ + + std::map<MEdge, std::set<MTriangle*>, Less_Edge > edge2tris; + for(int i=0; i< triangles.size(); i++){ + MTriangle *t = triangles[i]; + for (int j=0; j<3; j++){ + MEdge me = t->getEdge(j); + std::map<MEdge, std::set<MTriangle*>, Less_Edge >::iterator it = edge2tris.find(me); + if (it == edge2tris.end()) { + std::set<MTriangle*> mySet; + mySet.insert(t); + edge2tris.insert(std::make_pair(me, mySet)); + } + else{ + std::set<MTriangle*> mySet = it->second; + mySet.insert(t); + it->second = mySet; + } + } + } + + std::set<MTriangle* > touched; + int iE, si, iE2, si2; + touched.insert(triangles[0]); + while(touched.size() != triangles.size()){ + for(int i = 0; i< triangles.size(); i++){ + MTriangle *t = triangles[i]; + std::set<MTriangle*>::iterator it2 = touched.find(t); + if(it2 != touched.end()){ + for (int j=0; j<3; j++){ + MEdge me = t->getEdge(j); + t->getEdgeInfo(me, iE,si); + std::map<MEdge, std::set<MTriangle*>, Less_Edge >::iterator it = edge2tris.find(me); + std::set<MTriangle*> mySet = it->second; + for(std::set<MTriangle*>::iterator itt = mySet.begin(); itt != mySet.end(); itt++){ + if (*itt != t){ + (*itt)->getEdgeInfo(me,iE2,si2); + if(si == si2) (*itt)->revert(); + touched.insert(*itt); + } + } + } + } + } + } + + return; + +} + void GFaceCompound::buildAllNodes() const { diff --git a/Geo/GFaceCompound.h b/Geo/GFaceCompound.h index 7ca1ad7b9f..acfa0478bd 100644 --- a/Geo/GFaceCompound.h +++ b/Geo/GFaceCompound.h @@ -101,6 +101,7 @@ class GFaceCompound : public GFace { virtual int genusGeom () const; virtual bool checkTopology() const; bool parametrize() const ; + void coherenceNormals(); void partitionFaceCM(); virtual std::list<GFace*> getCompounds() const {return _compound;}; mutable int nbSplit; diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index 1357131d7d..9e03fc0264 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1454,6 +1454,7 @@ void partitionAndRemesh(GFaceCompound *gf) } Msg::Info("*** Mesh of surface %d done by assembly remeshed faces", gf->tag()); + gf->coherenceNormals(); gf->meshStatistics.status = GFace::DONE; //CreateOutputFile("toto.msh", CTX::instance()->mesh.format); -- GitLab