Salome HOME
23239: [CEA 1739] Regression : crash trying to create mesh
[modules/smesh.git] / src / SMESHUtils / SMESH_MAT2d.hxx
index 7e1061d05bdabc04c00f8e938fb44457413d716f..328366ccefe7d81b9e71f8d80c7d65adf540f27d 100644 (file)
@@ -82,12 +82,14 @@ namespace SMESH_MAT2d
     std::size_t   _iEdge; // MA edge index within the branch
     double        _edgeParam; // normalized param within the MA edge
 
-    BranchPoint(): _branch(0), _iEdge(0), _edgeParam(-1) {}
+    BranchPoint( const Branch* b = 0, std::size_t e = 0, double u = -1 ):
+      _branch(b), _iEdge(e), _edgeParam(u) {}
   };
   //-------------------------------------------------------------------------------------
   /*!
    * \brief Branch is a set of MA edges enclosed between branch points and/or MA ends.
    *        It's main feature is to return two BoundaryPoint's per a point on it.
+   *        Points on a Branch are defined by [0,1] parameter 
    */
   class SMESHUtils_EXPORT Branch
   {
@@ -114,15 +116,20 @@ namespace SMESH_MAT2d
                                std::vector< std::size_t >& edgeIDs2,
                                std::vector< BranchPoint >& divPoints) const;
 
-    // construction
-    void init( std::vector<const TVDEdge*>&                maEdges,
-               const Boundary*                             boundary,
-               std::map< const TVDVertex*, BranchEndType > endType);
+    bool isRemoved() const { return _proxyPoint._branch; }
+
+  public: // internal: construction
+
+    void init( std::vector<const TVDEdge*>&                 maEdges,
+               const Boundary*                              boundary,
+               std::map< const TVDVertex*, BranchEndType >& endType);
     void setBranchesToEnds( const std::vector< Branch >&   branches);
+    BranchPoint getPoint( const TVDVertex* vertex ) const;
+    void setRemoved( const BranchPoint& proxyPoint );
 
-    static void setGeomEdge( std::size_t geomIndex, const TVDEdge* maEdge );
-    static std::size_t getGeomEdge( const TVDEdge* maEdge );
-    static void setBndSegment( std::size_t segIndex, const TVDEdge* maEdge );
+    static void        setGeomEdge  ( std::size_t geomIndex, const TVDEdge* maEdge );
+    static std::size_t getGeomEdge  ( const TVDEdge* maEdge );
+    static void        setBndSegment( std::size_t segIndex, const TVDEdge* maEdge );
     static std::size_t getBndSegment( const TVDEdge* maEdge );
 
   private:
@@ -132,7 +139,7 @@ namespace SMESH_MAT2d
                                   std::vector< BranchPoint >&        divPoints,
                                   const std::vector<const TVDEdge*>& maEdges,
                                   const std::vector<const TVDEdge*>& maEdgesTwin,
-                                  size_t &                           i) const;
+                                  int &                              i) const;
 
     // association of _maEdges with boundary segments is stored in this way:
     // index of an EDGE:           TVDEdge->cell()->color()
@@ -142,6 +149,7 @@ namespace SMESH_MAT2d
     const Boundary*      _boundary; // face boundary
     BranchEnd            _endPoint1;
     BranchEnd            _endPoint2;
+    BranchPoint          _proxyPoint;
   };
 
   //-------------------------------------------------------------------------------------
@@ -161,7 +169,7 @@ namespace SMESH_MAT2d
    * \brief Face boundary is discretized so that each its segment to correspond to
    *        an edge of MA
    */
-  class Boundary
+  class SMESHUtils_EXPORT Boundary
   {
   public:
 
@@ -173,7 +181,11 @@ namespace SMESH_MAT2d
 
     bool getBranchPoint( const std::size_t iEdge, double u, BranchPoint& p ) const;
 
-    bool IsConcaveSegment( std::size_t iEdge, std::size_t iSeg ) const;
+    bool getBranchPoint( const BoundaryPoint& bp, BranchPoint& p ) const;
+
+    bool isConcaveSegment( std::size_t iEdge, std::size_t iSeg ) const;
+
+    bool moveToClosestEdgeEnd( BoundaryPoint& bp ) const;
 
   private:
     std::vector< BndPoints > _pointsPerEdge;
@@ -201,11 +213,12 @@ namespace SMESH_MAT2d
                const std::vector< TopoDS_Edge >& edges,
                const double                      minSegLen,
                const bool                        ignoreCorners = false );
-    const Boundary&                        getBoundary() const { return _boundary; }
-    const std::vector< Branch >&           getBranches() const { return _branch; }
+    std::size_t                            nbBranches() const { return _nbBranches; }
+    const Branch*                          getBranch(size_t i) const;
     const std::vector< const BranchEnd* >& getBranchPoints() const { return _branchPnt; }
+    const Boundary&                        getBoundary() const { return _boundary; }
 
-    void getPoints( const Branch& branch, std::vector< gp_XY >& points) const;
+    void getPoints( const Branch* branch, std::vector< gp_XY >& points) const;
     Adaptor3d_Curve* make3DCurve(const Branch& branch) const;
 
   private:
@@ -214,6 +227,7 @@ namespace SMESH_MAT2d
     TopoDS_Face                     _face;
     TVD                             _vd;
     std::vector< Branch >           _branch;
+    std::size_t                     _nbBranches; // removed branches ignored
     std::vector< const BranchEnd* > _branchPnt;
     Boundary                        _boundary;
     double                          _scale[2];