1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //=============================================================================
21 // File : GEOMImpl_IShapesOperations.hxx
23 // Author : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007
25 // Copyright : CEA 2003
27 //=============================================================================
28 #ifndef _GEOMImpl_IShapesOperations_HXX_
29 #define _GEOMImpl_IShapesOperations_HXX_
33 #include "GEOM_IOperations.hxx"
35 #include "GEOMAlgo_State.hxx"
37 #include <TopTools_ListOfShape.hxx>
38 #include <TColStd_HSequenceOfTransient.hxx>
39 #include <TColStd_HSequenceOfInteger.hxx>
42 #include <Handle_Geom_Surface.hxx>
47 class Handle(GEOM_Object);
48 class Handle(TColStd_HArray1OfInteger);
50 class GEOMImpl_IShapesOperations : public GEOM_IOperations
53 Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
54 Standard_EXPORT ~GEOMImpl_IShapesOperations();
56 Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
57 Handle(GEOM_Object) thePoint2);
59 Standard_EXPORT Handle(GEOM_Object) MakeWire (list<Handle(GEOM_Object)> theEdgesAndWires);
61 Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
63 Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (list<Handle(GEOM_Object)> theWires,
64 const bool isPlanarWanted);
66 Standard_EXPORT Handle(GEOM_Object) MakeShell (list<Handle(GEOM_Object)> theShapes);
68 Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell);
70 Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (list<Handle(GEOM_Object)> theShells);
72 Standard_EXPORT Handle(GEOM_Object) MakeCompound (list<Handle(GEOM_Object)> theShapes);
74 Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
75 const Standard_Real theTolerance,
76 const Standard_Boolean doKeepNonSolids);
78 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
79 const Standard_Real theTolerance);
81 Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
82 const Standard_Real theTolerance,
83 list<Handle(GEOM_Object)> theFaces,
84 const Standard_Boolean doKeepNonSolids);
86 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object) theShape,
87 const Standard_Integer theShapeType,
88 const Standard_Boolean isSorted);
90 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object) theShape,
91 const Standard_Integer theShapeType,
92 const Standard_Boolean isSorted);
94 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
95 const Standard_Integer theID);
97 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
98 Handle(GEOM_Object) theSubShape);
100 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
101 Handle(GEOM_Object) theSubShape);
103 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
105 Standard_EXPORT Standard_Integer NumberOfFaces (Handle(GEOM_Object) theShape);
106 Standard_EXPORT Standard_Integer NumberOfEdges (Handle(GEOM_Object) theShape);
108 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
110 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
112 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object) theShape1,
113 Handle(GEOM_Object) theShape2,
114 const Standard_Integer theShapeType);
116 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
117 const Standard_Integer theShapeType,
118 const Handle(GEOM_Object)& theAx1,
119 const GEOMAlgo_State theState);
121 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
122 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
123 const Standard_Integer theShapeType,
124 const Handle(GEOM_Object)& theAx1,
125 const Handle(GEOM_Object)& thePnt,
126 const GEOMAlgo_State theState);
129 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
130 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
131 const Standard_Integer theShapeType,
132 const Handle(GEOM_Object)& theAxis,
133 const Standard_Real theRadius,
134 const GEOMAlgo_State theState);
136 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
137 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
138 const Standard_Integer theShapeType,
139 const Handle(GEOM_Object)& theCenter,
140 const Standard_Real theRadius,
141 const GEOMAlgo_State theState);
143 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
144 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
145 const Standard_Integer theShapeType,
146 const Handle(GEOM_Object)& theAx1,
147 const GEOMAlgo_State theState);
149 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
150 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
151 const Standard_Integer theShapeType,
152 const Handle(GEOM_Object)& theAx1,
153 const Handle(GEOM_Object)& thePnt,
154 const GEOMAlgo_State theState);
156 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
157 GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
158 const Standard_Integer theShapeType,
159 const Handle(GEOM_Object)& theAxis,
160 const Standard_Real theRadius,
161 const GEOMAlgo_State theState);
163 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
164 GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
165 const Standard_Integer theShapeType,
166 const Handle(GEOM_Object)& theCenter,
167 const Standard_Real theRadius,
168 const GEOMAlgo_State theState);
171 * \brief Find subshapes complying with given status about quadrangle
172 * \param theShape - the shape to explore
173 * \param theShapeType - type of subshape of theShape
174 * \param theTopLeftPoint - top left quadrangle corner
175 * \param theTopRigthPoint - top right quadrangle corner
176 * \param theBottomLeftPoint - bottom left quadrangle corner
177 * \param theBottomRigthPoint - bottom right quadrangle corner
178 * \param theState - required state
179 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
181 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
182 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
183 const Standard_Integer theShapeType,
184 const Handle(GEOM_Object)& theTopLeftPoint,
185 const Handle(GEOM_Object)& theTopRigthPoint,
186 const Handle(GEOM_Object)& theBottomLeftPoint,
187 const Handle(GEOM_Object)& theBottomRigthPoint,
188 const GEOMAlgo_State theState);
191 * \brief Find IDs of subshapes complying with given status about quadrangle
192 * \param theShape - the shape to explore
193 * \param theShapeType - type of subshape of theShape
194 * \param theTopLeftPoint - top left quadrangle corner
195 * \param theTopRigthPoint - top right quadrangle corner
196 * \param theBottomLeftPoint - bottom left quadrangle corner
197 * \param theBottomRigthPoint - bottom right quadrangle corner
198 * \param theState - required state
199 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
201 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
202 GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
203 const Standard_Integer theShapeType,
204 const Handle(GEOM_Object)& theTopLeftPoint,
205 const Handle(GEOM_Object)& theTopRigthPoint,
206 const Handle(GEOM_Object)& theBottomLeftPoint,
207 const Handle(GEOM_Object)& theBottomRigthPoint,
208 const GEOMAlgo_State theState);
210 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
211 const Standard_Integer theShapeType,
212 Handle(GEOM_Object) theAxis,
213 const Standard_Real theRadius);
215 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
216 const Standard_Integer theShapeType,
217 Handle(GEOM_Object) theCenter,
218 const Standard_Real theRadius);
220 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
222 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
223 Handle(GEOM_Object) theShapeWhat);
225 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
226 Handle(GEOM_Object) theShapeWhat);
229 * \brief Searches a shape equal to theWhat in the context of theWhere
230 * \param theShapeWhere - a context shap
231 * \param theShapeWhat - a sample shape
232 * \retval Handle(GEOM_Object) - found shape
234 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
235 const Handle(GEOM_Object)& theShapeWhat);
238 * \brief Find IDs of subshapes complying with given status about surface
239 * \param theBox - the box to check state of subshapes against
240 * \param theShape - the shape to explore
241 * \param theShapeType - type of subshape of theShape
242 * \param theState - required state
243 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
245 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
246 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
247 const Handle(GEOM_Object)& theShape,
248 const Standard_Integer theShapeType,
249 GEOMAlgo_State theState);
252 * \brief Find subshapes complying with given status about surface
253 * \param theBox - the box to check state of subshapes against
254 * \param theShape - the shape to explore
255 * \param theShapeType - type of subshape of theShape
256 * \param theState - required state
257 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
259 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
260 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
261 const Handle(GEOM_Object)& theShape,
262 const Standard_Integer theShapeType,
263 GEOMAlgo_State theState);
267 * \brief Sort shapes in the list by their coordinates.
268 * \param SL The list of shapes to sort.
270 Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
273 * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
275 * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
277 * \param theCompsolid The compsolid to be converted.
278 * \retval TopoDS_Shape Returns the resulting compound.
280 Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
283 * \brief Build a triangulation on \a theShape if it is absent.
284 * \param theShape The shape to check/build triangulation on.
285 * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
287 Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
290 Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)> theShapes,
291 const Standard_Integer theObjectType,
292 const Standard_Integer theFunctionType,
293 const TCollection_AsciiString& theMethodName);
295 // ----------------------------------------------------
296 // methods common for all GetShapesOnXXX() functions
297 // ----------------------------------------------------
300 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
301 * \param theShapeType - the shape type to check
302 * \retval bool - result of the check
304 bool checkTypeShapesOn(const Standard_Integer theShapeType);
307 * \brief Creates Geom_Plane
308 * \param theAx1 - edge defining plane normal
309 * \retval Handle(Geom_Surface) - resulting surface
311 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
314 * \brief Creates Geom_CylindricalSurface
315 * \param theAx1 - edge defining cylinder axis
316 * \param theRadius - cylinder radius
317 * \retval Handle(Geom_Surface) - resulting surface
319 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
320 const Standard_Real theRadius);
323 * \brief Find IDs of subshapes complying with given status about surface
324 * \param theSurface - the surface to check state of subshapes against
325 * \param theShape - the shape to explore
326 * \param theShapeType - type of subshape of theShape
327 * \param theState - required state
328 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
330 Handle(TColStd_HSequenceOfInteger)
331 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
332 const TopoDS_Shape& theShape,
333 TopAbs_ShapeEnum theShapeType,
334 GEOMAlgo_State theState);
337 * \brief Find subshapes complying with given status about surface
338 * \param theSurface - the surface to check state of subshapes against
339 * \param theShape - the shape to explore
340 * \param theShapeType - type of subshape of theShape
341 * \param theState - required state
342 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
343 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
345 Handle(TColStd_HSequenceOfTransient)
346 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
347 const Handle(GEOM_Object)& theShape,
348 TopAbs_ShapeEnum theShapeType,
349 GEOMAlgo_State theState,
350 TCollection_AsciiString & theShapeEntries);
353 * \brief Find IDs of subshapes complying with given status about quadrangle
354 * \param theShape - the shape to explore
355 * \param theShapeType - type of subshape of theShape
356 * \param theTopLeftPoint - top left quadrangle corner
357 * \param theTopRigthPoint - top right quadrangle corner
358 * \param theBottomLeftPoint - bottom left quadrangle corner
359 * \param theBottomRigthPoint - bottom right quadrangle corner
360 * \param theState - required state
361 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
363 Handle(TColStd_HSequenceOfInteger)
364 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
365 const Standard_Integer theShapeType,
366 const Handle(GEOM_Object)& theTopLeftPoint,
367 const Handle(GEOM_Object)& theTopRigthPoint,
368 const Handle(GEOM_Object)& theBottomLeftPoint,
369 const Handle(GEOM_Object)& theBottomRigthPoint,
370 const GEOMAlgo_State theState);
373 * \brief Find IDs of subshapes complying with given status about surface
374 * \param theBox - the box to check state of subshapes against
375 * \param theShape - the shape to explore
376 * \param theShapeType - type of subshape of theShape
377 * \param theState - required state
378 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
380 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
381 const Handle(GEOM_Object)& theShape,
382 const Standard_Integer theShapeType,
383 GEOMAlgo_State theState);
386 * \brief Find shape objects and their entries by their ids
387 * \param theShape - the main shape
388 * \param theShapeIDs - theShapeIDs - incoming shape ids
389 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
390 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
392 Handle(TColStd_HSequenceOfTransient)
393 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
394 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
395 TCollection_AsciiString & theShapeEntries);
398 * \brief Select the object created last
399 * \param theObj1 - Object 1
400 * \param theObj2 - Object 2
401 * \retval Handle(GEOM_Object) - selected object
403 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
404 const Handle(GEOM_Object)& theObj2);