Salome HOME
NPAL15379: Fuse error with partitionned shape. Roll back the fix because of regressions.
[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  public:
41   Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
42   Standard_EXPORT ~GEOMImpl_IShapesOperations();
43
44   Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
45                                 Handle(GEOM_Object) thePoint2);
46
47   Standard_EXPORT Handle(GEOM_Object) MakeWire (list<Handle(GEOM_Object)> theEdgesAndWires);
48
49   Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
50
51   Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (list<Handle(GEOM_Object)> theWires,
52                                      const bool isPlanarWanted);
53
54   Standard_EXPORT Handle(GEOM_Object) MakeShell (list<Handle(GEOM_Object)> theShapes);
55
56   Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell);
57
58   Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (list<Handle(GEOM_Object)> theShells);
59
60   Standard_EXPORT Handle(GEOM_Object) MakeCompound (list<Handle(GEOM_Object)> theShapes);
61
62   Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
63                                                      const Standard_Real theTolerance);
64
65   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
66                                                                      const Standard_Real theTolerance);
67
68   Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
69                                                            const Standard_Real theTolerance,
70                                                            list<Handle(GEOM_Object)> theFaces);
71
72   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object)    theShape,
73                                                     const Standard_Integer theShapeType,
74                                                     const Standard_Boolean isSorted);
75
76   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs (Handle(GEOM_Object)    theShape,
77                                                      const Standard_Integer theShapeType,
78                                                      const Standard_Boolean isSorted);
79
80   Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object)    theMainShape,
81                                                    const Standard_Integer theID);
82
83   Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
84                                                      Handle(GEOM_Object) theSubShape);
85
86   Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
87                                                      Handle(GEOM_Object) theSubShape);
88
89   Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
90
91   Standard_EXPORT Standard_Integer NumberOfFaces (Handle(GEOM_Object) theShape);
92   Standard_EXPORT Standard_Integer NumberOfEdges (Handle(GEOM_Object) theShape);
93
94   Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
95
96   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
97
98   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetSharedShapes (Handle(GEOM_Object)    theShape1,
99                                                         Handle(GEOM_Object)    theShape2,
100                                                         const Standard_Integer theShapeType);
101
102   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
103                                                          const Standard_Integer     theShapeType,
104                                                          const Handle(GEOM_Object)& theAx1,
105                                                          const GEOMAlgo_State       theState);
106
107   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
108     GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
109                                   const Standard_Integer     theShapeType,
110                                   const Handle(GEOM_Object)& theAx1,
111                                   const Handle(GEOM_Object)& thePnt,
112                                   const GEOMAlgo_State       theState);
113
114
115   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
116                                                             const Standard_Integer     theShapeType,
117                                                             const Handle(GEOM_Object)& theAxis,
118                                                             const Standard_Real        theRadius,
119                                                             const GEOMAlgo_State       theState);
120
121   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
122                                                           const Standard_Integer     theShapeType,
123                                                           const Handle(GEOM_Object)& theCenter,
124                                                           const Standard_Real        theRadius,
125                                                           const GEOMAlgo_State       theState);
126
127   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
128                                                           const Standard_Integer     theShapeType,
129                                                           const Handle(GEOM_Object)& theAx1,
130                                                           const GEOMAlgo_State       theState);
131
132   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
133     GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
134                                      const Standard_Integer     theShapeType,
135                                      const Handle(GEOM_Object)& theAx1,
136                                      const Handle(GEOM_Object)& thePnt,
137                                      const GEOMAlgo_State       theState);
138
139   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
140                                                              const Standard_Integer     theShapeType,
141                                                              const Handle(GEOM_Object)& theAxis,
142                                                              const Standard_Real        theRadius,
143                                                              const GEOMAlgo_State       theState);
144
145   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
146                                                            const Standard_Integer     theShapeType,
147                                                            const Handle(GEOM_Object)& theCenter,
148                                                            const Standard_Real        theRadius,
149                                                            const GEOMAlgo_State       theState);
150
151   /*!
152    * \brief Find subshapes complying with given status about quadrangle
153     * \param theShape - the shape to explore
154     * \param theShapeType - type of subshape of theShape
155     * \param theTopLeftPoint - top left quadrangle corner
156     * \param theTopRigthPoint - top right quadrangle corner
157     * \param theBottomLeftPoint - bottom left quadrangle corner
158     * \param theBottomRigthPoint - bottom right quadrangle corner
159     * \param theState - required state
160     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
161    */
162   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
163     GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
164                            const Standard_Integer     theShapeType,
165                            const Handle(GEOM_Object)& theTopLeftPoint,
166                            const Handle(GEOM_Object)& theTopRigthPoint,
167                            const Handle(GEOM_Object)& theBottomLeftPoint,
168                            const Handle(GEOM_Object)& theBottomRigthPoint,
169                            const GEOMAlgo_State       theState);
170
171   /*!
172    * \brief Find IDs of subshapes complying with given status about quadrangle
173     * \param theShape - the shape to explore
174     * \param theShapeType - type of subshape of theShape
175     * \param theTopLeftPoint - top left quadrangle corner
176     * \param theTopRigthPoint - top right quadrangle corner
177     * \param theBottomLeftPoint - bottom left quadrangle corner
178     * \param theBottomRigthPoint - bottom right quadrangle corner
179     * \param theState - required state
180     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
181    */
182   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
183     GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
184                               const Standard_Integer     theShapeType,
185                               const Handle(GEOM_Object)& theTopLeftPoint,
186                               const Handle(GEOM_Object)& theTopRigthPoint,
187                               const Handle(GEOM_Object)& theBottomLeftPoint,
188                               const Handle(GEOM_Object)& theBottomRigthPoint,
189                               const GEOMAlgo_State       theState);
190
191   Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object)    theShape,
192                                               const Standard_Integer theShapeType,
193                                               Handle(GEOM_Object)    theAxis,
194                                               const Standard_Real    theRadius);
195
196   Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object)    theShape,
197                                             const Standard_Integer theShapeType,
198                                             Handle(GEOM_Object)    theCenter,
199                                             const Standard_Real    theRadius);
200
201   Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
202                                                   Handle(GEOM_Object) theShapeWhat);
203
204   Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
205
206   /*!
207    * \brief Searches a shape equal to theWhat in the context of theWhere
208    * \param theShapeWhere - a context shap
209    * \param theShapeWhat - a sample shape
210    * \retval Handle(GEOM_Object) - found shape
211    */
212   Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
213                                               const Handle(GEOM_Object)& theShapeWhat);
214
215   /*!
216    * \brief Find IDs of subshapes complying with given status about surface
217     * \param theBox - the box to check state of subshapes against
218     * \param theShape - the shape to explore
219     * \param theShapeType - type of subshape of theShape
220     * \param theState - required state
221     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
222    */
223   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
224                               GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
225                                                 const Handle(GEOM_Object)& theShape,
226                                                 const Standard_Integer theShapeType,
227                                                 GEOMAlgo_State theState);
228
229   /*!
230    * \brief Find subshapes complying with given status about surface
231    * \param theBox - the box to check state of subshapes against
232    * \param theShape - the shape to explore
233    * \param theShapeType - type of subshape of theShape
234    * \param theState - required state
235    * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
236    */
237   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
238                                 GetShapesOnBox(const Handle(GEOM_Object)& theBox,
239                                                const Handle(GEOM_Object)& theShape,
240                                                const Standard_Integer theShapeType,
241                                                GEOMAlgo_State theState);
242
243  private:
244   Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)>      theShapes,
245                                  const Standard_Integer         theObjectType,
246                                  const Standard_Integer         theFunctionType,
247                                  const TCollection_AsciiString& theMethodName);
248
249 // ----------------------------------------------------
250   // methods common for all GetShapesOnXXX() functions
251 // ----------------------------------------------------
252
253   bool CheckTriangulation (const TopoDS_Shape& aShape);
254
255   /*!
256    * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
257     * \param theShapeType - the shape type to check
258     * \retval bool  - result of the check
259    */
260   bool checkTypeShapesOn(const Standard_Integer theShapeType);
261
262   /*!
263    * \brief Creates Geom_Plane
264     * \param theAx1 - edge defining plane normal
265     * \retval Handle(Geom_Surface) - resulting surface
266    */
267   Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
268
269   /*!
270    * \brief Creates Geom_CylindricalSurface
271     * \param theAx1 - edge defining cylinder axis
272     * \param theRadius - cylinder radius
273     * \retval Handle(Geom_Surface) - resulting surface
274    */
275   Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
276                                     const Standard_Real theRadius);
277
278   /*!
279    * \brief Find IDs of subshapes complying with given status about surface
280     * \param theSurface - the surface to check state of subshapes against
281     * \param theShape - the shape to explore
282     * \param theShapeType - type of subshape of theShape
283     * \param theState - required state
284     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
285    */
286   Handle(TColStd_HSequenceOfInteger)
287     getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
288                           const TopoDS_Shape&         theShape,
289                           TopAbs_ShapeEnum            theShapeType,
290                           GEOMAlgo_State              theState);
291
292   /*!
293    * \brief Find subshapes complying with given status about surface
294     * \param theSurface - the surface to check state of subshapes against
295     * \param theShape - the shape to explore
296     * \param theShapeType - type of subshape of theShape
297     * \param theState - required state
298     * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
299     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
300    */
301   Handle(TColStd_HSequenceOfTransient)
302     getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
303                        const Handle(GEOM_Object)&  theShape,
304                        TopAbs_ShapeEnum            theShapeType,
305                        GEOMAlgo_State              theState,
306                        TCollection_AsciiString &   theShapeEntries);
307
308   /*!
309    * \brief Find IDs of subshapes complying with given status about quadrangle
310     * \param theShape - the shape to explore
311     * \param theShapeType - type of subshape of theShape
312     * \param theTopLeftPoint - top left quadrangle corner
313     * \param theTopRigthPoint - top right quadrangle corner
314     * \param theBottomLeftPoint - bottom left quadrangle corner
315     * \param theBottomRigthPoint - bottom right quadrangle corner
316     * \param theState - required state
317     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
318    */
319   Handle(TColStd_HSequenceOfInteger)
320     getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
321                               const Standard_Integer     theShapeType,
322                               const Handle(GEOM_Object)& theTopLeftPoint,
323                               const Handle(GEOM_Object)& theTopRigthPoint,
324                               const Handle(GEOM_Object)& theBottomLeftPoint,
325                               const Handle(GEOM_Object)& theBottomRigthPoint,
326                               const GEOMAlgo_State       theState);
327
328   /*!
329    * \brief Find IDs of subshapes complying with given status about surface
330     * \param theBox - the box to check state of subshapes against
331     * \param theShape - the shape to explore
332     * \param theShapeType - type of subshape of theShape
333     * \param theState - required state
334     * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found subshapes
335    */
336   Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
337                                                        const Handle(GEOM_Object)& theShape,
338                                                        const Standard_Integer theShapeType,
339                                                        GEOMAlgo_State theState);
340
341   /*!
342    * \brief Find shape objects and their entries by their ids
343     * \param theShape - the main shape
344     * \param theShapeIDs - theShapeIDs - incoming shape ids
345     * \param theShapeEntries - outgoing entries like "entry1, entry2, ..."
346     * \retval Handle(TColStd_HSequenceOfTransient) - found shape objects
347    */
348   Handle(TColStd_HSequenceOfTransient)
349     getObjectsShapesOn(const Handle(GEOM_Object)&                theShape,
350                        const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
351                        TCollection_AsciiString &                 theShapeEntries);
352
353   /*!
354    * \brief Select the object created last
355     * \param theObj1 - Object 1
356     * \param theObj2 - Object 2
357     * \retval Handle(GEOM_Object) - selected object
358    */
359   static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
360                                             const Handle(GEOM_Object)& theObj2);
361 };
362
363 #endif