Salome HOME
Update copyrights 2014.
[modules/geom.git] / src / ShHealOper / ShHealOper_CloseContour.hxx
1 // Copyright (C) 2007-2014  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 <MMgt_TShared.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopTools_SequenceOfShape.hxx>
33 #include <TopoDS_Wire.hxx>
34 #include <BRepTools_ReShape.hxx>
35 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
36 #include <ShapeExtend_WireData.hxx>
37 #include <ShapeAnalysis_Wire.hxx>
38 #include <TColStd_MapOfInteger.hxx>
39 #include <ShHealOper_Tool.hxx>
40 #include <TopoDS_Edge.hxx>
41 ///  Class ShHealOper_CloseContour
42 //
43
44 class ShHealOper_CloseContour : public ShHealOper_Tool
45 {
46  public:
47   // ---------- PUBLIC METHODS ----------
48   Standard_EXPORT ShHealOper_CloseContour() : ShHealOper_Tool() {}
49
50   Standard_EXPORT ShHealOper_CloseContour (const TopoDS_Shape& theShape);
51   //Initalizes by whole shape.
52
53   Standard_EXPORT virtual void Init(const TopoDS_Shape& theShape);
54    //Method for initalization by whole shape.
55
56   Standard_EXPORT Standard_Boolean Perform(const TopTools_SequenceOfShape& theSeqEdges,
57                           const Standard_Boolean theModeVertex = Standard_False,
58                           const Standard_Boolean theModeFixGapsCurves = Standard_True);
59                           
60   //Build wire from specified edges and close gap between edges by segment of line
61   // or by vertex in according to specified mode.
62
63   Standard_EXPORT Standard_Boolean Perform(const TopoDS_Wire& theWire,
64                           const Standard_Boolean theModeVertex= Standard_False,
65                           const Standard_Boolean theModeFixGapsCurves = Standard_True);
66                          
67   //Close gap into specified wire by segment of line or by vertex in according 
68   //to specified mode.
69   
70   inline void SetTolerance(const Standard_Real theTolerance)
71   {
72     myTolerance = theTolerance;
73   }
74   //Sets tolerance for checking closure of the contour.
75  
76   inline Standard_Real GetTolerance()
77   {
78     return  myTolerance;
79   }
80   //Returns value of the tolerance.
81   
82   inline void SetMaxTolerance(const Standard_Real theMaxTolerance)
83   {
84     myMaxTolerance = theMaxTolerance;
85   }
86   //Sets tolerance for checking closure of the contour.
87  
88   inline Standard_Real GetMaxTolerance()
89   {
90     return  myMaxTolerance;
91   }
92   //Returns value of the tolerance.
93
94   inline void SetModeVertex(const Standard_Boolean theModeVertex)
95   {
96     myModeVertex = theModeVertex;
97   }
98   //Sets mode for closure of the contour.
99
100   inline Standard_Boolean GetModeVertex() 
101   {
102     return myModeVertex;
103   }
104   //Get mode for closure of the contour.
105   
106   
107  private:
108   // ---------- PRIVATE METHODS ----------
109   
110   void build(Handle(ShapeExtend_WireData)& theSewd);
111   
112   Standard_Boolean fixGaps(const Handle(ShapeExtend_WireData)& theWire,
113                            const TopTools_SequenceOfShape& theCommonFaces);
114
115   Standard_Boolean checkOneFace(const Handle(ShapeExtend_WireData)& theSewd,
116                                 TopTools_SequenceOfShape& theCommonFaces) const;
117   
118   void buildEdge(const TopoDS_Edge& aE1, 
119                  const TopoDS_Edge& aE2,
120                  const TopTools_SequenceOfShape& theCommonFaces);
121
122   void updateWire (Handle(ShapeExtend_WireData)& sbwd);
123  private:
124   // ---------- PRIVATE FIELDS ----------
125
126
127   Standard_Boolean myModeVertex;
128   Standard_Boolean myModeFixGapsCurves;
129   
130   Standard_Real myMaxTolerance;
131   Standard_Real myTolerance;
132   TopTools_IndexedDataMapOfShapeListOfShape myMapEdgesFace;
133   TopTools_SequenceOfShape myFreeEdges;
134  public:
135 // Declaration of CASCADE RTTI
136 //DEFINE_STANDARD_RTTI (ShHealOper_CloseContour)
137 };
138
139 // Definition of HANDLE object using Standard_DefineHandle.hxx
140 //DEFINE_STANDARD_HANDLE (ShHealOper_CloseContour, )
141
142
143 #endif