Salome HOME
updated copyright message
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_GetInPlace.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 // File:        GEOMAlgo_GetInPlace.hxx
23 // Created:
24 // Author:      Peter KURNEV
25
26 #ifndef _GEOMAlgo_GetInPlace_HeaderFile
27 #define _GEOMAlgo_GetInPlace_HeaderFile
28
29 #include <Standard.hxx>
30 #include <Standard_Macro.hxx>
31 #include <Standard_Integer.hxx>
32 #include <Standard_Real.hxx>
33 #include <Standard_Boolean.hxx>
34
35 #include <TopAbs_ShapeEnum.hxx>
36 #include <TopoDS_Shape.hxx>
37
38 #include <GEOMAlgo_CoupleOfShapes.hxx>
39 #include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
40 #include <GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx>
41
42 #include <GEOMAlgo_DataMapOfShapeMapOfShape.hxx>
43 #include <GEOMAlgo_GluerAlgo.hxx>
44 #include <GEOMAlgo_Algo.hxx>
45 #include <GEOMAlgo_DataMapOfShapePnt.hxx>
46 #include <TopTools_DataMapOfShapeInteger.hxx>
47 #include <TopTools_DataMapOfShapeShape.hxx>
48
49
50 //=======================================================================
51 /**
52  * The implementation of iterator of intersected  shapes
53  * for Get In Place Algorithm.
54  * The intersection is in terms of 3D bounding boxes.
55  */
56 //=======================================================================
57 //class    : GEOMAlgo_GetInPlaceIterator
58 //purpose  :
59 //=======================================================================
60 class GEOMAlgo_GetInPlaceIterator  {
61  public:
62   /**
63    * Constructor.
64    */
65   //Standard_EXPORT
66     GEOMAlgo_GetInPlaceIterator();
67
68   /**
69    * Destructor.
70    */
71   //Standard_EXPORT
72     virtual ~GEOMAlgo_GetInPlaceIterator();
73
74   /**
75    * Clear the internal content.
76    */
77   //Standard_EXPORT
78     void Clear() ;
79
80   /**
81    * Append the pair of intersected shapes.
82    * @param theCS
83    *   The pair of intersected shapes.
84    */
85   //Standard_EXPORT
86     void AppendPair(const GEOMAlgo_CoupleOfShapes& theCS) ;
87
88   /**
89    * Initialize the iterator.
90    * @param theT1
91    *   The type of (sub)shape What.
92    * @param theT2
93    *   The type of (sub)shape Where.
94    */
95   //Standard_EXPORT
96     void Initialize(const TopAbs_ShapeEnum theT1,
97                     const TopAbs_ShapeEnum theT2) ;
98   /**
99    * Check the existence of pairs to iterare.
100    * @return
101    *   Standard_True if there are pairs to iterare.
102    */
103   //Standard_EXPORT
104     Standard_Boolean More() const;
105
106   /**
107    * Shift to the next pair.
108    */
109   //Standard_EXPORT
110     void Next() ;
111
112   /**
113    * Returns the pair of intersected shapes.
114    * @return
115    *   The pair of intersected shapes.
116    */
117   //Standard_EXPORT
118     const GEOMAlgo_CoupleOfShapes& Value() const;
119
120 protected:
121   Standard_Integer myDim;
122   GEOMAlgo_ListOfCoupleOfShapes myLists[10];
123   GEOMAlgo_ListOfCoupleOfShapes myEmptyList;
124   GEOMAlgo_ListIteratorOfListOfCoupleOfShapes myIterator;
125
126 private:
127 };
128
129
130 //=======================================================================
131 /**
132  * The implementation of Get In Place Algorithm.
133  * The algorithm provides the search the argument [What]
134  * in the shape [Where].
135  */
136 //=======================================================================
137 //class    : GEOMAlgo_GetInPlace
138 //purpose  :
139 //=======================================================================
140 class GEOMAlgo_GetInPlace  : public GEOMAlgo_GluerAlgo,
141                              public GEOMAlgo_Algo
142 {
143  public:
144   /**
145    * Constructor.
146    */
147   Standard_EXPORT
148     GEOMAlgo_GetInPlace();
149   /**
150    * Destructor.
151    */
152   Standard_EXPORT
153     virtual ~GEOMAlgo_GetInPlace();
154   /**
155    * Modifier. Sets the shape where the search is intended.
156    * @param theShape
157    *   The shape where the search is intended.
158    */
159   Standard_EXPORT
160     virtual void SetShapeWhere(const TopoDS_Shape& theShape) ;
161
162   /**
163    * Selector. Returns the shape where the search is intended.
164    * @return
165    *   The shape where the search is intended.
166    */
167   Standard_EXPORT
168     const TopoDS_Shape& ShapeWhere() const;
169
170   /**
171    * Modifier. Sets the tolerance of mass.
172    * @param theTol
173    *   The value tolerance of mass.
174    */
175   Standard_EXPORT
176     void SetTolMass(const Standard_Real theTol) ;
177
178   /**
179    * Selector. Returns the value tolerance of mass.
180    * @return
181    *   The value tolerance of mass.
182    */
183   Standard_EXPORT
184     Standard_Real TolMass() const;
185
186   /**
187    * Modifier. Sets the tolerance of center of gravily.
188    * @param theTol
189    *   The value tolerance of center of gravily.
190    */
191   Standard_EXPORT
192     void SetTolCG(const Standard_Real theTol) ;
193
194   /**
195    * Selector. Returns the tolerance of center of gravily.
196    * @return
197    *   The value tolerance of center of gravily.
198    */
199   Standard_EXPORT
200     Standard_Real TolCG() const;
201
202   /**
203    * Perform the algorithm.
204    */
205   Standard_EXPORT
206     virtual  void Perform() ;
207
208   /**
209    * Returns state of the search.
210    * @return
211    *   Standard_True if the whole argument is found.
212    */
213   Standard_EXPORT
214     Standard_Boolean IsFound() const;
215
216   /**
217    * Checks data
218    */
219   Standard_EXPORT
220     virtual  void CheckData() ;
221
222   /**
223    * Clear the internal content.
224    */
225   Standard_EXPORT
226     virtual  void Clear() ;
227
228   /**
229    * Returns the map of shapes IN.
230    * @return
231    ** Returns the map of shapes IN.
232    * The Key - the (sub)shape of the argument [What].
233    * The Item- the (sub)shapes of the shape [Where] that have
234    *           the state IN in respect of [What].
235   */
236   Standard_EXPORT
237     const GEOMAlgo_DataMapOfShapeMapOfShape& ShapesIn() const;
238
239   /**
240    * Returns the map of shapes ON.
241    * @return
242    * Returns the map of shapes ON.
243    * The Key - the (sub)shape of the argument [What].
244    * The Item- the (sub)shapes of the shape [Where] that have
245    *           the state ON in respect of [What].
246    */
247   Standard_EXPORT
248     const GEOMAlgo_DataMapOfShapeMapOfShape& ShapesOn() const;
249   //
250   /**
251    * Returns the result that includes parts of the whole and whole from parts.
252    *
253    * The Result is the parts (taken from myShapeWhere) that correspond to
254    * myArgument (the whole one or its part). To check if the whole myArgument
255    * is found in myShapeWhere it is possible to use the method IsFound.
256    *
257    * The Result is a compound.
258    *
259    * @return
260    *  - the compound of the parts from myShapeWhere 
261    *    that correspond to the myArgument if success.
262    *  - NULL shape otherwise
263    */
264   Standard_EXPORT
265     const TopoDS_Shape &Result();
266     
267 protected:
268   Standard_EXPORT
269     void Intersect() ;
270
271   Standard_EXPORT
272     void PerformVV() ;
273
274   Standard_EXPORT
275     void PerformVE() ;
276
277   Standard_EXPORT
278     void PerformEE() ;
279
280     void PerformEE(const TopoDS_Shape &theE1, const TopoDS_Shape &theE2);
281
282   Standard_EXPORT
283     void PerformVF() ;
284
285   Standard_EXPORT
286     void PerformEF() ;
287
288   Standard_EXPORT
289     void PerformFF() ;
290
291     void PerformFF(const TopoDS_Shape &theF1, const TopoDS_Shape &theF2);
292
293   Standard_EXPORT
294     void FillEdgesOn(const TopoDS_Shape &theShape);
295
296   Standard_EXPORT
297     void FillFacesOn(const TopoDS_Shape &theShape);
298
299   Standard_EXPORT
300     void FillSolidsOn(const TopoDS_Shape &theShape);
301
302   Standard_EXPORT
303     void PerformZF() ;
304
305   Standard_EXPORT
306     void PerformZZ() ;
307
308     void PerformZZ(const TopoDS_Shape &theSo1, const TopoDS_Shape &theSo2);
309
310   Standard_EXPORT
311     void FillImages(const TopoDS_Shape &theShape,
312                     const Standard_Boolean IsWhere);
313
314     void FillImgSimple(const TopoDS_Shape     &theShape,
315                        const TopAbs_ShapeEnum  theSubShapeType,
316                        const Standard_Boolean  IsWhere);
317
318     void FillImgComplex(const TopoDS_Shape     &theShape,
319                         const Standard_Boolean  IsWhere);
320
321     void FillImgComplex(const TopoDS_Shape     &theShape,
322                         const TopAbs_ShapeEnum  theSubShapeType,
323                         const Standard_Boolean  IsWhere);
324
325   Standard_EXPORT
326     void CheckGProps() ;
327
328   Standard_EXPORT
329     void FillShapesIn(const TopoDS_Shape& theS1,
330                       const TopoDS_Shape& theS2) ;
331
332   Standard_EXPORT
333     void FillShapesOn(const TopoDS_Shape& theS1,
334                       const TopoDS_Shape& theS2) ;
335
336   Standard_EXPORT
337     Standard_Boolean CheckCoincidence(const TopoDS_Shape& theS1,
338                                       const TopoDS_Shape& theS2);
339   
340   Standard_EXPORT
341     Standard_Integer CheckGProps(const TopoDS_Shape& theS);
342
343   Standard_Boolean CompareGProps
344                   (const TopoDS_Shape         &theShape1,
345                    const TopTools_ListOfShape &theListShape2) const;
346
347   Standard_EXPORT
348     void UpdateChecked(const TopoDS_Shape& theS1,
349                        const Standard_Integer theFlag);
350   //
351   TopoDS_Shape myShapeWhere;
352   GEOMAlgo_GetInPlaceIterator myIterator;
353   GEOMAlgo_DataMapOfShapeMapOfShape myShapesIn;
354   GEOMAlgo_DataMapOfShapeMapOfShape myShapesOn;
355   TopTools_DataMapOfShapeShape myShapesInclusive;
356   Standard_Real myTolMass;
357   Standard_Real myTolCG;
358   Standard_Boolean myFound;
359   GEOMAlgo_DataMapOfShapePnt myMapShapePnt;
360   TopTools_DataMapOfShapeInteger myChecked;
361   //
362   TopoDS_Shape myResult;
363
364 private:
365 };
366
367
368
369 #endif