Skip to content
Snippets Groups Projects
Commit 436fe6a4 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix orientation of surface mesh for OCC models

parent b97f687c
No related branches found
No related tags found
No related merge requests found
...@@ -1418,31 +1418,52 @@ void orientMeshGFace::operator()(GFace *gf) ...@@ -1418,31 +1418,52 @@ void orientMeshGFace::operator()(GFace *gf)
if(gf->geomType() == GEntity::ProjectionFace) return; if(gf->geomType() == GEntity::ProjectionFace) return;
// surface orientions in OCC are not consistent with the orientation
// of the bounding edges, so just leave them unchanged:
if(gf->getNativeType() == GEntity::OpenCascadeModel) return;
// in old versions we did not reorient transfinite surface meshes; // in old versions we did not reorient transfinite surface meshes;
// we could add the following to provide backward compatibility: // we could add the following to provide backward compatibility:
// if(gf->meshAttributes.Method == MESH_TRANSFINITE) return; // if(gf->meshAttributes.Method == MESH_TRANSFINITE) return;
// orients the mesh to match the orientation of the first edge if(gf->getNativeType() == GEntity::OpenCascadeModel){
std::list<GEdge*> edges = gf->edges(); // surface orientions in OCC do not seem to be consistent with the
std::list<int> ori = gf->orientations(); // orientation of the bounding edges, so we compare the normals
if(edges.empty() || ori.empty()) return; // pointwise in an element
GEdge *ge = *edges.begin(); for(int i = 0; i < gf->getNumMeshElements(); i++){
GVertex *beg = ge->getBeginVertex(); MElement *e = gf->getMeshElement(i);
GVertex *end = ge->getEndVertex(); for(int j = 0; j < e->getNumVertices(); j++){
if(!beg || beg->mesh_vertices.empty() || !end || end->mesh_vertices.empty()) return; MVertex *v = e->getVertex(j);
MVertex *v1 = beg->mesh_vertices[0]; SPoint2 param;
MVertex *v2 = ge->mesh_vertices.empty() ? end->mesh_vertices[0] : ge->mesh_vertices[0]; if(reparamMeshVertexOnFace(v, gf, param)){
int sign = *ori.begin(); SVector3 ne = e->getFace(0).normal();
MEdge ref(sign > 0 ? v1 : v2, sign > 0 ? v2 : v1); SVector3 nf = gf->normal(param);
if(shouldRevert(ref, gf->triangles) || shouldRevert(ref, gf->quadrangles)){ if(dot(ne, nf) < 0){
Msg::Debug("Reverting orientation of mesh in face %d", gf->tag()); Msg::Debug("Reverting orientation of mesh in face %d", gf->tag());
for(unsigned int i = 0; i < gf->triangles.size(); i++) for(int k = 0; k < gf->getNumMeshElements(); k++)
gf->triangles[i]->revert(); gf->getMeshElement(k)->revert();
for(unsigned int i = 0; i < gf->quadrangles.size(); i++) }
gf->quadrangles[i]->revert(); return;
}
}
}
Msg::Warning("Could not orient mesh in face %d", gf->tag());
}
else{
// orient the mesh to match the orientation of the first edge
std::list<GEdge*> edges = gf->edges();
std::list<int> ori = gf->orientations();
if(edges.empty() || ori.empty()) return;
GEdge *ge = *edges.begin();
GVertex *beg = ge->getBeginVertex();
GVertex *end = ge->getEndVertex();
if(!beg || beg->mesh_vertices.empty() || !end || end->mesh_vertices.empty()) return;
MVertex *v1 = beg->mesh_vertices[0];
MVertex *v2 = ge->mesh_vertices.empty() ? end->mesh_vertices[0] : ge->mesh_vertices[0];
int sign = *ori.begin();
MEdge ref(sign > 0 ? v1 : v2, sign > 0 ? v2 : v1);
if(shouldRevert(ref, gf->triangles) || shouldRevert(ref, gf->quadrangles)){
Msg::Debug("Reverting orientation of mesh in face %d", gf->tag());
for(unsigned int i = 0; i < gf->triangles.size(); i++)
gf->triangles[i]->revert();
for(unsigned int i = 0; i < gf->quadrangles.size(); i++)
gf->quadrangles[i]->revert();
}
} }
} }
$Id: VERSIONS.txt,v 1.38 2009-03-13 08:04:38 geuzaine Exp $ $Id: VERSIONS.txt,v 1.39 2009-03-15 10:36:40 geuzaine Exp $
(?): removed GSL dependency (Gmsh now simply requires Blas and (?): removed GSL dependency (Gmsh now simply requires Blas and
Lapack); new per-window visibility; added support for composite window Lapack); new per-window visibility; added support for composite window
printing and background images; fixes for string options in parser. printing and background images; fixes for string options in parser;
fixed surface mesh orientation for Open Cascade models.
2.3.0 (Jan 23, 2009): major graphics and GUI code refactoring; new 2.3.0 (Jan 23, 2009): major graphics and GUI code refactoring; new
full-quad/hexa subdivision algorithm (removed Mesh.RecombineAlgo); full-quad/hexa subdivision algorithm (removed Mesh.RecombineAlgo);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment