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