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_
31 #include "GEOM_IOperations.hxx"
33 #include "GEOMAlgo_State.hxx"
35 #include <TopTools_ListOfShape.hxx>
36 #include <TColStd_HSequenceOfTransient.hxx>
37 #include <TColStd_HSequenceOfInteger.hxx>
40 #include <Handle_Geom_Surface.hxx>
45 class Handle(GEOM_Object);
46 class Handle(TColStd_HArray1OfInteger);
48 class GEOMImpl_IShapesOperations : public GEOM_IOperations
51 Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
52 Standard_EXPORT ~GEOMImpl_IShapesOperations();
54 Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
55 Handle(GEOM_Object) thePoint2);
57 Standard_EXPORT Handle(GEOM_Object) MakeWire (list<Handle(GEOM_Object)> theEdgesAndWires);
59 Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
61 Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (list<Handle(GEOM_Object)> theWires,
62 const bool isPlanarWanted);
64 Standard_EXPORT Handle(GEOM_Object) MakeShell (list<Handle(GEOM_Object)> theShapes);
66 Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell);
68 Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (list<Handle(GEOM_Object)> theShells);
70 Standard_EXPORT Handle(GEOM_Object) MakeCompound (list<Handle(GEOM_Object)> theShapes);
72 Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
73 const Standard_Real theTolerance,
74 const Standard_Boolean doKeepNonSolids);
76 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
77 const Standard_Real theTolerance);
79 Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
80 const Standard_Real theTolerance,
81 list<Handle(GEOM_Object)> theFaces,
82 const Standard_Boolean doKeepNonSolids);
84 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object) theShape,
85 const Standard_Integer theShapeType,
86 const Standard_Boolean isSorted);
88 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object) theShape,
89 const Standard_Integer theShapeType,
90 const Standard_Boolean isSorted);
92 Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape,
93 const Standard_Integer theID);
95 Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
96 Handle(GEOM_Object) theSubShape);
98 Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
99 Handle(GEOM_Object) theSubShape);
101 Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
103 Standard_EXPORT Standard_Integer NumberOfFaces (Handle(GEOM_Object) theShape);
104 Standard_EXPORT Standard_Integer NumberOfEdges (Handle(GEOM_Object) theShape);
106 Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
108 Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
110 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object) theShape1,
111 Handle(GEOM_Object) theShape2,
112 const Standard_Integer theShapeType);
114 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
115 const Standard_Integer theShapeType,
116 const Handle(GEOM_Object)& theAx1,
117 const GEOMAlgo_State theState);
119 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
120 GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
121 const Standard_Integer theShapeType,
122 const Handle(GEOM_Object)& theAx1,
123 const Handle(GEOM_Object)& thePnt,
124 const GEOMAlgo_State theState);
127 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
128 GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
129 const Standard_Integer theShapeType,
130 const Handle(GEOM_Object)& theAxis,
131 const Standard_Real theRadius,
132 const GEOMAlgo_State theState);
134 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
135 GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
136 const Standard_Integer theShapeType,
137 const Handle(GEOM_Object)& theCenter,
138 const Standard_Real theRadius,
139 const GEOMAlgo_State theState);
141 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
142 GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
143 const Standard_Integer theShapeType,
144 const Handle(GEOM_Object)& theAx1,
145 const GEOMAlgo_State theState);
147 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
148 GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
149 const Standard_Integer theShapeType,
150 const Handle(GEOM_Object)& theAx1,
151 const Handle(GEOM_Object)& thePnt,
152 const GEOMAlgo_State theState);
154 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
155 GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
156 const Standard_Integer theShapeType,
157 const Handle(GEOM_Object)& theAxis,
158 const Standard_Real theRadius,
159 const GEOMAlgo_State theState);
161 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
162 GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
163 const Standard_Integer theShapeType,
164 const Handle(GEOM_Object)& theCenter,
165 const Standard_Real theRadius,
166 const GEOMAlgo_State theState);
169 * \brief Find subshapes complying with given status about quadrangle
170 * \param theShape - the shape to explore
171 * \param theShapeType - type of subshape of theShape
172 * \param theTopLeftPoint - top left quadrangle corner
173 * \param theTopRigthPoint - top right quadrangle corner
174 * \param theBottomLeftPoint - bottom left quadrangle corner
175 * \param theBottomRigthPoint - bottom right quadrangle corner
176 * \param theState - required state
177 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
179 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
180 GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
181 const Standard_Integer theShapeType,
182 const Handle(GEOM_Object)& theTopLeftPoint,
183 const Handle(GEOM_Object)& theTopRigthPoint,
184 const Handle(GEOM_Object)& theBottomLeftPoint,
185 const Handle(GEOM_Object)& theBottomRigthPoint,
186 const GEOMAlgo_State theState);
189 * \brief Find IDs of 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_HSequenceOfInteger)
200 GetShapesOnQuadrangleIDs (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);
208 Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
209 const Standard_Integer theShapeType,
210 Handle(GEOM_Object) theAxis,
211 const Standard_Real theRadius);
213 Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
214 const Standard_Integer theShapeType,
215 Handle(GEOM_Object) theCenter,
216 const Standard_Real theRadius);
218 void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
220 Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
221 Handle(GEOM_Object) theShapeWhat);
223 Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
224 Handle(GEOM_Object) theShapeWhat);
227 * \brief Searches a shape equal to theWhat in the context of theWhere
228 * \param theShapeWhere - a context shap
229 * \param theShapeWhat - a sample shape
230 * \retval Handle(GEOM_Object) - found shape
232 Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
233 const Handle(GEOM_Object)& theShapeWhat);
236 * \brief Find IDs of subshapes complying with given status about surface
237 * \param theBox - the box to check state of subshapes against
238 * \param theShape - the shape to explore
239 * \param theShapeType - type of subshape of theShape
240 * \param theState - required state
241 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
243 Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
244 GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
245 const Handle(GEOM_Object)& theShape,
246 const Standard_Integer theShapeType,
247 GEOMAlgo_State theState);
250 * \brief Find subshapes complying with given status about surface
251 * \param theBox - the box to check state of subshapes against
252 * \param theShape - the shape to explore
253 * \param theShapeType - type of subshape of theShape
254 * \param theState - required state
255 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
257 Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
258 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
259 const Handle(GEOM_Object)& theShape,
260 const Standard_Integer theShapeType,
261 GEOMAlgo_State theState);
265 * \brief Sort shapes in the list by their coordinates.
266 * \param SL The list of shapes to sort.
268 Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
271 * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
273 * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
275 * \param theCompsolid The compsolid to be converted.
276 * \retval TopoDS_Shape Returns the resulting compound.
278 Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
281 * \brief Build a triangulation on \a theShape if it is absent.
282 * \param theShape The shape to check/build triangulation on.
283 * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
285 Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
288 Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)> theShapes,
289 const Standard_Integer theObjectType,
290 const Standard_Integer theFunctionType,
291 const TCollection_AsciiString& theMethodName);
293 // ----------------------------------------------------
294 // methods common for all GetShapesOnXXX() functions
295 // ----------------------------------------------------
298 * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
299 * \param theShapeType - the shape type to check
300 * \retval bool - result of the check
302 bool checkTypeShapesOn(const Standard_Integer theShapeType);
305 * \brief Creates Geom_Plane
306 * \param theAx1 - edge defining plane normal
307 * \retval Handle(Geom_Surface) - resulting surface
309 Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
312 * \brief Creates Geom_CylindricalSurface
313 * \param theAx1 - edge defining cylinder axis
314 * \param theRadius - cylinder radius
315 * \retval Handle(Geom_Surface) - resulting surface
317 Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
318 const Standard_Real theRadius);
321 * \brief Find IDs of subshapes complying with given status about surface
322 * \param theSurface - the surface to check state of subshapes against
323 * \param theShape - the shape to explore
324 * \param theShapeType - type of subshape of theShape
325 * \param theState - required state
326 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
328 Handle(TColStd_HSequenceOfInteger)
329 getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
330 const TopoDS_Shape& theShape,
331 TopAbs_ShapeEnum theShapeType,
332 GEOMAlgo_State theState);
335 * \brief Find subshapes complying with given status about surface
336 * \param theSurface - the surface to check state of subshapes against
337 * \param theShape - the shape to explore
338 * \param theShapeType - type of subshape of theShape
339 * \param theState - required state
340 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
341 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
343 Handle(TColStd_HSequenceOfTransient)
344 getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
345 const Handle(GEOM_Object)& theShape,
346 TopAbs_ShapeEnum theShapeType,
347 GEOMAlgo_State theState,
348 TCollection_AsciiString & theShapeEntries);
351 * \brief Find IDs of subshapes complying with given status about quadrangle
352 * \param theShape - the shape to explore
353 * \param theShapeType - type of subshape of theShape
354 * \param theTopLeftPoint - top left quadrangle corner
355 * \param theTopRigthPoint - top right quadrangle corner
356 * \param theBottomLeftPoint - bottom left quadrangle corner
357 * \param theBottomRigthPoint - bottom right quadrangle corner
358 * \param theState - required state
359 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
361 Handle(TColStd_HSequenceOfInteger)
362 getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
363 const Standard_Integer theShapeType,
364 const Handle(GEOM_Object)& theTopLeftPoint,
365 const Handle(GEOM_Object)& theTopRigthPoint,
366 const Handle(GEOM_Object)& theBottomLeftPoint,
367 const Handle(GEOM_Object)& theBottomRigthPoint,
368 const GEOMAlgo_State theState);
371 * \brief Find IDs of subshapes complying with given status about surface
372 * \param theBox - the box to check state of subshapes against
373 * \param theShape - the shape to explore
374 * \param theShapeType - type of subshape of theShape
375 * \param theState - required state
376 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
378 Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
379 const Handle(GEOM_Object)& theShape,
380 const Standard_Integer theShapeType,
381 GEOMAlgo_State theState);
384 * \brief Find shape objects and their entries by their ids
385 * \param theShape - the main shape
386 * \param theShapeIDs - theShapeIDs - incoming shape ids
387 * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
388 * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
390 Handle(TColStd_HSequenceOfTransient)
391 getObjectsShapesOn(const Handle(GEOM_Object)& theShape,
392 const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
393 TCollection_AsciiString & theShapeEntries);
396 * \brief Select the object created last
397 * \param theObj1 - Object 1
398 * \param theObj2 - Object 2
399 * \retval Handle(GEOM_Object) - selected object
401 static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
402 const Handle(GEOM_Object)& theObj2);