diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index 1acc2a23c5a6a0b5b6b4bded2ce37d215d00fa39..7e5788b6d265e5a0177c87fb36c9deb4cfa27f92 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 7ca1ad7b9f73209b70d9a480bd71155ad0ca8e9f..acfa0478bd9625c889f6ce199d949a20966141dc 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 1357131d7d3208b3825b49cc0a98c593d518a62d..9e03fc0264c5216ef432aec29f23d380b78bb6bc 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);