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) MakeExplode (Handle(GEOM_Object) theShape,
89 const Standard_Integer theShapeType,
90 const Standard_Boolean isSorted);
92 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object) theShape,
93 const Standard_Integer theShapeType,
94 const Standard_Boolean isSorted);
96 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
97 const Standard_Integer theID);
99 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
100 Handle(GEOM_Object) theSubShape);
102 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
103 Handle(GEOM_Object) theSubShape);
105 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
107 Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
108 const Standard_Integer theShapeType);
110 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
112 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
114 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object) theShape1,
115 Handle(GEOM_Object) theShape2,
116 const Standard_Integer theShapeType);
118 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
119 const Standard_Integer theShapeType,
120 const Handle(GEOM_Object)& theAx1,
121 const GEOMAlgo_State theState);
123 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
124 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
125 const Standard_Integer theShapeType,
126 const Handle(GEOM_Object)& theAx1,
127 const Handle(GEOM_Object)& thePnt,
128 const GEOMAlgo_State theState);
131 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
132 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
133 const Standard_Integer theShapeType,
134 const Handle(GEOM_Object)& theAxis,
135 const Standard_Real theRadius,
136 const GEOMAlgo_State theState);
138 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
139 GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
140 const Standard_Integer theShapeType,
141 const Handle(GEOM_Object)& theAxis,
142 const Handle(GEOM_Object)& thePnt,
143 const Standard_Real theRadius,
144 const GEOMAlgo_State theState);
146 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
147 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
148 const Standard_Integer theShapeType,
149 const Handle(GEOM_Object)& theCenter,
150 const Standard_Real theRadius,
151 const GEOMAlgo_State theState);
153 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
154 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
155 const Standard_Integer theShapeType,
156 const Handle(GEOM_Object)& theAx1,
157 const GEOMAlgo_State theState);
159 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
160 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
161 const Standard_Integer theShapeType,
162 const Handle(GEOM_Object)& theAx1,
163 const Handle(GEOM_Object)& thePnt,
164 const GEOMAlgo_State theState);
166 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
167 GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
168 const Standard_Integer theShapeType,
169 const Handle(GEOM_Object)& theAxis,
170 const Standard_Real theRadius,
171 const GEOMAlgo_State theState);
173 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
174 GetShapesOnCylinderWithLocationIDs (const Handle(GEOM_Object)& theShape,
175 const Standard_Integer theShapeType,
176 const Handle(GEOM_Object)& theAxis,
177 const Handle(GEOM_Object)& thePnt,
178 const Standard_Real theRadius,
179 const GEOMAlgo_State theState);
181 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
182 GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
183 const Standard_Integer theShapeType,
184 const Handle(GEOM_Object)& theCenter,
185 const Standard_Real theRadius,
186 const GEOMAlgo_State theState);
189 * \brief Find subshapes complying with given status about quadrangle
190 * \param theShape - the shape to explore
191 * \param theShapeType - type of subshape of theShape
192 * \param theTopLeftPoint - top left quadrangle corner
193 * \param theTopRigthPoint - top right quadrangle corner
194 * \param theBottomLeftPoint - bottom left quadrangle corner
195 * \param theBottomRigthPoint - bottom right quadrangle corner
196 * \param theState - required state
197 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
199 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
200 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
201 const Standard_Integer theShapeType,
202 const Handle(GEOM_Object)& theTopLeftPoint,
203 const Handle(GEOM_Object)& theTopRigthPoint,
204 const Handle(GEOM_Object)& theBottomLeftPoint,
205 const Handle(GEOM_Object)& theBottomRigthPoint,
206 const GEOMAlgo_State theState);
209 * \brief Find IDs of subshapes complying with given status about quadrangle
210 * \param theShape - the shape to explore
211 * \param theShapeType - type of subshape of theShape
212 * \param theTopLeftPoint - top left quadrangle corner
213 * \param theTopRigthPoint - top right quadrangle corner
214 * \param theBottomLeftPoint - bottom left quadrangle corner
215 * \param theBottomRigthPoint - bottom right quadrangle corner
216 * \param theState - required state
217 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
219 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
220 GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
221 const Standard_Integer theShapeType,
222 const Handle(GEOM_Object)& theTopLeftPoint,
223 const Handle(GEOM_Object)& theTopRigthPoint,
224 const Handle(GEOM_Object)& theBottomLeftPoint,
225 const Handle(GEOM_Object)& theBottomRigthPoint,
226 const GEOMAlgo_State theState);
228 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
229 const Standard_Integer theShapeType,
230 Handle(GEOM_Object) theAxis,
231 const Standard_Real theRadius);
233 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
234 const Standard_Integer theShapeType,
235 Handle(GEOM_Object) theCenter,
236 const Standard_Real theRadius);
238 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
240 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
241 Handle(GEOM_Object) theShapeWhat);
243 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
244 Handle(GEOM_Object) theShapeWhat);
247 * \brief Searches a shape equal to theWhat in the context of theWhere
248 * \param theShapeWhere - a context shap
249 * \param theShapeWhat - a sample shape
250 * \retval Handle(GEOM_Object) - found shape
252 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
253 const Handle(GEOM_Object)& theShapeWhat);
256 * \brief Find IDs of subshapes complying with given status about surface
257 * \param theBox - the box to check state of subshapes against
258 * \param theShape - the shape to explore
259 * \param theShapeType - type of subshape of theShape
260 * \param theState - required state
261 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
263 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
264 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
265 const Handle(GEOM_Object)& theShape,
266 const Standard_Integer theShapeType,
267 GEOMAlgo_State theState);
270 * \brief Find subshapes complying with given status about surface
271 * \param theBox - the box to check state of subshapes against
272 * \param theShape - the shape to explore
273 * \param theShapeType - type of subshape of theShape
274 * \param theState - required state
275 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
277 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
278 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
279 const Handle(GEOM_Object)& theShape,
280 const Standard_Integer theShapeType,
281 GEOMAlgo_State theState);
284 * \brief Find IDs of subshapes complying with given status about surface
285 * \param theCheckShape - the shape to check state of subshapes against
286 * \param theShape - the shape to explore
287 * \param theShapeType - type of subshape of theShape
288 * \param theState - required state
289 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
291 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
292 GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
293 const Handle(GEOM_Object)& theShape,
294 const Standard_Integer theShapeType,
295 GEOMAlgo_State theState);
298 * \brief Find subshapes complying with given status about surface
299 * \param theCheckShape - the shape to check state of subshapes against
300 * \param theShape - the shape to explore
301 * \param theShapeType - type of subshape of theShape
302 * \param theState - required state
303 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
305 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
306 GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
307 const Handle(GEOM_Object)& theShape,
308 const Standard_Integer theShapeType,
309 GEOMAlgo_State theState);
310 Standard_EXPORT Handle(GEOM_Object)
311 GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
312 const Handle(GEOM_Object)& theShape,
313 const Standard_Integer theShapeType,
314 GEOMAlgo_State theState);
318 * \brief Sort shapes in the list by their coordinates.
319 * \param SL The list of shapes to sort.
321 Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
324 * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
326 * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
328 * \param theCompsolid The compsolid to be converted.
329 * \retval TopoDS_Shape Returns the resulting compound.
331 Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
334 * \brief Build a triangulation on \a theShape if it is absent.
335 * \param theShape The shape to check/build triangulation on.
336 * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
338 Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
341 Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
342 const Standard_Integer theObjectType,
343 const Standard_Integer theFunctionType,
344 const TCollection_AsciiString& theMethodName);
346 // ----------------------------------------------------
347 // methods common for all GetShapesOnXXX() functions
348 // ----------------------------------------------------
351 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
352 * \param theShapeType - the shape type to check
353 * \retval bool - result of the check
355 bool checkTypeShapesOn(const Standard_Integer theShapeType);
358 * \brief Creates Geom_Plane
359 * \param theAx1 - edge defining plane normal
360 * \retval Handle(Geom_Surface) - resulting surface
362 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
365 * \brief Creates Geom_CylindricalSurface
366 * \param theAx1 - edge defining cylinder axis
367 * \param theRadius - cylinder radius
368 * \retval Handle(Geom_Surface) - resulting surface
370 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
371 const Standard_Real theRadius);
374 * \brief Find IDs of subshapes complying with given status about surface
375 * \param theSurface - the surface to check state of subshapes against
376 * \param theShape - the shape to explore
377 * \param theShapeType - type of subshape of theShape
378 * \param theState - required state
379 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
381 Handle(TColStd_HSequenceOfInteger)
382 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
383 const TopoDS_Shape& theShape,
384 TopAbs_ShapeEnum theShapeType,
385 GEOMAlgo_State theState);
388 * \brief Find subshapes complying with given status about surface
389 * \param theSurface - the surface to check state of subshapes against
390 * \param theShape - the shape to explore
391 * \param theShapeType - type of subshape of theShape
392 * \param theState - required state
393 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
394 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
396 Handle(TColStd_HSequenceOfTransient)
397 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
398 const Handle(GEOM_Object)& theShape,
399 TopAbs_ShapeEnum theShapeType,
400 GEOMAlgo_State theState,
401 TCollection_AsciiString & theShapeEntries);
404 * \brief Find IDs of subshapes complying with given status about quadrangle
405 * \param theShape - the shape to explore
406 * \param theShapeType - type of subshape of theShape
407 * \param theTopLeftPoint - top left quadrangle corner
408 * \param theTopRigthPoint - top right quadrangle corner
409 * \param theBottomLeftPoint - bottom left quadrangle corner
410 * \param theBottomRigthPoint - bottom right quadrangle corner
411 * \param theState - required state
412 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
414 Handle(TColStd_HSequenceOfInteger)
415 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
416 const Standard_Integer theShapeType,
417 const Handle(GEOM_Object)& theTopLeftPoint,
418 const Handle(GEOM_Object)& theTopRigthPoint,
419 const Handle(GEOM_Object)& theBottomLeftPoint,
420 const Handle(GEOM_Object)& theBottomRigthPoint,
421 const GEOMAlgo_State theState);
424 * \brief Find IDs of subshapes complying with given status about surface
425 * \param theBox - the box to check state of subshapes against
426 * \param theShape - the shape to explore
427 * \param theShapeType - type of subshape of theShape
428 * \param theState - required state
429 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
431 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
432 const Handle(GEOM_Object)& theShape,
433 const Standard_Integer theShapeType,
434 GEOMAlgo_State theState);
437 * \brief Find IDs of subshapes complying with given status about surface
438 * \param theCheckShape - the shape to check state of subshapes against
439 * \param theShape - the shape to explore
440 * \param theShapeType - type of subshape of theShape
441 * \param theState - required state
442 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
444 Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
445 (const Handle(GEOM_Object)& theCheckShape,
446 const Handle(GEOM_Object)& theShape,
447 const Standard_Integer theShapeType,
448 GEOMAlgo_State theState);
451 * \brief Find shape objects and their entries by their ids
452 * \param theShape - the main shape
453 * \param theShapeIDs - theShapeIDs - incoming shape ids
454 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
455 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
457 Handle(TColStd_HSequenceOfTransient)
458 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
459 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
460 TCollection_AsciiString & theShapeEntries);
463 * \brief Select the object created last
464 * \param theObj1 - Object 1
465 * \param theObj2 - Object 2
466 * \retval Handle(GEOM_Object) - selected object
468 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
469 const Handle(GEOM_Object)& theObj2);