Salome HOME
1b72d61895e8d857a3c3da3b0e74f252ecf55a1b
[modules/geom.git] / src / ShHealOper / ShHealOper_CloseContour.hxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:      ShHealOper_CloseContour.hxx
24 // Created:   20.04.04 10:25:46
25 // Author:    Galina KULIKOVA
26 //
27 #ifndef ShHealOper_CloseContour_HeaderFile
28 #define ShHealOper_CloseContour_HeaderFile
29
30 #include <TopoDS_Shape.hxx>
31 #include <TopTools_SequenceOfShape.hxx>
32 #include <TopoDS_Wire.hxx>
33 #include <BRepTools_ReShape.hxx>
34 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
35 #include <ShapeExtend_WireData.hxx>
36 #include <ShapeAnalysis_Wire.hxx>
37 #include <TColStd_MapOfInteger.hxx>
38 #include <ShHealOper_Tool.hxx>
39 #include <TopoDS_Edge.hxx>
40 ///  Class ShHealOper_CloseContour
41 //
42
43 class ShHealOper_CloseContour : public ShHealOper_Tool
44 {
45  public:
46   // ---------- PUBLIC METHODS ----------
47   Standard_EXPORT ShHealOper_CloseContour() : ShHealOper_Tool() {}
48
49   Standard_EXPORT ShHealOper_CloseContour (const TopoDS_Shape& theShape);
50   //Initializes by whole shape.
51
52   Standard_EXPORT virtual void Init(const TopoDS_Shape& theShape);
53    //Method for initialization by whole shape.
54
55   Standard_EXPORT Standard_Boolean Perform(const TopTools_SequenceOfShape& theSeqEdges,
56                           const Standard_Boolean theModeVertex = Standard_False,
57                           const Standard_Boolean theModeFixGapsCurves = Standard_True);
58                           
59   //Build wire from specified edges and close gap between edges by segment of line
60   // or by vertex in according to specified mode.
61
62   Standard_EXPORT Standard_Boolean Perform(const TopoDS_Wire& theWire,
63                           const Standard_Boolean theModeVertex= Standard_False,
64                           const Standard_Boolean theModeFixGapsCurves = Standard_True);
65                          
66   //Close gap into specified wire by segment of line or by vertex in according 
67   //to specified mode.
68   
69   inline void SetTolerance(const Standard_Real theTolerance)
70   {
71     myTolerance = theTolerance;
72   }
73   //Sets tolerance for checking closure of the contour.
74  
75   inline Standard_Real GetTolerance()
76   {
77     return  myTolerance;
78   }
79   //Returns value of the tolerance.
80   
81   inline void SetMaxTolerance(const Standard_Real theMaxTolerance)
82   {
83     myMaxTolerance = theMaxTolerance;
84   }
85   //Sets tolerance for checking closure of the contour.
86  
87   inline Standard_Real GetMaxTolerance()
88   {
89     return  myMaxTolerance;
90   }
91   //Returns value of the tolerance.
92
93   inline void SetModeVertex(const Standard_Boolean theModeVertex)
94   {
95     myModeVertex = theModeVertex;
96   }
97   //Sets mode for closure of the contour.
98
99   inline Standard_Boolean GetModeVertex() 
100   {
101     return myModeVertex;
102   }
103   //Get mode for closure of the contour.
104   
105   
106  private:
107   // ---------- PRIVATE METHODS ----------
108   
109   void build(Handle(ShapeExtend_WireData)& theSewd);
110   
111   Standard_Boolean fixGaps(const Handle(ShapeExtend_WireData)& theWire,
112                            const TopTools_SequenceOfShape& theCommonFaces);
113
114   Standard_Boolean checkOneFace(const Handle(ShapeExtend_WireData)& theSewd,
115                                 TopTools_SequenceOfShape& theCommonFaces) const;
116   
117   void buildEdge(const TopoDS_Edge& aE1, 
118                  const TopoDS_Edge& aE2,
119                  const TopTools_SequenceOfShape& theCommonFaces);
120
121   void updateWire (Handle(ShapeExtend_WireData)& sbwd);
122  private:
123   // ---------- PRIVATE FIELDS ----------
124
125
126   Standard_Boolean myModeVertex;
127   Standard_Boolean myModeFixGapsCurves;
128   
129   Standard_Real myMaxTolerance;
130   Standard_Real myTolerance;
131   TopTools_IndexedDataMapOfShapeListOfShape myMapEdgesFace;
132   TopTools_SequenceOfShape myFreeEdges;
133  public:
134 // Declaration of CASCADE RTTI
135 //DEFINE_STANDARD_RTTI (ShHealOper_CloseContour)
136 };
137
138 // Definition of HANDLE object using Standard_DefineHandle.hxx
139 //DEFINE_STANDARD_HANDLE (ShHealOper_CloseContour, )
140
141
142 #endif