]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMImpl/GEOMImpl_IShapesOperations.hxx
Salome HOME
b345677552a4efe7fc9e42bafd5348f3d89cb4af
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IShapesOperations.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20
21 #ifndef _GEOMImpl_IShapesOperations_HXX_
22 #define _GEOMImpl_IShapesOperations_HXX_
23
24 #include "GEOM_IOperations.hxx"
25
26 #include "GEOMAlgo_State.hxx"
27
28 #include <TopTools_ListOfShape.hxx>
29 #include <TColStd_HSequenceOfTransient.hxx>
30 #include <TColStd_HSequenceOfInteger.hxx>
31
32 #include <list>
33 #include <Handle_Geom_Surface.hxx>
34
35 class GEOM_Engine;
36 class Handle(GEOM_Object);
37 class Handle(TColStd_HArray1OfInteger);
38
39 class GEOMImpl_IShapesOperations : public GEOM_IOperations
40 {
41  public:
42   Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
43   Standard_EXPORT ~GEOMImpl_IShapesOperations();
44
45   Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
46                                 Handle(GEOM_Object) thePoint2);
47
48   Standard_EXPORT Handle(GEOM_Object) MakeWire (list<Handle(GEOM_Object)> theEdgesAndWires);
49
50   Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
51
52   Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (list<Handle(GEOM_Object)> theWires,
53                                      const bool isPlanarWanted);
54
55   Standard_EXPORT Handle(GEOM_Object) MakeShell (list<Handle(GEOM_Object)> theShapes);
56
57   Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell);
58
59   Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (list<Handle(GEOM_Object)> theShells);
60
61   Standard_EXPORT Handle(GEOM_Object) MakeCompound (list<Handle(GEOM_Object)> theShapes);
62
63   Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
64                                                      const Standard_Real theTolerance,
65                                                      const Standard_Boolean doKeepNonSolids);
66
67   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
68                                                                      const Standard_Real theTolerance);
69
70   Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
71                                                            const Standard_Real theTolerance,
72                                                            list<Handle(GEOM_Object)> theFaces,
73                                                            const Standard_Boolean doKeepNonSolids);
74
75   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object)    theShape,
76                                                                     const Standard_Integer theShapeType,
77                                                                     const Standard_Boolean isSorted);
78
79   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object)    theShape,
80                                                                      const Standard_Integer theShapeType,
81                                                                      const Standard_Boolean isSorted);
82
83   Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object)    theMainShape,
84                                                    const Standard_Integer theID);
85
86   Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
87                                                      Handle(GEOM_Object) theSubShape);
88
89   Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
90                                                      Handle(GEOM_Object) theSubShape);
91
92   Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
93
94   Standard_EXPORT Standard_Integer NumberOfFaces (Handle(GEOM_Object) theShape);
95   Standard_EXPORT Standard_Integer NumberOfEdges (Handle(GEOM_Object) theShape);
96
97   Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
98
99   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
100
101   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object)    theShape1,
102                                                         Handle(GEOM_Object)    theShape2,
103                                                         const Standard_Integer theShapeType);
104
105   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
106                                                          const Standard_Integer     theShapeType,
107                                                          const Handle(GEOM_Object)& theAx1,
108                                                          const GEOMAlgo_State       theState);
109
110   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
111     GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
112                                   const Standard_Integer     theShapeType,
113                                   const Handle(GEOM_Object)& theAx1,
114                                   const Handle(GEOM_Object)& thePnt,
115                                   const GEOMAlgo_State       theState);
116
117
118   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
119     GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
120                          const Standard_Integer     theShapeType,
121                          const Handle(GEOM_Object)& theAxis,
122                          const Standard_Real        theRadius,
123                          const GEOMAlgo_State       theState);
124
125   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
126     GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
127                        const Standard_Integer     theShapeType,
128                        const Handle(GEOM_Object)& theCenter,
129                        const Standard_Real        theRadius,
130                        const GEOMAlgo_State       theState);
131
132   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
133     GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
134                          const Standard_Integer     theShapeType,
135                          const Handle(GEOM_Object)& theAx1,
136                          const GEOMAlgo_State       theState);
137
138   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
139     GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
140                                      const Standard_Integer     theShapeType,
141                                      const Handle(GEOM_Object)& theAx1,
142                                      const Handle(GEOM_Object)& thePnt,
143                                      const GEOMAlgo_State       theState);
144
145   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
146     GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
147                             const Standard_Integer     theShapeType,
148                             const Handle(GEOM_Object)& theAxis,
149                             const Standard_Real        theRadius,
150                             const GEOMAlgo_State       theState);
151
152   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
153     GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
154                           const Standard_Integer     theShapeType,
155                           const Handle(GEOM_Object)& theCenter,
156                           const Standard_Real        theRadius,
157                           const GEOMAlgo_State       theState);
158
159   /*!
160    * \brief Find subshapes complying with given status about quadrangle
161     * \param theShape - the shape to explore
162     * \param theShapeType - type of subshape of theShape
163     * \param theTopLeftPoint - top left quadrangle corner
164     * \param theTopRigthPoint - top right quadrangle corner
165     * \param theBottomLeftPoint - bottom left quadrangle corner
166     * \param theBottomRigthPoint - bottom right quadrangle corner
167     * \param theState - required state
168     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
169    */
170   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
171     GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
172                            const Standard_Integer     theShapeType,
173                            const Handle(GEOM_Object)& theTopLeftPoint,
174                            const Handle(GEOM_Object)& theTopRigthPoint,
175                            const Handle(GEOM_Object)& theBottomLeftPoint,
176                            const Handle(GEOM_Object)& theBottomRigthPoint,
177                            const GEOMAlgo_State       theState);
178
179   /*!
180    * \brief Find IDs of subshapes complying with given status about quadrangle
181     * \param theShape - the shape to explore
182     * \param theShapeType - type of subshape of theShape
183     * \param theTopLeftPoint - top left quadrangle corner
184     * \param theTopRigthPoint - top right quadrangle corner
185     * \param theBottomLeftPoint - bottom left quadrangle corner
186     * \param theBottomRigthPoint - bottom right quadrangle corner
187     * \param theState - required state
188     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
189    */
190   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
191     GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
192                               const Standard_Integer     theShapeType,
193                               const Handle(GEOM_Object)& theTopLeftPoint,
194                               const Handle(GEOM_Object)& theTopRigthPoint,
195                               const Handle(GEOM_Object)& theBottomLeftPoint,
196                               const Handle(GEOM_Object)& theBottomRigthPoint,
197                               const GEOMAlgo_State       theState);
198
199   Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object)    theShape,
200                                               const Standard_Integer theShapeType,
201                                               Handle(GEOM_Object)    theAxis,
202                                               const Standard_Real    theRadius);
203
204   Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object)    theShape,
205                                             const Standard_Integer theShapeType,
206                                             Handle(GEOM_Object)    theCenter,
207                                             const Standard_Real    theRadius);
208
209   Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
210                                                   Handle(GEOM_Object) theShapeWhat);
211
212   /*!
213    * \brief Searches a shape equal to theWhat in the context of theWhere
214    * \param theShapeWhere - a context shap
215    * \param theShapeWhat - a sample shape
216    * \retval Handle(GEOM_Object) - found shape
217    */
218   Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
219                                               const Handle(GEOM_Object)& theShapeWhat);
220
221   /*!
222    * \brief Find IDs of subshapes complying with given status about surface
223     * \param theBox - the box to check state of subshapes against
224     * \param theShape - the shape to explore
225     * \param theShapeType - type of subshape of theShape
226     * \param theState - required state
227     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
228    */
229   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
230                               GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
231                                                 const Handle(GEOM_Object)& theShape,
232                                                 const Standard_Integer theShapeType,
233                                                 GEOMAlgo_State theState);
234
235   /*!
236    * \brief Find 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
242    */
243   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
244                                 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
245                                                const Handle(GEOM_Object)& theShape,
246                                                const Standard_Integer theShapeType,
247                                                GEOMAlgo_State theState);
248
249  public:
250   /*!
251    * \brief Sort shapes in the list by their coordinates.
252    * \param SL The list of shapes to sort.
253    */
254   Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
255
256   /*!
257    * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
258    *
259    * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
260    *
261    * \param theCompsolid The compsolid to be converted.
262    * \retval TopoDS_Shape Returns the resulting compound.
263    */
264   Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
265
266   /*!
267    * \brief Build a triangulation on \a theShape if it is absent.
268    * \param theShape The shape to check/build triangulation on.
269    * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
270    */
271   Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
272
273  private:
274   Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)>      theShapes,
275                                  const Standard_Integer         theObjectType,
276                                  const Standard_Integer         theFunctionType,
277                                  const TCollection_AsciiString& theMethodName);
278
279 // ----------------------------------------------------
280 // methods common for all GetShapesOnXXX() functions
281 // ----------------------------------------------------
282
283   /*!
284    * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
285     * \param theShapeType - the shape type to check
286     * \retval bool  - result of the check
287    */
288   bool checkTypeShapesOn(const Standard_Integer theShapeType);
289
290   /*!
291    * \brief Creates Geom_Plane
292     * \param theAx1 - edge defining plane normal
293     * \retval Handle(Geom_Surface) - resulting surface
294    */
295   Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
296
297   /*!
298    * \brief Creates Geom_CylindricalSurface
299     * \param theAx1 - edge defining cylinder axis
300     * \param theRadius - cylinder radius
301     * \retval Handle(Geom_Surface) - resulting surface
302    */
303   Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
304                                     const Standard_Real theRadius);
305
306   /*!
307    * \brief Find IDs of subshapes complying with given status about surface
308     * \param theSurface - the surface to check state of subshapes against
309     * \param theShape - the shape to explore
310     * \param theShapeType - type of subshape of theShape
311     * \param theState - required state
312     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
313    */
314   Handle(TColStd_HSequenceOfInteger)
315     getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
316                           const TopoDS_Shape&         theShape,
317                           TopAbs_ShapeEnum            theShapeType,
318                           GEOMAlgo_State              theState);
319
320   /*!
321    * \brief Find 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     * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
327     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
328    */
329   Handle(TColStd_HSequenceOfTransient)
330     getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
331                        const Handle(GEOM_Object)&  theShape,
332                        TopAbs_ShapeEnum            theShapeType,
333                        GEOMAlgo_State              theState,
334                        TCollection_AsciiString &   theShapeEntries);
335
336   /*!
337    * \brief Find IDs of subshapes complying with given status about quadrangle
338     * \param theShape - the shape to explore
339     * \param theShapeType - type of subshape of theShape
340     * \param theTopLeftPoint - top left quadrangle corner
341     * \param theTopRigthPoint - top right quadrangle corner
342     * \param theBottomLeftPoint - bottom left quadrangle corner
343     * \param theBottomRigthPoint - bottom right quadrangle corner
344     * \param theState - required state
345     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
346    */
347   Handle(TColStd_HSequenceOfInteger)
348     getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
349                               const Standard_Integer     theShapeType,
350                               const Handle(GEOM_Object)& theTopLeftPoint,
351                               const Handle(GEOM_Object)& theTopRigthPoint,
352                               const Handle(GEOM_Object)& theBottomLeftPoint,
353                               const Handle(GEOM_Object)& theBottomRigthPoint,
354                               const GEOMAlgo_State       theState);
355
356   /*!
357    * \brief Find IDs of subshapes complying with given status about surface
358     * \param theBox - the box to check state of subshapes against
359     * \param theShape - the shape to explore
360     * \param theShapeType - type of subshape of theShape
361     * \param theState - required state
362     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
363    */
364   Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
365                                                        const Handle(GEOM_Object)& theShape,
366                                                        const Standard_Integer theShapeType,
367                                                        GEOMAlgo_State theState);
368
369   /*!
370    * \brief Find shape objects and their entries by their ids
371     * \param theShape - the main shape
372     * \param theShapeIDs - theShapeIDs - incoming shape ids
373     * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
374     * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
375    */
376   Handle(TColStd_HSequenceOfTransient)
377     getObjectsShapesOn(const Handle(GEOM_Object)&                theShape,
378                        const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
379                        TCollection_AsciiString &                 theShapeEntries);
380
381   /*!
382    * \brief Select the object created last
383     * \param theObj1 - Object 1
384     * \param theObj2 - Object 2
385     * \retval Handle(GEOM_Object) - selected object
386    */
387   static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
388                                             const Handle(GEOM_Object)& theObj2);
389 };
390
391 #endif