Salome HOME
Patch for Windows compatibility: add missing -lSALOMEBasics option
[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   //Get the reference shape
68   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
69   if (aShapeRef.IsNull()) return aGEOMObject._retn();
70
71   //Create the Fillet
72   Handle(GEOM_Object) anObject =
73     GetOperations()->MakeFilletAll(aShapeRef, theR);
74   if (!GetOperations()->IsDone() || anObject.IsNull())
75     return aGEOMObject._retn();
76
77   return GetObject(anObject);
78 }
79
80 //=============================================================================
81 /*!
82  *  MakeFilletEdges
83  */
84 //=============================================================================
85 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges
86                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
87                        const GEOM::ListOfLong& theEdges)
88 {
89   GEOM::GEOM_Object_var aGEOMObject;
90
91   //Get the reference shape
92   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
93   if (aShapeRef.IsNull()) return aGEOMObject._retn();
94
95   //Get the reference edges
96   int ind = 0;
97   int aLen = theEdges.length();
98   list<int> anEdges;
99   for (; ind < aLen; ind++) {
100     anEdges.push_back(theEdges[ind]);
101   }
102
103   //Create the Fillet
104   Handle(GEOM_Object) anObject =
105     GetOperations()->MakeFilletEdges(aShapeRef, theR, anEdges);
106   if (!GetOperations()->IsDone() || anObject.IsNull())
107     return aGEOMObject._retn();
108
109   return GetObject(anObject);
110 }
111
112 //=============================================================================
113 /*!
114  *  MakeFilletEdges R1 R2
115  */
116 //=============================================================================
117 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdgesR1R2
118                      (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
119                       CORBA::Double theR2, const GEOM::ListOfLong& theEdges)
120 {
121   GEOM::GEOM_Object_var aGEOMObject;
122
123   //Get the reference shape
124   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
125   if (aShapeRef.IsNull()) return aGEOMObject._retn();
126
127   //Get the reference edges
128   int ind = 0;
129   int aLen = theEdges.length();
130   list<int> anEdges;
131   for (; ind < aLen; ind++) {
132     anEdges.push_back(theEdges[ind]);
133   }
134
135   //Create the Fillet
136   Handle(GEOM_Object) anObject =
137     GetOperations()->MakeFilletEdgesR1R2(aShapeRef, theR1, theR2, anEdges);
138   if (!GetOperations()->IsDone() || anObject.IsNull())
139     return aGEOMObject._retn();
140
141   return GetObject(anObject);
142 }
143
144 //=============================================================================
145 /*!
146  *  MakeFilletFaces
147  */
148 //=============================================================================
149 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces
150                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
151                        const GEOM::ListOfLong& theFaces)
152 {
153   GEOM::GEOM_Object_var aGEOMObject;
154
155   //Get the reference shape
156   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
157   if (aShapeRef.IsNull()) return aGEOMObject._retn();
158
159   //Get the reference faces
160   int ind = 0;
161   int aLen = theFaces.length();
162   list<int> aFaces;
163   for (; ind < aLen; ind++) {
164     aFaces.push_back(theFaces[ind]);
165   }
166
167   //Create the Fillet
168   Handle(GEOM_Object) anObject =
169     GetOperations()->MakeFilletFaces(aShapeRef, theR, aFaces);
170   if (!GetOperations()->IsDone() || anObject.IsNull())
171     return aGEOMObject._retn();
172
173   return GetObject(anObject);
174 }
175
176 //=============================================================================
177 /*!
178  *  MakeFilletFaces R1 R2
179  */
180 //=============================================================================
181 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFacesR1R2
182                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1,
183                        CORBA::Double theR2, const GEOM::ListOfLong& theFaces)
184 {
185   GEOM::GEOM_Object_var aGEOMObject;
186
187   //Get the reference shape
188   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
189   if (aShapeRef.IsNull()) return aGEOMObject._retn();
190
191   //Get the reference faces
192   int ind = 0;
193   int aLen = theFaces.length();
194   list<int> aFaces;
195   for (; ind < aLen; ind++) {
196     aFaces.push_back(theFaces[ind]);
197   }
198
199   //Create the Fillet
200   Handle(GEOM_Object) anObject =
201     GetOperations()->MakeFilletFacesR1R2(aShapeRef, theR1, theR2, aFaces);
202   if (!GetOperations()->IsDone() || anObject.IsNull())
203     return aGEOMObject._retn();
204
205   return GetObject(anObject);
206 }
207
208 //=============================================================================
209 /*!
210  *  MakeFillet2D
211  */
212 //=============================================================================
213 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet2D
214                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
215                        const GEOM::ListOfLong& theVertexes)
216 {
217   GEOM::GEOM_Object_var aGEOMObject;
218
219   //Get the reference shape
220   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
221   if (aShapeRef.IsNull()) return aGEOMObject._retn();
222
223   //Get the reference vertex
224   int ind = 0;
225   int aLen = theVertexes.length();
226   list<int> aVertexes;
227   for (; ind < aLen; ind++) {
228     aVertexes.push_back(theVertexes[ind]);
229   }
230
231   //Create the Fillet
232   Handle(GEOM_Object) anObject =
233     GetOperations()->MakeFillet2D(aShapeRef, theR, aVertexes);
234   if (!GetOperations()->IsDone() || anObject.IsNull())
235     return aGEOMObject._retn();
236
237   return GetObject(anObject);
238 }
239
240 //=============================================================================
241 /*!
242  *  MakeFillet1D
243  */
244 //=============================================================================
245 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet1D
246                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR,
247                        const GEOM::ListOfLong& theVertexes)
248 {
249   GEOM::GEOM_Object_var aGEOMObject;
250
251   //Get the reference shape (wire)
252   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
253   if (aShapeRef.IsNull()) return aGEOMObject._retn();
254
255   //Get the reference vertex
256   int ind = 0;
257   int aLen = theVertexes.length();
258   list<int> aVertexes;
259   for (; ind < aLen; ind++) {
260     aVertexes.push_back(theVertexes[ind]);
261   }
262
263   //Create the Fillet
264   Handle(GEOM_Object) anObject =
265     GetOperations()->MakeFillet1D(aShapeRef, theR, aVertexes);
266   if (!GetOperations()->IsDone() || anObject.IsNull())
267     return aGEOMObject._retn();
268
269   return GetObject(anObject);
270 }
271
272 //=============================================================================
273 /*!
274  *  MakeChamferAll
275  */
276 //=============================================================================
277 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferAll
278                       (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD)
279 {
280   GEOM::GEOM_Object_var aGEOMObject;
281
282   //Get the reference shape
283   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
284   if (aShapeRef.IsNull()) return aGEOMObject._retn();
285
286   //Create the Chamfer
287   Handle(GEOM_Object) anObject =
288     GetOperations()->MakeChamferAll(aShapeRef, theD);
289   if (!GetOperations()->IsDone() || anObject.IsNull())
290     return aGEOMObject._retn();
291
292   return GetObject(anObject);
293 }
294
295 //=============================================================================
296 /*!
297  *  MakeChamferEdge
298  */
299 //=============================================================================
300 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge
301                       (GEOM::GEOM_Object_ptr theShape,
302                        CORBA::Double theD1, CORBA::Double theD2,
303                        CORBA::Long theFace1, CORBA::Long theFace2)
304 {
305   GEOM::GEOM_Object_var aGEOMObject;
306
307   //Get the reference shape
308   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
309   if (aShapeRef.IsNull()) return aGEOMObject._retn();
310
311   //Create the Chamfer
312   Handle(GEOM_Object) anObject =
313     GetOperations()->MakeChamferEdge(aShapeRef, theD1, theD2, theFace1, theFace2);
314   if (!GetOperations()->IsDone() || anObject.IsNull())
315     return aGEOMObject._retn();
316
317   return GetObject(anObject);
318 }
319 //=============================================================================
320 /*!
321  *  MakeChamferEdgeAD
322  */
323 //=============================================================================
324 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgeAD
325                       (GEOM::GEOM_Object_ptr theShape,
326                        CORBA::Double theD, CORBA::Double theAngle,
327                        CORBA::Long theFace1, CORBA::Long theFace2)
328 {
329   GEOM::GEOM_Object_var aGEOMObject;
330
331   //Get the reference shape
332   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
333   if (aShapeRef.IsNull()) return aGEOMObject._retn();
334
335   //Create the Chamfer
336   Handle(GEOM_Object) anObject =
337     GetOperations()->MakeChamferEdgeAD(aShapeRef, theD, theAngle, theFace1, theFace2);
338   if (!GetOperations()->IsDone() || anObject.IsNull())
339     return aGEOMObject._retn();
340
341   return GetObject(anObject);
342 }
343
344 //=============================================================================
345 /*!
346  *  MakeChamferFaces
347  */
348 //=============================================================================
349 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces
350                       (GEOM::GEOM_Object_ptr theShape,
351                        CORBA::Double theD1, CORBA::Double theD2,
352                        const GEOM::ListOfLong& theFaces)
353 {
354   GEOM::GEOM_Object_var aGEOMObject;
355
356   //Get the reference shape
357   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
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   //Get the reference shape
389   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
390   if (aShapeRef.IsNull()) return aGEOMObject._retn();
391
392   //Get the reference faces
393   int ind = 0;
394   int aLen = theFaces.length();
395   list<int> aFaces;
396   for (; ind < aLen; ind++) {
397     aFaces.push_back(theFaces[ind]);
398   }
399
400   //Create the Chamfer
401   Handle(GEOM_Object) anObject =
402     GetOperations()->MakeChamferFacesAD(aShapeRef, theD, theAngle, aFaces);
403   if (!GetOperations()->IsDone() || anObject.IsNull())
404     return aGEOMObject._retn();
405
406   return GetObject(anObject);
407 }
408
409 //=============================================================================
410 /*!
411  *  MakeChamferEdges
412  */
413 //=============================================================================
414 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdges
415                       (GEOM::GEOM_Object_ptr theShape,
416                        CORBA::Double theD1, CORBA::Double theD2,
417                        const GEOM::ListOfLong& theEdges)
418 {
419   GEOM::GEOM_Object_var aGEOMObject;
420
421   //Get the reference shape
422   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
423   if (aShapeRef.IsNull()) return aGEOMObject._retn();
424
425   //Get the reference edges
426   int ind = 0;
427   int aLen = theEdges.length();
428   list<int> aEdges;
429   for (; ind < aLen; ind++) {
430     aEdges.push_back(theEdges[ind]);
431   }
432
433   //Create the Chamfer
434   Handle(GEOM_Object) anObject =
435     GetOperations()->MakeChamferEdges(aShapeRef, theD1, theD2, aEdges);
436   if (!GetOperations()->IsDone() || anObject.IsNull())
437     return aGEOMObject._retn();
438
439   return GetObject(anObject);
440 }
441
442 //=============================================================================
443 /*!
444  *  MakeChamferEdgesAD
445  */
446 //=============================================================================
447 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdgesAD
448                       (GEOM::GEOM_Object_ptr theShape,
449                        CORBA::Double theD, CORBA::Double theAngle,
450                        const GEOM::ListOfLong& theEdges)
451 {
452   GEOM::GEOM_Object_var aGEOMObject;
453
454   //Get the reference shape
455   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
456   if (aShapeRef.IsNull()) return aGEOMObject._retn();
457
458   //Get the reference edges
459   int ind = 0;
460   int aLen = theEdges.length();
461   list<int> aEdges;
462   for (; ind < aLen; ind++) {
463     aEdges.push_back(theEdges[ind]);
464   }
465
466   //Create the Chamfer
467   Handle(GEOM_Object) anObject =
468     GetOperations()->MakeChamferEdgesAD(aShapeRef, theD, theAngle, aEdges);
469   if (!GetOperations()->IsDone() || anObject.IsNull())
470     return aGEOMObject._retn();
471
472   return GetObject(anObject);
473 }
474
475 //=============================================================================
476 /*!
477  *  MakeArchimede
478  */
479 //=============================================================================
480 GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape,
481                                                               CORBA::Double theWeight,
482                                                               CORBA::Double theWaterDensity,
483                                                               CORBA::Double theMeshingDeflection)
484 {
485   GEOM::GEOM_Object_var aGEOMObject;
486
487   //Get the reference shape
488   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
489   if (aShapeRef.IsNull()) return aGEOMObject._retn();
490
491   //Create the Archimede
492   Handle(GEOM_Object) anObject = GetOperations()->MakeArchimede
493     (aShapeRef, theWeight, theWaterDensity, theMeshingDeflection);
494   if (!GetOperations()->IsDone() || anObject.IsNull())
495     return aGEOMObject._retn();
496
497   return GetObject(anObject);
498 }
499
500 //=============================================================================
501 /*!
502  *  GetSubShapeIndex
503  */
504 //=============================================================================
505 CORBA::Long GEOM_ILocalOperations_i::GetSubShapeIndex
506   (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr theSubShape)
507 {
508   //Get the reference shapes
509   Handle(GEOM_Object) aShapeRef = GetObjectImpl(theShape);
510   Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
511   if (aShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
512
513   //Get the unique ID of <theSubShape> inside <theShape>
514   CORBA::Long anID = GetOperations()->GetSubShapeIndex(aShapeRef, aSubShapeRef);
515   if (!GetOperations()->IsDone())
516     return -1;
517
518   return anID;
519 }