1 // Copyright (C) 2007-2010 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.
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
29 //=============================================================================
31 #ifndef _GEOMImpl_IShapesOperations_HXX_
32 #define _GEOMImpl_IShapesOperations_HXX_
34 #include "GEOM_IOperations.hxx"
36 #include "GEOMAlgo_State.hxx"
38 #include <TopTools_ListOfShape.hxx>
39 #include <TColStd_HSequenceOfTransient.hxx>
40 #include <TColStd_HSequenceOfInteger.hxx>
43 #include <Handle_Geom_Surface.hxx>
48 class Handle(GEOM_Object);
49 class Handle(TColStd_HArray1OfInteger);
51 class GEOMImpl_IShapesOperations : public GEOM_IOperations
54 Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
55 Standard_EXPORT ~GEOMImpl_IShapesOperations();
57 Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
58 Handle(GEOM_Object) thePoint2);
60 Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
61 const Standard_Real theTolerance);
63 Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
65 Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list<Handle(GEOM_Object)> theWires,
66 const bool isPlanarWanted);
68 Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
70 Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell);
72 Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
74 Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
76 Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
77 const Standard_Real theTolerance,
78 const Standard_Boolean doKeepNonSolids);
80 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
81 const Standard_Real theTolerance);
83 Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
84 const Standard_Real theTolerance,
85 std::list<Handle(GEOM_Object)> theFaces,
86 const Standard_Boolean doKeepNonSolids);
88 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects
89 (Handle(GEOM_Object) theShape,
90 const Standard_Boolean theGroupsOnly);
92 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object) theShape,
93 const Standard_Integer theShapeType,
94 const Standard_Boolean isSorted);
96 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object) theShape,
97 const Standard_Integer theShapeType,
98 const Standard_Boolean isSorted);
100 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
101 const Standard_Integer theID);
103 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
104 Handle(GEOM_Object) theSubShape);
106 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
107 Handle(GEOM_Object) theSubShape);
109 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
111 Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
112 const Standard_Integer theShapeType);
114 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
116 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
118 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object) theShape1,
119 Handle(GEOM_Object) theShape2,
120 const Standard_Integer theShapeType);
122 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
123 const Standard_Integer theShapeType,
124 const Handle(GEOM_Object)& theAx1,
125 const GEOMAlgo_State theState);
127 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
128 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
129 const Standard_Integer theShapeType,
130 const Handle(GEOM_Object)& theAx1,
131 const Handle(GEOM_Object)& thePnt,
132 const GEOMAlgo_State theState);
135 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
136 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
137 const Standard_Integer theShapeType,
138 const Handle(GEOM_Object)& theAxis,
139 const Standard_Real theRadius,
140 const GEOMAlgo_State theState);
142 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
143 GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
144 const Standard_Integer theShapeType,
145 const Handle(GEOM_Object)& theAxis,
146 const Handle(GEOM_Object)& thePnt,
147 const Standard_Real theRadius,
148 const GEOMAlgo_State theState);
150 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
151 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
152 const Standard_Integer theShapeType,
153 const Handle(GEOM_Object)& theCenter,
154 const Standard_Real theRadius,
155 const GEOMAlgo_State theState);
157 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
158 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
159 const Standard_Integer theShapeType,
160 const Handle(GEOM_Object)& theAx1,
161 const GEOMAlgo_State theState);
163 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
164 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
165 const Standard_Integer theShapeType,
166 const Handle(GEOM_Object)& theAx1,
167 const Handle(GEOM_Object)& thePnt,
168 const GEOMAlgo_State theState);
170 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
171 GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
172 const Standard_Integer theShapeType,
173 const Handle(GEOM_Object)& theAxis,
174 const Standard_Real theRadius,
175 const GEOMAlgo_State theState);
177 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
178 GetShapesOnCylinderWithLocationIDs (const Handle(GEOM_Object)& theShape,
179 const Standard_Integer theShapeType,
180 const Handle(GEOM_Object)& theAxis,
181 const Handle(GEOM_Object)& thePnt,
182 const Standard_Real theRadius,
183 const GEOMAlgo_State theState);
185 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
186 GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
187 const Standard_Integer theShapeType,
188 const Handle(GEOM_Object)& theCenter,
189 const Standard_Real theRadius,
190 const GEOMAlgo_State theState);
193 * \brief Find subshapes complying with given status about quadrangle
194 * \param theShape - the shape to explore
195 * \param theShapeType - type of subshape of theShape
196 * \param theTopLeftPoint - top left quadrangle corner
197 * \param theTopRigthPoint - top right quadrangle corner
198 * \param theBottomLeftPoint - bottom left quadrangle corner
199 * \param theBottomRigthPoint - bottom right quadrangle corner
200 * \param theState - required state
201 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
203 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
204 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
205 const Standard_Integer theShapeType,
206 const Handle(GEOM_Object)& theTopLeftPoint,
207 const Handle(GEOM_Object)& theTopRigthPoint,
208 const Handle(GEOM_Object)& theBottomLeftPoint,
209 const Handle(GEOM_Object)& theBottomRigthPoint,
210 const GEOMAlgo_State theState);
213 * \brief Find IDs of subshapes complying with given status about quadrangle
214 * \param theShape - the shape to explore
215 * \param theShapeType - type of subshape of theShape
216 * \param theTopLeftPoint - top left quadrangle corner
217 * \param theTopRigthPoint - top right quadrangle corner
218 * \param theBottomLeftPoint - bottom left quadrangle corner
219 * \param theBottomRigthPoint - bottom right quadrangle corner
220 * \param theState - required state
221 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
223 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
224 GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
225 const Standard_Integer theShapeType,
226 const Handle(GEOM_Object)& theTopLeftPoint,
227 const Handle(GEOM_Object)& theTopRigthPoint,
228 const Handle(GEOM_Object)& theBottomLeftPoint,
229 const Handle(GEOM_Object)& theBottomRigthPoint,
230 const GEOMAlgo_State theState);
232 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
233 const Standard_Integer theShapeType,
234 Handle(GEOM_Object) theAxis,
235 const Standard_Real theRadius);
237 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
238 const Standard_Integer theShapeType,
239 Handle(GEOM_Object) theCenter,
240 const Standard_Real theRadius);
242 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
244 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
245 Handle(GEOM_Object) theShapeWhat);
247 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
248 Handle(GEOM_Object) theShapeWhat);
251 * \brief Searches a shape equal to theWhat in the context of theWhere
252 * \param theShapeWhere - a context shap
253 * \param theShapeWhat - a sample shape
254 * \retval Handle(GEOM_Object) - found shape
256 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
257 const Handle(GEOM_Object)& theShapeWhat);
260 * \brief Find IDs of subshapes complying with given status about surface
261 * \param theBox - the box to check state of subshapes against
262 * \param theShape - the shape to explore
263 * \param theShapeType - type of subshape of theShape
264 * \param theState - required state
265 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
267 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
268 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
269 const Handle(GEOM_Object)& theShape,
270 const Standard_Integer theShapeType,
271 GEOMAlgo_State theState);
274 * \brief Find subshapes complying with given status about surface
275 * \param theBox - the box to check state of subshapes against
276 * \param theShape - the shape to explore
277 * \param theShapeType - type of subshape of theShape
278 * \param theState - required state
279 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
281 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
282 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
283 const Handle(GEOM_Object)& theShape,
284 const Standard_Integer theShapeType,
285 GEOMAlgo_State theState);
288 * \brief Find IDs of subshapes complying with given status about surface
289 * \param theCheckShape - the shape to check state of subshapes against
290 * \param theShape - the shape to explore
291 * \param theShapeType - type of subshape of theShape
292 * \param theState - required state
293 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
295 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
296 GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
297 const Handle(GEOM_Object)& theShape,
298 const Standard_Integer theShapeType,
299 GEOMAlgo_State theState);
302 * \brief Find subshapes complying with given status about surface
303 * \param theCheckShape - the shape to check state of subshapes against
304 * \param theShape - the shape to explore
305 * \param theShapeType - type of subshape of theShape
306 * \param theState - required state
307 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
309 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
310 GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
311 const Handle(GEOM_Object)& theShape,
312 const Standard_Integer theShapeType,
313 GEOMAlgo_State theState);
314 Standard_EXPORT Handle(GEOM_Object)
315 GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
316 const Handle(GEOM_Object)& theShape,
317 const Standard_Integer theShapeType,
318 GEOMAlgo_State theState);
322 * \brief Sort shapes in the list by their coordinates.
323 * \param SL The list of shapes to sort.
325 Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
328 * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
330 * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
332 * \param theCompsolid The compsolid to be converted.
333 * \retval TopoDS_Shape Returns the resulting compound.
335 Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
338 * \brief Build a triangulation on \a theShape if it is absent.
339 * \param theShape The shape to check/build triangulation on.
340 * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
342 Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
345 Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
346 const Standard_Integer theObjectType,
347 const Standard_Integer theFunctionType,
348 const TCollection_AsciiString& theMethodName);
350 // ----------------------------------------------------
351 // methods common for all GetShapesOnXXX() functions
352 // ----------------------------------------------------
355 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
356 * \param theShapeType - the shape type to check
357 * \retval bool - result of the check
359 bool checkTypeShapesOn(const Standard_Integer theShapeType);
362 * \brief Creates Geom_Plane
363 * \param theAx1 - edge defining plane normal
364 * \retval Handle(Geom_Surface) - resulting surface
366 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
369 * \brief Creates Geom_CylindricalSurface
370 * \param theAx1 - edge defining cylinder axis
371 * \param theRadius - cylinder radius
372 * \retval Handle(Geom_Surface) - resulting surface
374 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
375 const Standard_Real theRadius);
378 * \brief Find IDs of subshapes complying with given status about surface
379 * \param theSurface - the surface to check state of subshapes against
380 * \param theShape - the shape to explore
381 * \param theShapeType - type of subshape of theShape
382 * \param theState - required state
383 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
385 Handle(TColStd_HSequenceOfInteger)
386 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
387 const TopoDS_Shape& theShape,
388 TopAbs_ShapeEnum theShapeType,
389 GEOMAlgo_State theState);
392 * \brief Find subshapes complying with given status about surface
393 * \param theSurface - the surface to check state of subshapes against
394 * \param theShape - the shape to explore
395 * \param theShapeType - type of subshape of theShape
396 * \param theState - required state
397 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
398 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
400 Handle(TColStd_HSequenceOfTransient)
401 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
402 const Handle(GEOM_Object)& theShape,
403 TopAbs_ShapeEnum theShapeType,
404 GEOMAlgo_State theState,
405 TCollection_AsciiString & theShapeEntries);
408 * \brief Find IDs of subshapes complying with given status about quadrangle
409 * \param theShape - the shape to explore
410 * \param theShapeType - type of subshape of theShape
411 * \param theTopLeftPoint - top left quadrangle corner
412 * \param theTopRigthPoint - top right quadrangle corner
413 * \param theBottomLeftPoint - bottom left quadrangle corner
414 * \param theBottomRigthPoint - bottom right quadrangle corner
415 * \param theState - required state
416 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
418 Handle(TColStd_HSequenceOfInteger)
419 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
420 const Standard_Integer theShapeType,
421 const Handle(GEOM_Object)& theTopLeftPoint,
422 const Handle(GEOM_Object)& theTopRigthPoint,
423 const Handle(GEOM_Object)& theBottomLeftPoint,
424 const Handle(GEOM_Object)& theBottomRigthPoint,
425 const GEOMAlgo_State theState);
428 * \brief Find IDs of subshapes complying with given status about surface
429 * \param theBox - the box to check state of subshapes against
430 * \param theShape - the shape to explore
431 * \param theShapeType - type of subshape of theShape
432 * \param theState - required state
433 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
435 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
436 const Handle(GEOM_Object)& theShape,
437 const Standard_Integer theShapeType,
438 GEOMAlgo_State theState);
441 * \brief Find IDs of subshapes complying with given status about surface
442 * \param theCheckShape - the shape to check state of subshapes against
443 * \param theShape - the shape to explore
444 * \param theShapeType - type of subshape of theShape
445 * \param theState - required state
446 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
448 Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
449 (const Handle(GEOM_Object)& theCheckShape,
450 const Handle(GEOM_Object)& theShape,
451 const Standard_Integer theShapeType,
452 GEOMAlgo_State theState);
455 * \brief Find shape objects and their entries by their ids
456 * \param theShape - the main shape
457 * \param theShapeIDs - theShapeIDs - incoming shape ids
458 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
459 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
461 Handle(TColStd_HSequenceOfTransient)
462 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
463 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
464 TCollection_AsciiString & theShapeEntries);
467 * \brief Select the object created last
468 * \param theObj1 - Object 1
469 * \param theObj2 - Object 2
470 * \retval Handle(GEOM_Object) - selected object
472 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
473 const Handle(GEOM_Object)& theObj2);