Salome HOME
Fix regressions
[modules/smesh.git] / src / SMESH / SMESH_Algo.cxx
index 9541f249e6945800fc1212139f819b83be0a1b9e..035c23c5919ccc309f758165820aa958c4cdbd78 100644 (file)
@@ -231,7 +231,7 @@ SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen)
 
 //=============================================================================
 /*!
- * Usually an algoritm has nothing to save
+ * Usually an algorithm has nothing to save
  */
 //=============================================================================
 
@@ -412,7 +412,7 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh*                   theM
     return false;
 
   SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
-  if ( !eSubMesh || ( eSubMesh->NbElements()==0 &&  eSubMesh->NbNodes() == 0))
+  if ( !eSubMesh || ( eSubMesh->NbElements() == 0 && eSubMesh->NbNodes() == 0))
     return false; // edge is not meshed
 
   int nbNodes = 0;
@@ -440,13 +440,15 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh*                   theM
   TopExp::Vertices(theEdge, v1, v2);
   const SMDS_MeshNode* n1 = VertexNode( v1, eSubMesh, 0 );
   const SMDS_MeshNode* n2 = VertexNode( v2, eSubMesh, 0 );
+  const SMDS_MeshNode* nEnd[2] = { nbNodes ? theNodes.begin()->second  : 0,
+                                   nbNodes ? theNodes.rbegin()->second : 0 };
   Standard_Real f, l;
   BRep_Tool::Range(theEdge, f, l);
   if ( v1.Orientation() != TopAbs_FORWARD )
     std::swap( f, l );
-  if ( n1 && ++nbNodes )
+  if ( n1 && n1 != nEnd[0] && n1 != nEnd[1] && ++nbNodes )
     theNodes.insert( make_pair( f, n1 ));
-  if ( n2 && ++nbNodes )
+  if ( n2 && n2 != nEnd[0] && n2 != nEnd[1] && ++nbNodes )
     theNodes.insert( make_pair( l, n2 ));
 
   return (int)theNodes.size() == nbNodes;
@@ -494,10 +496,11 @@ SMESH_Algo::GetCompatibleHypoFilter(const bool ignoreAuxiliary) const
  */
 //================================================================================
 
-GeomAbs_Shape SMESH_Algo::Continuity(TopoDS_Edge E1,
-                                     TopoDS_Edge E2)
+GeomAbs_Shape SMESH_Algo::Continuity(const TopoDS_Edge& theE1,
+                                     const TopoDS_Edge& theE2)
 {
-  //E1.Orientation(TopAbs_FORWARD), E2.Orientation(TopAbs_FORWARD); // avoid pb with internal edges
+  // avoid pb with internal edges
+  TopoDS_Edge E1 = theE1, E2 = theE2;
   if (E1.Orientation() > TopAbs_REVERSED) // INTERNAL
     E1.Orientation( TopAbs_FORWARD );
   if (E2.Orientation() > TopAbs_REVERSED) // INTERNAL
@@ -583,8 +586,10 @@ bool SMESH_Algo::IsStraight( const TopoDS_Edge & E,
  */
 //================================================================================
 
-bool SMESH_Algo::isDegenerated( const TopoDS_Edge & E )
+bool SMESH_Algo::isDegenerated( const TopoDS_Edge & E, const bool checkLength )
 {
+  if ( checkLength )
+    return EdgeLength( E ) == 0;
   double f,l;
   TopLoc_Location loc;
   Handle(Geom_Curve) C = BRep_Tool::Curve( E, loc, f,l );
@@ -746,7 +751,7 @@ SMESH_Algo::EMeshError SMESH_Algo::GetMeshError(SMESH_subMesh* subMesh)
     if ( !fIt->more() )
       return MEr_EMPTY;
 
-    // We check that olny links on EDGEs encouter once, the rest links, twice
+    // We check that only links on EDGEs encouter once, the rest links, twice
     set< SMESH_TLink > links;
     while ( fIt->more() )
     {