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
63 All = Groups | Fields | SubShapes,
66 Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
67 Standard_EXPORT ~GEOMImpl_IShapesOperations();
69 Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
70 Handle(GEOM_Object) thePoint2);
72 Standard_EXPORT Handle(GEOM_Object) MakeEdgeOnCurveByLength (Handle(GEOM_Object) theCurve,
73 const Standard_Real theLength,
74 Handle(GEOM_Object) theStartPoint);
76 Standard_EXPORT Handle(GEOM_Object) MakeEdgeWire (Handle(GEOM_Object) theWire,
77 const Standard_Real theLinearTolerance,
78 const Standard_Real theAngularTolerance);
80 Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
81 const Standard_Real theTolerance);
83 Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
85 Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list<Handle(GEOM_Object)> theWires,
86 const bool isPlanarWanted);
88 Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
90 Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
92 Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
94 Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
95 const Standard_Real theTolerance,
96 const Standard_Boolean doKeepNonSolids);
98 //Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
99 // const Standard_Real theTolerance);
101 Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
102 const Standard_Real theTolerance,
103 std::list<Handle(GEOM_Object)> theFaces,
104 const Standard_Boolean doKeepNonSolids,
105 const Standard_Boolean doGlueAllEdges);
107 Standard_EXPORT Handle(GEOM_Object) MakeGlueEdges (Handle(GEOM_Object) theShape,
108 const Standard_Real theTolerance);
110 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueShapes (Handle(GEOM_Object) theShape,
111 const Standard_Real theTolerance,
112 const TopAbs_ShapeEnum theType);
114 Standard_EXPORT Handle(GEOM_Object) MakeGlueEdgesByList (Handle(GEOM_Object) theShape,
115 const Standard_Real theTolerance,
116 std::list<Handle(GEOM_Object)> theEdges);
118 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape,
119 const Standard_Boolean theGroupsOnly);
120 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects(Handle(GEOM_Object) theShape,
121 const Standard_Integer theTypes = All);
124 EXPLODE_OLD_INCLUDE_MAIN,
125 EXPLODE_NEW_INCLUDE_MAIN,
126 EXPLODE_NEW_EXCLUDE_MAIN
129 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode
130 (Handle(GEOM_Object) theShape,
131 const Standard_Integer theShapeType,
132 const Standard_Boolean isSorted,
133 const ExplodeType theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
135 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs
136 (Handle(GEOM_Object) theShape,
137 const Standard_Integer theShapeType,
138 const Standard_Boolean isSorted,
139 const ExplodeType theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
141 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
142 const Standard_Integer theID);
144 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeSubShapes
145 (Handle(GEOM_Object) theMainShape,
146 Handle(TColStd_HArray1OfInteger) theIndices);
148 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
149 Handle(GEOM_Object) theSubShape);
151 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSubShapesIndices (Handle(GEOM_Object) theMainShape,
152 std::list<Handle(GEOM_Object)> theSubShapes);
154 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
155 Handle(GEOM_Object) theSubShape);
157 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
159 Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
160 const Standard_Integer theShapeType);
162 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
164 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
166 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
167 GetSharedShapes (Handle(GEOM_Object) theShape1,
168 Handle(GEOM_Object) theShape2,
169 const Standard_Integer theShapeType);
171 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
172 GetSharedShapes (std::list<Handle(GEOM_Object)> theShapes,
173 const Standard_Integer theShapeType);
175 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
176 GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
177 const Standard_Integer theShapeType,
178 const Handle(GEOM_Object)& theAx1,
179 const GEOMAlgo_State theState);
181 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
182 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
183 const Standard_Integer theShapeType,
184 const Handle(GEOM_Object)& theAx1,
185 const Handle(GEOM_Object)& thePnt,
186 const GEOMAlgo_State theState);
189 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
190 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
191 const Standard_Integer theShapeType,
192 const Handle(GEOM_Object)& theAxis,
193 const Standard_Real theRadius,
194 const GEOMAlgo_State theState);
196 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
197 GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
198 const Standard_Integer theShapeType,
199 const Handle(GEOM_Object)& theAxis,
200 const Handle(GEOM_Object)& thePnt,
201 const Standard_Real theRadius,
202 const GEOMAlgo_State theState);
204 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
205 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
206 const Standard_Integer theShapeType,
207 const Handle(GEOM_Object)& theCenter,
208 const Standard_Real theRadius,
209 const GEOMAlgo_State theState);
211 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
212 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
213 const Standard_Integer theShapeType,
214 const Handle(GEOM_Object)& theAx1,
215 const GEOMAlgo_State theState);
217 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
218 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
219 const Standard_Integer theShapeType,
220 const Handle(GEOM_Object)& theAx1,
221 const Handle(GEOM_Object)& thePnt,
222 const GEOMAlgo_State theState);
224 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
225 GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
226 const Standard_Integer theShapeType,
227 const Handle(GEOM_Object)& theAxis,
228 const Standard_Real theRadius,
229 const GEOMAlgo_State theState);
231 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
232 GetShapesOnCylinderWithLocationIDs (const Handle(GEOM_Object)& theShape,
233 const Standard_Integer theShapeType,
234 const Handle(GEOM_Object)& theAxis,
235 const Handle(GEOM_Object)& thePnt,
236 const Standard_Real theRadius,
237 const GEOMAlgo_State theState);
239 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
240 GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
241 const Standard_Integer theShapeType,
242 const Handle(GEOM_Object)& theCenter,
243 const Standard_Real theRadius,
244 const GEOMAlgo_State theState);
247 * \brief Find sub-shapes complying with given status about quadrangle
248 * \param theShape - the shape to explore
249 * \param theShapeType - type of sub-shape of theShape
250 * \param theTopLeftPoint - top left quadrangle corner
251 * \param theTopRigthPoint - top right quadrangle corner
252 * \param theBottomLeftPoint - bottom left quadrangle corner
253 * \param theBottomRigthPoint - bottom right quadrangle corner
254 * \param theState - required state
255 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
257 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
258 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
259 const Standard_Integer theShapeType,
260 const Handle(GEOM_Object)& theTopLeftPoint,
261 const Handle(GEOM_Object)& theTopRigthPoint,
262 const Handle(GEOM_Object)& theBottomLeftPoint,
263 const Handle(GEOM_Object)& theBottomRigthPoint,
264 const GEOMAlgo_State theState);
267 * \brief Find IDs of sub-shapes complying with given status about quadrangle
268 * \param theShape - the shape to explore
269 * \param theShapeType - type of sub-shape of theShape
270 * \param theTopLeftPoint - top left quadrangle corner
271 * \param theTopRigthPoint - top right quadrangle corner
272 * \param theBottomLeftPoint - bottom left quadrangle corner
273 * \param theBottomRigthPoint - bottom right quadrangle corner
274 * \param theState - required state
275 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
277 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
278 GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
279 const Standard_Integer theShapeType,
280 const Handle(GEOM_Object)& theTopLeftPoint,
281 const Handle(GEOM_Object)& theTopRigthPoint,
282 const Handle(GEOM_Object)& theBottomLeftPoint,
283 const Handle(GEOM_Object)& theBottomRigthPoint,
284 const GEOMAlgo_State theState);
286 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
287 const Standard_Integer theShapeType,
288 Handle(GEOM_Object) theAxis,
289 const Standard_Real theRadius);
291 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
292 const Standard_Integer theShapeType,
293 Handle(GEOM_Object) theCenter,
294 const Standard_Real theRadius);
296 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
298 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
299 Handle(GEOM_Object) theShapeWhat);
301 Standard_EXPORT Handle(GEOM_Object) GetInPlaceOld (Handle(GEOM_Object) theShapeWhere,
302 Handle(GEOM_Object) theShapeWhat);
304 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
305 Handle(GEOM_Object) theShapeWhat);
308 * \brief Searches a shape equal to theWhat in the context of theWhere
309 * \param theShapeWhere - a context shap
310 * \param theShapeWhat - a sample shape
311 * \retval Handle(GEOM_Object) - found shape
313 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
314 const Handle(GEOM_Object)& theShapeWhat);
317 * \brief Searches a shape equal to theWhat in the context of theWhere
318 * \param theShapeWhere - a context shap
319 * \param theShapeWhat - a sample shape
320 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
322 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSameIDs(const Handle(GEOM_Object)& theShapeWhere,
323 const Handle(GEOM_Object)& theShapeWhat);
326 * \brief Find IDs of sub-shapes complying with given status about surface
327 * \param theBox - the box to check state of sub-shapes against
328 * \param theShape - the shape to explore
329 * \param theShapeType - type of sub-shape of theShape
330 * \param theState - required state
331 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
333 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
334 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
335 const Handle(GEOM_Object)& theShape,
336 const Standard_Integer theShapeType,
337 GEOMAlgo_State theState);
340 * \brief Find sub-shapes complying with given status about surface
341 * \param theBox - the box to check state of sub-shapes against
342 * \param theShape - the shape to explore
343 * \param theShapeType - type of sub-shape of theShape
344 * \param theState - required state
345 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
347 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
348 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
349 const Handle(GEOM_Object)& theShape,
350 const Standard_Integer theShapeType,
351 GEOMAlgo_State theState);
354 * \brief Find IDs of sub-shapes complying with given status about surface
355 * \param theCheckShape - the shape to check state of sub-shapes against
356 * \param theShape - the shape to explore
357 * \param theShapeType - type of sub-shape of theShape
358 * \param theState - required state
359 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
361 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
362 GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
363 const Handle(GEOM_Object)& theShape,
364 const Standard_Integer theShapeType,
365 GEOMAlgo_State theState);
368 * \brief Find sub-shapes complying with given status about surface
369 * \param theCheckShape - the shape to check state of sub-shapes against
370 * \param theShape - the shape to explore
371 * \param theShapeType - type of sub-shape of theShape
372 * \param theState - required state
373 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
375 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
376 GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
377 const Handle(GEOM_Object)& theShape,
378 const Standard_Integer theShapeType,
379 GEOMAlgo_State theState);
380 Standard_EXPORT Handle(GEOM_Object)
381 GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
382 const Handle(GEOM_Object)& theShape,
383 const Standard_Integer theShapeType,
384 GEOMAlgo_State theState);
387 Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
388 const Standard_Integer theObjectType,
389 const Standard_Integer theFunctionType,
390 const TCollection_AsciiString& theMethodName);
392 // ----------------------------------------------------
393 // methods common for all GetShapesOnXXX() functions
394 // ----------------------------------------------------
397 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
398 * \param theShapeType - the shape type to check
399 * \retval bool - result of the check
401 bool checkTypeShapesOn(const Standard_Integer theShapeType);
404 * \brief Creates Geom_Plane
405 * \param theAx1 - edge defining plane normal
406 * \retval Handle(Geom_Surface) - resulting surface
408 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
411 * \brief Creates Geom_CylindricalSurface
412 * \param theAx1 - edge defining cylinder axis
413 * \param theRadius - cylinder radius
414 * \retval Handle(Geom_Surface) - resulting surface
416 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
417 const Standard_Real theRadius);
420 * \brief Find IDs of sub-shapes complying with given status about surface
421 * \param theSurface - the surface to check state of sub-shapes against
422 * \param theShape - the shape to explore
423 * \param theShapeType - type of sub-shape of theShape
424 * \param theState - required state
425 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
427 Handle(TColStd_HSequenceOfInteger)
428 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
429 const TopoDS_Shape& theShape,
430 TopAbs_ShapeEnum theShapeType,
431 GEOMAlgo_State theState);
434 * \brief Find sub-shapes complying with given status about surface
435 * \param theSurface - the surface to check state of sub-shapes against
436 * \param theShape - the shape to explore
437 * \param theShapeType - type of sub-shape of theShape
438 * \param theState - required state
439 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
440 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
442 Handle(TColStd_HSequenceOfTransient)
443 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
444 const Handle(GEOM_Object)& theShape,
445 TopAbs_ShapeEnum theShapeType,
446 GEOMAlgo_State theState,
447 TCollection_AsciiString & theShapeEntries);
450 * \brief Find IDs of sub-shapes complying with given status about quadrangle
451 * \param theShape - the shape to explore
452 * \param theShapeType - type of sub-shape of theShape
453 * \param theTopLeftPoint - top left quadrangle corner
454 * \param theTopRigthPoint - top right quadrangle corner
455 * \param theBottomLeftPoint - bottom left quadrangle corner
456 * \param theBottomRigthPoint - bottom right quadrangle corner
457 * \param theState - required state
458 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
460 Handle(TColStd_HSequenceOfInteger)
461 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
462 const Standard_Integer theShapeType,
463 const Handle(GEOM_Object)& theTopLeftPoint,
464 const Handle(GEOM_Object)& theTopRigthPoint,
465 const Handle(GEOM_Object)& theBottomLeftPoint,
466 const Handle(GEOM_Object)& theBottomRigthPoint,
467 const GEOMAlgo_State theState);
470 * \brief Find IDs of sub-shapes complying with given status about surface
471 * \param theBox - the box to check state of sub-shapes against
472 * \param theShape - the shape to explore
473 * \param theShapeType - type of sub-shape of theShape
474 * \param theState - required state
475 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
477 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
478 const Handle(GEOM_Object)& theShape,
479 const Standard_Integer theShapeType,
480 GEOMAlgo_State theState);
483 * \brief Find IDs of sub-shapes complying with given status about surface
484 * \param theCheckShape - the shape to check state of sub-shapes against
485 * \param theShape - the shape to explore
486 * \param theShapeType - type of sub-shape of theShape
487 * \param theState - required state
488 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
490 Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
491 (const Handle(GEOM_Object)& theCheckShape,
492 const Handle(GEOM_Object)& theShape,
493 const Standard_Integer theShapeType,
494 GEOMAlgo_State theState);
497 * \brief Find shape objects and their entries by their ids
498 * \param theShape - the main shape
499 * \param theShapeIDs - theShapeIDs - incoming shape ids
500 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
501 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
503 Handle(TColStd_HSequenceOfTransient)
504 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
505 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
506 TCollection_AsciiString & theShapeEntries);
509 * \brief Select the object created last
510 * \param theObj1 - Object 1
511 * \param theObj2 - Object 2
512 * \retval Handle(GEOM_Object) - selected object
514 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
515 const Handle(GEOM_Object)& theObj2);