diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index 8993eef77a59203b6618a605b5ca9fa6cbfa1f18..299ffd0fa5efac5c17baf82bfa5e93b17591c844 100644 --- a/Geo/GFaceCompound.cpp +++ b/Geo/GFaceCompound.cpp @@ -1014,7 +1014,7 @@ void GFaceCompound::getBoundingEdges() getUniqueEdges(_unique); l_edges.clear(); - l_dirs.clear(); // added by Trevor Strickler + l_dirs.clear(); // added by Trevor Strickler if(_U0.size()){ @@ -1073,16 +1073,16 @@ void GFaceCompound::getBoundingEdges() std::list<GEdge*>::iterator it_loop; std::list<std::list<GEdge*> >::iterator it_interior; l_edges.clear(); - + for( it_interior = _interior_loops.begin(); it_interior != _interior_loops.end(); it_interior++ ){ for( it_loop = it_interior->begin(); it_loop != it_interior->end(); it_loop++ ){ l_edges.push_back( (*it_loop) ); std::list<GEdge*>::iterator it_loop_next = it_loop; it_loop_next++; - if( it_loop_next == it_interior->end() ) + if( it_loop_next == it_interior->end() ) it_loop_next = it_interior->begin(); GVertex *vB = (*it_loop)->getBeginVertex(); - GVertex *vE = (*it_loop)->getEndVertex(); + GVertex *vE = (*it_loop)->getEndVertex(); GVertex *vB_next = (*it_loop_next)->getBeginVertex(); GVertex *vE_next = (*it_loop_next)->getEndVertex(); if( vB == vB_next || vB == vE_next ) @@ -1094,7 +1094,7 @@ void GFaceCompound::getBoundingEdges() } } } - + } @@ -1164,19 +1164,19 @@ void GFaceCompound::computeALoop(std::set<GEdge*> &_unique, std::list<GEdge*> &l _unique.erase(it); bool found = false; -/* Mod by Trevor Strickler: In the old implementation, the iterator - itx was incremented twice per loop and _loops was not set up correctly. - The While Loop below replaces the old for loop. +/* Mod by Trevor Strickler: In the old implementation, the iterator + itx was incremented twice per loop and _loops was not set up correctly. + The While Loop below replaces the old for loop. */ - for(int i = 0; i < 2; i++) { + for(int i = 0; i < 2; i++) { std::set<GEdge*>::iterator itx = _unique.begin(); while (itx != _unique.end() ){ GVertex *v1 = (*itx)->getBeginVertex(); GVertex *v2 = (*itx)->getEndVertex(); - + std::set<GEdge*>::iterator itp = itx; itx++; - + if(v1 == vE ){ _loop.push_back(*itp); vE = v2; @@ -1190,16 +1190,16 @@ void GFaceCompound::computeALoop(std::set<GEdge*> &_unique, std::list<GEdge*> &l _unique.erase(itp); } } - + if(vB == vE) { found = true; break; } - + if(_unique.empty()) break; // Mod by Trevor Strickler: had to wrap this in an if - // or else it was executed when i == -1, which is not good. + // or else it was executed when i == -1, which is not good. if( i != -1 ){ GVertex *temp = vB; vB = vE; @@ -2679,20 +2679,24 @@ double GFaceCompound::checkAspectRatio() const for(int k = 0; k < 3; k++){ v[k] = t->getVertex(k); } - std::map<MVertex*,SPoint3>::const_iterator it0 = coordinates.find(v[0]); - std::map<MVertex*,SPoint3>::const_iterator it1 = coordinates.find(v[1]); - std::map<MVertex*,SPoint3>::const_iterator it2 = coordinates.find(v[2]); double p0[3] = {v[0]->x(), v[0]->y(), v[0]->z()}; double p1[3] = {v[1]->x(), v[1]->y(), v[1]->z()}; double p2[3] = {v[2]->x(), v[2]->y(), v[2]->z()}; double a_3D = fabs(triangle_area(p0, p1, p2)); area3D += a_3D; - double q0[3] = {it0->second.x(), it0->second.y(), 0.0}; - double q1[3] = {it1->second.x(), it1->second.y(), 0.0}; - double q2[3] = {it2->second.x(), it2->second.y(), 0.0}; - double a_2D = fabs(triangle_area(q0, q1, q2)); - if (a_2D > limit) nb++; - areaMin = std::min(areaMin,a_2D); + std::map<MVertex*,SPoint3>::const_iterator it0 = coordinates.find(v[0]); + std::map<MVertex*,SPoint3>::const_iterator it1 = coordinates.find(v[1]); + std::map<MVertex*,SPoint3>::const_iterator it2 = coordinates.find(v[2]); + if(it0 != coordinates.end() && + it1 != coordinates.end() && + it2 != coordinates.end()){ + double q0[3] = {it0->second.x(), it0->second.y(), 0.0}; + double q1[3] = {it1->second.x(), it1->second.y(), 0.0}; + double q2[3] = {it2->second.x(), it2->second.y(), 0.0}; + double a_2D = fabs(triangle_area(q0, q1, q2)); + if (a_2D > limit) nb++; + areaMin = std::min(areaMin, a_2D); + } } } @@ -2704,11 +2708,11 @@ double GFaceCompound::checkAspectRatio() const double AR = M_PI*area3D/(tot_length*tot_length); - if (areaMin > 0 && areaMin < limit && nb > 3) { + if (nb > 3 && areaMin > 0 && areaMin < limit) { Msg::Warning("Too small triangles in mapping (a_2D=%g)", areaMin); } else { - Msg::Debug("Geometrical aspect ratio is OK :-)"); + Msg::Debug("Geometrical aspect ratio is OK :-)"); } return AR;