1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: GEOMAlgo_GetInPlace.hxx
24 // Author: Peter KURNEV
26 #ifndef _GEOMAlgo_GetInPlace_HeaderFile
27 #define _GEOMAlgo_GetInPlace_HeaderFile
29 #include <Standard.hxx>
30 #include <Standard_Macro.hxx>
31 #include <Standard_Integer.hxx>
32 #include <Standard_Real.hxx>
33 #include <Standard_Boolean.hxx>
35 #include <TopAbs_ShapeEnum.hxx>
36 #include <TopoDS_Shape.hxx>
38 #include <GEOMAlgo_CoupleOfShapes.hxx>
39 #include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
40 #include <GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx>
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>
50 //=======================================================================
52 * The implementation of iterator of intersected shapes
53 * for Get In Place Algorithm.
54 * The intersection is in terms of 3D bounding boxes.
56 //=======================================================================
57 //class : GEOMAlgo_GetInPlaceIterator
59 //=======================================================================
60 class GEOMAlgo_GetInPlaceIterator {
66 GEOMAlgo_GetInPlaceIterator();
72 virtual ~GEOMAlgo_GetInPlaceIterator();
75 * Clear the internal content.
81 * Append the pair of intersected shapes.
83 * The pair of intersected shapes.
86 void AppendPair(const GEOMAlgo_CoupleOfShapes& theCS) ;
89 * Initialize the iterator.
91 * The type of (sub)shape What.
93 * The type of (sub)shape Where.
96 void Initialize(const TopAbs_ShapeEnum theT1,
97 const TopAbs_ShapeEnum theT2) ;
99 * Check the existence of pairs to iterare.
101 * Standard_True if there are pairs to iterare.
104 Standard_Boolean More() const;
107 * Shift to the next pair.
113 * Returns the pair of intersected shapes.
115 * The pair of intersected shapes.
118 const GEOMAlgo_CoupleOfShapes& Value() const;
121 Standard_Integer myDim;
122 GEOMAlgo_ListOfCoupleOfShapes myLists[10];
123 GEOMAlgo_ListOfCoupleOfShapes myEmptyList;
124 GEOMAlgo_ListIteratorOfListOfCoupleOfShapes myIterator;
130 //=======================================================================
132 * The implementation of Get In Place Algorithm.
133 * The algorithm provides the search the argument [What]
134 * in the shape [Where].
136 //=======================================================================
137 //class : GEOMAlgo_GetInPlace
139 //=======================================================================
140 class GEOMAlgo_GetInPlace : public GEOMAlgo_GluerAlgo,
148 GEOMAlgo_GetInPlace();
153 virtual ~GEOMAlgo_GetInPlace();
155 * Modifier. Sets the shape where the search is intended.
157 * The shape where the search is intended.
160 virtual void SetShapeWhere(const TopoDS_Shape& theShape) ;
163 * Selector. Returns the shape where the search is intended.
165 * The shape where the search is intended.
168 const TopoDS_Shape& ShapeWhere() const;
171 * Modifier. Sets the tolerance of mass.
173 * The value tolerance of mass.
176 void SetTolMass(const Standard_Real theTol) ;
179 * Selector. Returns the value tolerance of mass.
181 * The value tolerance of mass.
184 Standard_Real TolMass() const;
187 * Modifier. Sets the tolerance of center of gravily.
189 * The value tolerance of center of gravily.
192 void SetTolCG(const Standard_Real theTol) ;
195 * Selector. Returns the tolerance of center of gravily.
197 * The value tolerance of center of gravily.
200 Standard_Real TolCG() const;
203 * Perform the algorithm.
206 virtual void Perform() ;
209 * Returns state of the search.
211 * Standard_True if the whole argument is found.
214 Standard_Boolean IsFound() const;
220 virtual void CheckData() ;
223 * Clear the internal content.
226 virtual void Clear() ;
229 * Returns the map of shapes IN.
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].
237 const GEOMAlgo_DataMapOfShapeMapOfShape& ShapesIn() const;
240 * Returns the map of shapes ON.
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].
248 const GEOMAlgo_DataMapOfShapeMapOfShape& ShapesOn() const;
251 * Returns the result that includes parts of the whole and whole from parts.
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.
257 * The Result is a compound.
260 * - the compound of the parts from myShapeWhere
261 * that correspond to the myArgument if success.
262 * - NULL shape otherwise
265 const TopoDS_Shape &Result();
280 void PerformEE(const TopoDS_Shape &theE1, const TopoDS_Shape &theE2);
291 void PerformFF(const TopoDS_Shape &theF1, const TopoDS_Shape &theF2);
294 void FillEdgesOn(const TopoDS_Shape &theShape);
297 void FillFacesOn(const TopoDS_Shape &theShape);
300 void FillSolidsOn(const TopoDS_Shape &theShape);
308 void PerformZZ(const TopoDS_Shape &theSo1, const TopoDS_Shape &theSo2);
311 void FillImages(const TopoDS_Shape &theShape,
312 const Standard_Boolean IsWhere);
314 void FillImgSimple(const TopoDS_Shape &theShape,
315 const TopAbs_ShapeEnum theSubShapeType,
316 const Standard_Boolean IsWhere);
318 void FillImgComplex(const TopoDS_Shape &theShape,
319 const Standard_Boolean IsWhere);
321 void FillImgComplex(const TopoDS_Shape &theShape,
322 const TopAbs_ShapeEnum theSubShapeType,
323 const Standard_Boolean IsWhere);
329 void FillShapesIn(const TopoDS_Shape& theS1,
330 const TopoDS_Shape& theS2) ;
333 void FillShapesOn(const TopoDS_Shape& theS1,
334 const TopoDS_Shape& theS2) ;
337 Standard_Boolean CheckCoincidence(const TopoDS_Shape& theS1,
338 const TopoDS_Shape& theS2);
341 Standard_Integer CheckGProps(const TopoDS_Shape& theS);
343 Standard_Boolean CompareGProps
344 (const TopoDS_Shape &theShape1,
345 const TopTools_ListOfShape &theListShape2) const;
348 void UpdateChecked(const TopoDS_Shape& theS1,
349 const Standard_Integer theFlag);
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;
362 TopoDS_Shape myResult;