Salome HOME
23179: EDF 11603 - Problem with extrusion when path is not well oriented
[modules/smesh.git] / src / SMESHUtils / SMESH_MAT2d.cxx
index 1d1a5300823371f4eab4faef7ead9b3da8e7374e..d423f8be89998102df25558d8bbc1a54bf261f8c 100644 (file)
@@ -390,7 +390,8 @@ namespace
     BranchIterator(const std::vector<const TVDEdge*> & edges, int i )
       :_i( i ), _size( edges.size() ), _edges( edges )
     {
-      _closed = ( edges[0]->vertex1() == edges.back()->vertex0() ); // closed branch
+      _closed = ( edges[0]->vertex1() == edges.back()->vertex0() || // closed branch
+                  edges[0]->vertex0() == edges.back()->vertex1() );
     }
     const TVDEdge* operator++() { ++_i; return edge(); }
     const TVDEdge* operator--() { --_i; return edge(); }
@@ -1031,14 +1032,16 @@ namespace
         {
           branchID = bndSegs[i]._prev->_branchID;  // with sign
         }
-        else if ( bndSegs[i]._edge && // 1st bndSeg of a WIRE
-                  bndSegs[i]._inSeg->isConnected( bndSegs[i]._edge ))
+        else if ( bndSegs[i]._edge ) // 1st bndSeg of a WIRE
         {
           branchEdges.resize(( branchID = branchEdges.size()) + 1 );
-          if ( bndSegs[i]._inSeg->point0() == bndSegs[i]._edge->vertex1() )
-            endType.insert( make_pair( bndSegs[i]._edge->vertex1(), SMESH_MAT2d::BE_ON_VERTEX ));
-          else
-            endType.insert( make_pair( bndSegs[i]._edge->vertex0(), SMESH_MAT2d::BE_ON_VERTEX ));
+          if ( bndSegs[i]._inSeg->isConnected( bndSegs[i]._edge ))
+          {
+            if ( bndSegs[i]._inSeg->point0() == bndSegs[i]._edge->vertex1() )
+              endType.insert( make_pair( bndSegs[i]._edge->vertex1(), SMESH_MAT2d::BE_ON_VERTEX ));
+            else
+              endType.insert( make_pair( bndSegs[i]._edge->vertex0(), SMESH_MAT2d::BE_ON_VERTEX ));
+          }
         }
 
         bndSegs[i].setBranch( branchID, bndSegsPerEdge ); // set to i-th and to the opposite bndSeg
@@ -1398,6 +1401,21 @@ bool SMESH_MAT2d::Boundary::getBranchPoint( const std::size_t iEdge,
   return true;
 }
 
+//================================================================================
+/*!
+ * \brief Returns a BranchPoint corresponding to a given BoundaryPoint on a geom EDGE
+ *  \param [in] bp - the BoundaryPoint
+ *  \param [out] p - the found BranchPoint
+ *  \return bool - is OK
+ */
+//================================================================================
+
+bool SMESH_MAT2d::Boundary::getBranchPoint( const BoundaryPoint& bp,
+                                            BranchPoint&         p ) const
+{
+  return getBranchPoint( bp._edgeIndex, bp._param, p );
+}
+
 //================================================================================
 /*!
  * \brief Check if a given boundary segment is a null-length segment on a concave