1 // Copyright (C) 2007-2014 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
23 //=============================================================================
24 // File : GEOMImpl_IShapesOperations.hxx
26 // Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007
28 //=============================================================================
30 #ifndef _GEOMImpl_IShapesOperations_HXX_
31 #define _GEOMImpl_IShapesOperations_HXX_
33 #include "GEOM_IOperations.hxx"
35 #include "GEOMAlgo_State.hxx"
37 #include <TopoDS_Shape.hxx>
38 #include <TopTools_ListOfShape.hxx>
39 #include <NCollection_DataMap.hxx>
40 #include <TColStd_HSequenceOfTransient.hxx>
41 #include <TColStd_HSequenceOfInteger.hxx>
43 #include <Handle_Geom_Surface.hxx>
51 class Handle(GEOM_Object);
52 class Handle(TColStd_HArray1OfInteger);
54 class GEOMImpl_IShapesOperations : public GEOM_IOperations
57 Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
58 Standard_EXPORT ~GEOMImpl_IShapesOperations();
60 Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
61 Handle(GEOM_Object) thePoint2);
63 Standard_EXPORT Handle(GEOM_Object) MakeEdgeOnCurveByLength (Handle(GEOM_Object) theCurve,
64 const Standard_Real theLength,
65 Handle(GEOM_Object) theStartPoint);
67 Standard_EXPORT Handle(GEOM_Object) MakeEdgeWire (Handle(GEOM_Object) theWire,
68 const Standard_Real theLinearTolerance,
69 const Standard_Real theAngularTolerance);
71 Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
72 const Standard_Real theTolerance);
74 Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
76 Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list<Handle(GEOM_Object)> theWires,
77 const bool isPlanarWanted);
79 Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
81 Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
83 Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
85 Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
86 const Standard_Real theTolerance,
87 const Standard_Boolean doKeepNonSolids);
89 //Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
90 // const Standard_Real theTolerance);
92 Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
93 const Standard_Real theTolerance,
94 std::list<Handle(GEOM_Object)> theFaces,
95 const Standard_Boolean doKeepNonSolids,
96 const Standard_Boolean doGlueAllEdges);
98 Standard_EXPORT Handle(GEOM_Object) MakeGlueEdges (Handle(GEOM_Object) theShape,
99 const Standard_Real theTolerance);
101 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueShapes (Handle(GEOM_Object) theShape,
102 const Standard_Real theTolerance,
103 const TopAbs_ShapeEnum theType);
105 Standard_EXPORT Handle(GEOM_Object) MakeGlueEdgesByList (Handle(GEOM_Object) theShape,
106 const Standard_Real theTolerance,
107 std::list<Handle(GEOM_Object)> theEdges);
109 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects
110 (Handle(GEOM_Object) theShape,
111 const Standard_Boolean theGroupsOnly);
114 EXPLODE_OLD_INCLUDE_MAIN,
115 EXPLODE_NEW_INCLUDE_MAIN,
116 EXPLODE_NEW_EXCLUDE_MAIN
119 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode
120 (Handle(GEOM_Object) theShape,
121 const Standard_Integer theShapeType,
122 const Standard_Boolean isSorted,
123 const ExplodeType theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
125 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs
126 (Handle(GEOM_Object) theShape,
127 const Standard_Integer theShapeType,
128 const Standard_Boolean isSorted,
129 const ExplodeType theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
131 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
132 const Standard_Integer theID);
134 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeSubShapes
135 (Handle(GEOM_Object) theMainShape,
136 Handle(TColStd_HArray1OfInteger) theIndices);
138 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
139 Handle(GEOM_Object) theSubShape);
141 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSubShapesIndices (Handle(GEOM_Object) theMainShape,
142 std::list<Handle(GEOM_Object)> theSubShapes);
144 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
145 Handle(GEOM_Object) theSubShape);
147 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
149 Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
150 const Standard_Integer theShapeType);
152 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
154 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
156 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
157 GetSharedShapes (Handle(GEOM_Object) theShape1,
158 Handle(GEOM_Object) theShape2,
159 const Standard_Integer theShapeType);
161 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
162 GetSharedShapes (std::list<Handle(GEOM_Object)> theShapes,
163 const Standard_Integer theShapeType);
165 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
166 GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
167 const Standard_Integer theShapeType,
168 const Handle(GEOM_Object)& theAx1,
169 const GEOMAlgo_State theState);
171 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
172 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
173 const Standard_Integer theShapeType,
174 const Handle(GEOM_Object)& theAx1,
175 const Handle(GEOM_Object)& thePnt,
176 const GEOMAlgo_State theState);
179 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
180 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
181 const Standard_Integer theShapeType,
182 const Handle(GEOM_Object)& theAxis,
183 const Standard_Real theRadius,
184 const GEOMAlgo_State theState);
186 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
187 GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
188 const Standard_Integer theShapeType,
189 const Handle(GEOM_Object)& theAxis,
190 const Handle(GEOM_Object)& thePnt,
191 const Standard_Real theRadius,
192 const GEOMAlgo_State theState);
194 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
195 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
196 const Standard_Integer theShapeType,
197 const Handle(GEOM_Object)& theCenter,
198 const Standard_Real theRadius,
199 const GEOMAlgo_State theState);
201 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
202 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
203 const Standard_Integer theShapeType,
204 const Handle(GEOM_Object)& theAx1,
205 const GEOMAlgo_State theState);
207 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
208 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
209 const Standard_Integer theShapeType,
210 const Handle(GEOM_Object)& theAx1,
211 const Handle(GEOM_Object)& thePnt,
212 const GEOMAlgo_State theState);
214 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
215 GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
216 const Standard_Integer theShapeType,
217 const Handle(GEOM_Object)& theAxis,
218 const Standard_Real theRadius,
219 const GEOMAlgo_State theState);
221 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
222 GetShapesOnCylinderWithLocationIDs (const Handle(GEOM_Object)& theShape,
223 const Standard_Integer theShapeType,
224 const Handle(GEOM_Object)& theAxis,
225 const Handle(GEOM_Object)& thePnt,
226 const Standard_Real theRadius,
227 const GEOMAlgo_State theState);
229 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
230 GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
231 const Standard_Integer theShapeType,
232 const Handle(GEOM_Object)& theCenter,
233 const Standard_Real theRadius,
234 const GEOMAlgo_State theState);
237 * \brief Find sub-shapes complying with given status about quadrangle
238 * \param theShape - the shape to explore
239 * \param theShapeType - type of sub-shape of theShape
240 * \param theTopLeftPoint - top left quadrangle corner
241 * \param theTopRigthPoint - top right quadrangle corner
242 * \param theBottomLeftPoint - bottom left quadrangle corner
243 * \param theBottomRigthPoint - bottom right quadrangle corner
244 * \param theState - required state
245 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
247 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
248 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
249 const Standard_Integer theShapeType,
250 const Handle(GEOM_Object)& theTopLeftPoint,
251 const Handle(GEOM_Object)& theTopRigthPoint,
252 const Handle(GEOM_Object)& theBottomLeftPoint,
253 const Handle(GEOM_Object)& theBottomRigthPoint,
254 const GEOMAlgo_State theState);
257 * \brief Find IDs of sub-shapes complying with given status about quadrangle
258 * \param theShape - the shape to explore
259 * \param theShapeType - type of sub-shape of theShape
260 * \param theTopLeftPoint - top left quadrangle corner
261 * \param theTopRigthPoint - top right quadrangle corner
262 * \param theBottomLeftPoint - bottom left quadrangle corner
263 * \param theBottomRigthPoint - bottom right quadrangle corner
264 * \param theState - required state
265 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
267 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
268 GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
269 const Standard_Integer theShapeType,
270 const Handle(GEOM_Object)& theTopLeftPoint,
271 const Handle(GEOM_Object)& theTopRigthPoint,
272 const Handle(GEOM_Object)& theBottomLeftPoint,
273 const Handle(GEOM_Object)& theBottomRigthPoint,
274 const GEOMAlgo_State theState);
276 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
277 const Standard_Integer theShapeType,
278 Handle(GEOM_Object) theAxis,
279 const Standard_Real theRadius);
281 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
282 const Standard_Integer theShapeType,
283 Handle(GEOM_Object) theCenter,
284 const Standard_Real theRadius);
286 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
288 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
289 Handle(GEOM_Object) theShapeWhat);
291 Standard_EXPORT Handle(GEOM_Object) GetInPlaceOld (Handle(GEOM_Object) theShapeWhere,
292 Handle(GEOM_Object) theShapeWhat);
294 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
295 Handle(GEOM_Object) theShapeWhat);
298 * \brief Searches a shape equal to theWhat in the context of theWhere
299 * \param theShapeWhere - a context shap
300 * \param theShapeWhat - a sample shape
301 * \retval Handle(GEOM_Object) - found shape
303 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
304 const Handle(GEOM_Object)& theShapeWhat);
307 * \brief Searches a shape equal to theWhat in the context of theWhere
308 * \param theShapeWhere - a context shap
309 * \param theShapeWhat - a sample shape
310 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
312 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSameIDs(const Handle(GEOM_Object)& theShapeWhere,
313 const Handle(GEOM_Object)& theShapeWhat);
316 * \brief Find IDs of sub-shapes complying with given status about surface
317 * \param theBox - the box to check state of sub-shapes against
318 * \param theShape - the shape to explore
319 * \param theShapeType - type of sub-shape of theShape
320 * \param theState - required state
321 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
323 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
324 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
325 const Handle(GEOM_Object)& theShape,
326 const Standard_Integer theShapeType,
327 GEOMAlgo_State theState);
330 * \brief Find sub-shapes complying with given status about surface
331 * \param theBox - the box to check state of sub-shapes against
332 * \param theShape - the shape to explore
333 * \param theShapeType - type of sub-shape of theShape
334 * \param theState - required state
335 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
337 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
338 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
339 const Handle(GEOM_Object)& theShape,
340 const Standard_Integer theShapeType,
341 GEOMAlgo_State theState);
344 * \brief Find IDs of sub-shapes complying with given status about surface
345 * \param theCheckShape - the shape to check state of sub-shapes against
346 * \param theShape - the shape to explore
347 * \param theShapeType - type of sub-shape of theShape
348 * \param theState - required state
349 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
351 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
352 GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
353 const Handle(GEOM_Object)& theShape,
354 const Standard_Integer theShapeType,
355 GEOMAlgo_State theState);
358 * \brief Find sub-shapes complying with given status about surface
359 * \param theCheckShape - the shape to check state of sub-shapes against
360 * \param theShape - the shape to explore
361 * \param theShapeType - type of sub-shape of theShape
362 * \param theState - required state
363 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
365 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
366 GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
367 const Handle(GEOM_Object)& theShape,
368 const Standard_Integer theShapeType,
369 GEOMAlgo_State theState);
370 Standard_EXPORT Handle(GEOM_Object)
371 GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
372 const Handle(GEOM_Object)& theShape,
373 const Standard_Integer theShapeType,
374 GEOMAlgo_State theState);
377 Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
378 const Standard_Integer theObjectType,
379 const Standard_Integer theFunctionType,
380 const TCollection_AsciiString& theMethodName);
382 // ----------------------------------------------------
383 // methods common for all GetShapesOnXXX() functions
384 // ----------------------------------------------------
387 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
388 * \param theShapeType - the shape type to check
389 * \retval bool - result of the check
391 bool checkTypeShapesOn(const Standard_Integer theShapeType);
394 * \brief Creates Geom_Plane
395 * \param theAx1 - edge defining plane normal
396 * \retval Handle(Geom_Surface) - resulting surface
398 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
401 * \brief Creates Geom_CylindricalSurface
402 * \param theAx1 - edge defining cylinder axis
403 * \param theRadius - cylinder radius
404 * \retval Handle(Geom_Surface) - resulting surface
406 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
407 const Standard_Real theRadius);
410 * \brief Find IDs of sub-shapes complying with given status about surface
411 * \param theSurface - the surface to check state of sub-shapes against
412 * \param theShape - the shape to explore
413 * \param theShapeType - type of sub-shape of theShape
414 * \param theState - required state
415 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
417 Handle(TColStd_HSequenceOfInteger)
418 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
419 const TopoDS_Shape& theShape,
420 TopAbs_ShapeEnum theShapeType,
421 GEOMAlgo_State theState);
424 * \brief Find sub-shapes complying with given status about surface
425 * \param theSurface - the surface to check state of sub-shapes against
426 * \param theShape - the shape to explore
427 * \param theShapeType - type of sub-shape of theShape
428 * \param theState - required state
429 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
430 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
432 Handle(TColStd_HSequenceOfTransient)
433 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
434 const Handle(GEOM_Object)& theShape,
435 TopAbs_ShapeEnum theShapeType,
436 GEOMAlgo_State theState,
437 TCollection_AsciiString & theShapeEntries);
440 * \brief Find IDs of sub-shapes complying with given status about quadrangle
441 * \param theShape - the shape to explore
442 * \param theShapeType - type of sub-shape of theShape
443 * \param theTopLeftPoint - top left quadrangle corner
444 * \param theTopRigthPoint - top right quadrangle corner
445 * \param theBottomLeftPoint - bottom left quadrangle corner
446 * \param theBottomRigthPoint - bottom right quadrangle corner
447 * \param theState - required state
448 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
450 Handle(TColStd_HSequenceOfInteger)
451 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
452 const Standard_Integer theShapeType,
453 const Handle(GEOM_Object)& theTopLeftPoint,
454 const Handle(GEOM_Object)& theTopRigthPoint,
455 const Handle(GEOM_Object)& theBottomLeftPoint,
456 const Handle(GEOM_Object)& theBottomRigthPoint,
457 const GEOMAlgo_State theState);
460 * \brief Find IDs of sub-shapes complying with given status about surface
461 * \param theBox - the box to check state of sub-shapes against
462 * \param theShape - the shape to explore
463 * \param theShapeType - type of sub-shape of theShape
464 * \param theState - required state
465 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
467 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
468 const Handle(GEOM_Object)& theShape,
469 const Standard_Integer theShapeType,
470 GEOMAlgo_State theState);
473 * \brief Find IDs of sub-shapes complying with given status about surface
474 * \param theCheckShape - the shape to check state of sub-shapes against
475 * \param theShape - the shape to explore
476 * \param theShapeType - type of sub-shape of theShape
477 * \param theState - required state
478 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
480 Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
481 (const Handle(GEOM_Object)& theCheckShape,
482 const Handle(GEOM_Object)& theShape,
483 const Standard_Integer theShapeType,
484 GEOMAlgo_State theState);
487 * \brief Find shape objects and their entries by their ids
488 * \param theShape - the main shape
489 * \param theShapeIDs - theShapeIDs - incoming shape ids
490 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
491 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
493 Handle(TColStd_HSequenceOfTransient)
494 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
495 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
496 TCollection_AsciiString & theShapeEntries);
499 * \brief Select the object created last
500 * \param theObj1 - Object 1
501 * \param theObj2 - Object 2
502 * \retval Handle(GEOM_Object) - selected object
504 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
505 const Handle(GEOM_Object)& theObj2);