Salome HOME
23348: EDF 12916 - SALOME crashes when generating pyramids
[modules/smesh.git] / src / SMESHUtils / SMESH_MeshAlgos.cxx
index aa702977d6cea5bdc95d0eb264cd8f18d2254323..dbadd82505154cbcbbae5e0fca2c686f205a9697 100644 (file)
@@ -987,16 +987,19 @@ TopAbs_State SMESH_ElementSearcherImpl::GetPointState(const gp_Pnt& point)
 
           // skip tangent intersections
           int nbTgt = 0;
-          const SMDS_MeshElement* prevFace = u_int1->second._face;
-          while ( ok && u_int2->second._coincides )
+          if ( u_int2 != u2inters.end() )
           {
-            if ( SMESH_MeshAlgos::GetCommonNodes(prevFace , u_int2->second._face).empty() )
-              ok = false;
-            else
+            const SMDS_MeshElement* prevFace = u_int1->second._face;
+            while ( ok && u_int2->second._coincides )
             {
-              nbTgt++;
-              u_int2++;
-              ok = ( u_int2 != u2inters.end() );
+              if ( SMESH_MeshAlgos::GetCommonNodes(prevFace , u_int2->second._face).empty() )
+                ok = false;
+              else
+              {
+                nbTgt++;
+                u_int2++;
+                ok = ( u_int2 != u2inters.end() );
+              }
             }
           }
           if ( !ok ) break;
@@ -1252,6 +1255,7 @@ bool SMESH_MeshAlgos::IsOut( const SMDS_MeshElement* element, const gp_Pnt& poin
     bool covexCorner = ( edgeNorm * edgeAdjacent * (rClosest==1. ? 1. : -1.)) < 0;
     return covexCorner ? (out || out2) : (out && out2);
   }
+
   if ( element->GetType() == SMDSAbs_Edge ) // --------------------------------------------------
   {
     // point is out of edge if it is NOT ON any straight part of edge
@@ -1279,6 +1283,7 @@ bool SMESH_MeshAlgos::IsOut( const SMDS_MeshElement* element, const gp_Pnt& poin
     }
     return true;
   }
+
   // Node or 0D element -------------------------------------------------------------------------
   {
     gp_Vec n2p ( xyz[0], point );