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