Salome HOME
Eliminate useless GetSubShape() lines in the python dump
[modules/geom.git] / src / GEOM_I / GEOM_ILocalOperations_i.cc
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include <Standard_Stream.hxx>
24
25 #include "GEOM_ILocalOperations_i.hh"
26
27 #include "utilities.h"
28 #include "OpUtil.hxx"
29 #include "Utils_ExceptHandlers.hxx"
30
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
33
34 //=============================================================================
35 /*!
36  *   constructor:
37  */
38 //=============================================================================
39 GEOM_ILocalOperations_i::GEOM_ILocalOperations_i (PortableServer::POA_ptr thePOA,
40                                                   GEOM::GEOM_Gen_ptr theEngine,
41                                                   ::GEOMImpl_ILocalOperations* theImpl)
42      :GEOM_IOperations_i(thePOA, theEngine, theImpl)
43 {
44   MESSAGE("GEOM_ILocalOperations_i::GEOM_ILocalOperations_i");
45 }
46
47 //=============================================================================
48 /*!
49  *  destructor
50  */
51 //=============================================================================
52 GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i()
53 {
54   MESSAGE("GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i");
55 }
56
57
58 //=============================================================================
59 /*!
60  *  MakeFilletAll
61  */
62 //=============================================================================
63 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletAll
64                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR)
65 {
66   GEOM::GEOM_Object_var aGEOMObject;
67
68   //Get the reference shape
69   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
70   if (aShapeRef.IsNull()) return aGEOMObject._retn();
71
72   //Create the Fillet
73   Handle(GEOM_Object) anObject =
74     GetOperations()->MakeFilletAll(aShapeRef, theR);
75   if (!GetOperations()->IsDone() || anObject.IsNull())
76     return aGEOMObject._retn();
77
78   return GetObject(anObject);
79 }
80
81 //=============================================================================
82 /*!
83  *  MakeFilletEdges
84  */
85 //=============================================================================
86 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges
87                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
88                        const GEOM::ListOfLong& theEdges)
89 {
90   GEOM::GEOM_Object_var aGEOMObject;
91
92   //Get the reference shape
93   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
94   if (aShapeRef.IsNull()) return aGEOMObject._retn();
95
96   //Get the reference edges
97   int ind = 0;
98   int aLen = theEdges.length();
99   std::list<int> anEdges;
100   for (; ind < aLen; ind++) {
101     anEdges.push_back(theEdges[ind]);
102   }
103
104   //Create the Fillet
105   Handle(GEOM_Object) anObject =
106     GetOperations()->MakeFilletEdges(aShapeRef, theR, anEdges);
107   if (!GetOperations()->IsDone() || anObject.IsNull())
108     return aGEOMObject._retn();
109
110   return GetObject(anObject);
111 }
112
113 //=============================================================================
114 /*!
115  *  MakeFilletEdges R1 R2
116  */
117 //=============================================================================
118 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdgesR1R2
119                      (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
120                       CORBA::Double theR2, const GEOM::ListOfLong& theEdges)
121 {
122   GEOM::GEOM_Object_var aGEOMObject;
123
124   //Get the reference shape
125   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
126   if (aShapeRef.IsNull()) return aGEOMObject._retn();
127
128   //Get the reference edges
129   int ind = 0;
130   int aLen = theEdges.length();
131   std::list<int> anEdges;
132   for (; ind < aLen; ind++) {
133     anEdges.push_back(theEdges[ind]);
134   }
135
136   //Create the Fillet
137   Handle(GEOM_Object) anObject =
138     GetOperations()->MakeFilletEdgesR1R2(aShapeRef, theR1, theR2, anEdges);
139   if (!GetOperations()->IsDone() || anObject.IsNull())
140     return aGEOMObject._retn();
141
142   return GetObject(anObject);
143 }
144
145 //=============================================================================
146 /*!
147  *  MakeFilletFaces
148  */
149 //=============================================================================
150 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces
151                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
152                        const GEOM::ListOfLong& theFaces)
153 {
154   GEOM::GEOM_Object_var aGEOMObject;
155
156   //Get the reference shape
157   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
158   if (aShapeRef.IsNull()) return aGEOMObject._retn();
159
160   //Get the reference faces
161   int ind = 0;
162   int aLen = theFaces.length();
163   std::list<int> aFaces;
164   for (; ind < aLen; ind++) {
165     aFaces.push_back(theFaces[ind]);
166   }
167
168   //Create the Fillet
169   Handle(GEOM_Object) anObject =
170     GetOperations()->MakeFilletFaces(aShapeRef, theR, aFaces);
171   if (!GetOperations()->IsDone() || anObject.IsNull())
172     return aGEOMObject._retn();
173
174   return GetObject(anObject);
175 }
176
177 //=============================================================================
178 /*!
179  *  MakeFilletFaces R1 R2
180  */
181 //=============================================================================
182 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFacesR1R2
183                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
184                        CORBA::Double theR2, const GEOM::ListOfLong& theFaces)
185 {
186   GEOM::GEOM_Object_var aGEOMObject;
187
188   //Get the reference shape
189   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
190   if (aShapeRef.IsNull()) return aGEOMObject._retn();
191
192   //Get the reference faces
193   int ind = 0;
194   int aLen = theFaces.length();
195   std::list<int> aFaces;
196   for (; ind < aLen; ind++) {
197     aFaces.push_back(theFaces[ind]);
198   }
199
200   //Create the Fillet
201   Handle(GEOM_Object) anObject =
202     GetOperations()->MakeFilletFacesR1R2(aShapeRef, theR1, theR2, aFaces);
203   if (!GetOperations()->IsDone() || anObject.IsNull())
204     return aGEOMObject._retn();
205
206   return GetObject(anObject);
207 }
208
209 //=============================================================================
210 /*!
211  *  MakeFillet2D
212  */
213 //=============================================================================
214 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet2D
215                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
216                        const GEOM::ListOfLong& theVertexes)
217 {
218   GEOM::GEOM_Object_var aGEOMObject;
219
220   //Get the reference shape
221   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
222   if (aShapeRef.IsNull()) return aGEOMObject._retn();
223
224   //Get the reference vertex
225   int ind = 0;
226   int aLen = theVertexes.length();
227   std::list<int> aVertexes;
228   for (; ind < aLen; ind++) {
229     aVertexes.push_back(theVertexes[ind]);
230   }
231
232   //Create the Fillet
233   Handle(GEOM_Object) anObject =
234     GetOperations()->MakeFillet2D(aShapeRef, theR, aVertexes);
235   if (!GetOperations()->IsDone() || anObject.IsNull())
236     return aGEOMObject._retn();
237
238   return GetObject(anObject);
239 }
240
241 //=============================================================================
242 /*!
243  *  MakeFillet1D
244  */
245 //=============================================================================
246 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet1D
247                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
248                        const GEOM::ListOfLong& theVertexes)
249 {
250   GEOM::GEOM_Object_var aGEOMObject;
251
252   //Get the reference shape (wire)
253   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
254   if (aShapeRef.IsNull()) return aGEOMObject._retn();
255
256   //Get the reference vertex
257   int ind = 0;
258   int aLen = theVertexes.length();
259   std::list<int> aVertexes;
260   for (; ind < aLen; ind++) {
261     aVertexes.push_back(theVertexes[ind]);
262   }
263
264   //Create the Fillet
265   Handle(GEOM_Object) anObject =
266     GetOperations()->MakeFillet1D(aShapeRef, theR, aVertexes);
267   if (!GetOperations()->IsDone() || anObject.IsNull())
268     return aGEOMObject._retn();
269
270   return GetObject(anObject);
271 }
272
273 //=============================================================================
274 /*!
275  *  MakeChamferAll
276  */
277 //=============================================================================
278 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferAll
279                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD)
280 {
281   GEOM::GEOM_Object_var aGEOMObject;
282
283   //Get the reference shape
284   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
285   if (aShapeRef.IsNull()) return aGEOMObject._retn();
286
287   //Create the Chamfer
288   Handle(GEOM_Object) anObject =
289     GetOperations()->MakeChamferAll(aShapeRef, theD);
290   if (!GetOperations()->IsDone() || anObject.IsNull())
291     return aGEOMObject._retn();
292
293   return GetObject(anObject);
294 }
295
296 //=============================================================================
297 /*!
298  *  MakeChamferEdge
299  */
300 //=============================================================================
301 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge
302                       (GEOM::GEOM_Object_ptr theShape,
303                        CORBA::Double theD1, CORBA::Double theD2,
304                        CORBA::Long theFace1, CORBA::Long theFace2)
305 {
306   GEOM::GEOM_Object_var aGEOMObject;
307
308   //Get the reference shape
309   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
310   if (aShapeRef.IsNull()) return aGEOMObject._retn();
311
312   //Create the Chamfer
313   Handle(GEOM_Object) anObject =
314     GetOperations()->MakeChamferEdge(aShapeRef, theD1, theD2, theFace1, theFace2);
315   if (!GetOperations()->IsDone() || anObject.IsNull())
316     return aGEOMObject._retn();
317
318   return GetObject(anObject);
319 }
320 //=============================================================================
321 /*!
322  *  MakeChamferEdgeAD
323  */
324 //=============================================================================
325 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgeAD
326                       (GEOM::GEOM_Object_ptr theShape,
327                        CORBA::Double theD, CORBA::Double theAngle,
328                        CORBA::Long theFace1, CORBA::Long theFace2)
329 {
330   GEOM::GEOM_Object_var aGEOMObject;
331
332   //Get the reference shape
333   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
334   if (aShapeRef.IsNull()) return aGEOMObject._retn();
335
336   //Create the Chamfer
337   Handle(GEOM_Object) anObject =
338     GetOperations()->MakeChamferEdgeAD(aShapeRef, theD, theAngle, theFace1, theFace2);
339   if (!GetOperations()->IsDone() || anObject.IsNull())
340     return aGEOMObject._retn();
341
342   return GetObject(anObject);
343 }
344
345 //=============================================================================
346 /*!
347  *  MakeChamferFaces
348  */
349 //=============================================================================
350 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces
351                       (GEOM::GEOM_Object_ptr theShape,
352                        CORBA::Double theD1, CORBA::Double theD2,
353                        const GEOM::ListOfLong& theFaces)
354 {
355   GEOM::GEOM_Object_var aGEOMObject;
356
357   //Get the reference shape
358   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
359   if (aShapeRef.IsNull()) return aGEOMObject._retn();
360
361   //Get the reference faces
362   int ind = 0;
363   int aLen = theFaces.length();
364   std::list<int> aFaces;
365   for (; ind < aLen; ind++) {
366     aFaces.push_back(theFaces[ind]);
367   }
368
369   //Create the Chamfer
370   Handle(GEOM_Object) anObject =
371     GetOperations()->MakeChamferFaces(aShapeRef, theD1, theD2, aFaces);
372   if (!GetOperations()->IsDone() || anObject.IsNull())
373     return aGEOMObject._retn();
374
375   return GetObject(anObject);
376 }
377 //=============================================================================
378 /*!
379  *  MakeChamferFacesAD
380  */
381 //=============================================================================
382 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFacesAD
383                       (GEOM::GEOM_Object_ptr theShape,
384                        CORBA::Double theD, CORBA::Double theAngle,
385                        const GEOM::ListOfLong& theFaces)
386 {
387   GEOM::GEOM_Object_var aGEOMObject;
388
389   //Get the reference shape
390   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
391   if (aShapeRef.IsNull()) return aGEOMObject._retn();
392
393   //Get the reference faces
394   int ind = 0;
395   int aLen = theFaces.length();
396   std::list<int> aFaces;
397   for (; ind < aLen; ind++) {
398     aFaces.push_back(theFaces[ind]);
399   }
400
401   //Create the Chamfer
402   Handle(GEOM_Object) anObject =
403     GetOperations()->MakeChamferFacesAD(aShapeRef, theD, theAngle, aFaces);
404   if (!GetOperations()->IsDone() || anObject.IsNull())
405     return aGEOMObject._retn();
406
407   return GetObject(anObject);
408 }
409
410 //=============================================================================
411 /*!
412  *  MakeChamferEdges
413  */
414 //=============================================================================
415 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdges
416                       (GEOM::GEOM_Object_ptr theShape,
417                        CORBA::Double theD1, CORBA::Double theD2,
418                        const GEOM::ListOfLong& theEdges)
419 {
420   GEOM::GEOM_Object_var aGEOMObject;
421
422   //Get the reference shape
423   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
424   if (aShapeRef.IsNull()) return aGEOMObject._retn();
425
426   //Get the reference edges
427   int ind = 0;
428   int aLen = theEdges.length();
429   std::list<int> aEdges;
430   for (; ind < aLen; ind++) {
431     aEdges.push_back(theEdges[ind]);
432   }
433
434   //Create the Chamfer
435   Handle(GEOM_Object) anObject =
436     GetOperations()->MakeChamferEdges(aShapeRef, theD1, theD2, aEdges);
437   if (!GetOperations()->IsDone() || anObject.IsNull())
438     return aGEOMObject._retn();
439
440   return GetObject(anObject);
441 }
442
443 //=============================================================================
444 /*!
445  *  MakeChamferEdgesAD
446  */
447 //=============================================================================
448 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgesAD
449                       (GEOM::GEOM_Object_ptr theShape,
450                        CORBA::Double theD, CORBA::Double theAngle,
451                        const GEOM::ListOfLong& theEdges)
452 {
453   GEOM::GEOM_Object_var aGEOMObject;
454
455   //Get the reference shape
456   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
457   if (aShapeRef.IsNull()) return aGEOMObject._retn();
458
459   //Get the reference edges
460   int ind = 0;
461   int aLen = theEdges.length();
462   std::list<int> aEdges;
463   for (; ind < aLen; ind++) {
464     aEdges.push_back(theEdges[ind]);
465   }
466
467   //Create the Chamfer
468   Handle(GEOM_Object) anObject =
469     GetOperations()->MakeChamferEdgesAD(aShapeRef, theD, theAngle, aEdges);
470   if (!GetOperations()->IsDone() || anObject.IsNull())
471     return aGEOMObject._retn();
472
473   return GetObject(anObject);
474 }
475
476 //=============================================================================
477 /*!
478  *  MakeArchimede
479  */
480 //=============================================================================
481 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape,
482                                                               CORBA::Double theWeight,
483                                                               CORBA::Double theWaterDensity,
484                                                               CORBA::Double theMeshingDeflection)
485 {
486   GEOM::GEOM_Object_var aGEOMObject;
487
488   //Get the reference shape
489   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
490   if (aShapeRef.IsNull()) return aGEOMObject._retn();
491
492   //Create the Archimede
493   Handle(GEOM_Object) anObject = GetOperations()->MakeArchimede
494     (aShapeRef, theWeight, theWaterDensity, theMeshingDeflection);
495   if (!GetOperations()->IsDone() || anObject.IsNull())
496     return aGEOMObject._retn();
497
498   return GetObject(anObject);
499 }
500
501 //=============================================================================
502 /*!
503  *  GetSubShapeIndex
504  */
505 //=============================================================================
506 CORBA::Long GEOM_ILocalOperations_i::GetSubShapeIndex
507   (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr theSubShape)
508 {
509   //Get the reference shapes
510   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
511   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
512   if (aShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
513
514   //Get the unique ID of <theSubShape> inside <theShape>
515   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aShapeRef, aSubShapeRef);
516   if (!GetOperations()->IsDone())
517     return -1;
518
519   return anID;
520 }