Salome HOME
Update copyrights 2014.
[modules/geom.git] / src / GEOM_I / GEOM_I3DPrimOperations_i.cc
1 // Copyright (C) 2007-2014  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, or (at your option) any later version.
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_I3DPrimOperations_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 #define SUBSHAPE_ERROR "Sub shape cannot be transformed"
35
36 //=============================================================================
37 /*!
38  *   constructor:
39  */
40 //=============================================================================
41 GEOM_I3DPrimOperations_i::GEOM_I3DPrimOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_I3DPrimOperations* theImpl)
42 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
43 {
44   MESSAGE("GEOM_I3DPrimOperations_i::GEOM_I3DPrimOperations_i");
45 }
46
47 //=============================================================================
48 /*!
49  *  destructor
50  */
51 //=============================================================================
52 GEOM_I3DPrimOperations_i::~GEOM_I3DPrimOperations_i()
53 {
54   MESSAGE("GEOM_I3DPrimOperations_i::~GEOM_I3DPrimOperations_i");
55 }
56
57
58 //=============================================================================
59 /*!
60  *  MakeBoxDXDYDZ
61  */
62 //=============================================================================
63 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxDXDYDZ (CORBA::Double theDX,
64                                                                CORBA::Double theDY,
65                                                                CORBA::Double theDZ)
66 {
67   GEOM::GEOM_Object_var aGEOMObject;
68
69   //Set a not done flag
70   GetOperations()->SetNotDone();
71
72   //Create the Box
73   Handle(GEOM_Object) anObject = GetOperations()->MakeBoxDXDYDZ(theDX, theDY, theDZ);
74   if (!GetOperations()->IsDone() || anObject.IsNull())
75     return aGEOMObject._retn();
76
77   return GetObject(anObject);
78 }
79
80 //=============================================================================
81 /*!
82  *  MakeBoxTwoPnt
83  */
84 //=============================================================================
85 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxTwoPnt
86                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
87 {
88   GEOM::GEOM_Object_var aGEOMObject;
89
90   //Set a not done flag
91   GetOperations()->SetNotDone();
92
93   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
94   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
95
96   if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
97
98   //Create the Box
99   Handle(GEOM_Object) anObject = GetOperations()->MakeBoxTwoPnt(aPnt1, aPnt2);
100   if (!GetOperations()->IsDone() || anObject.IsNull())
101     return aGEOMObject._retn();
102
103   return GetObject(anObject);
104 }
105
106 //=============================================================================
107 /*!
108  *  MakeFaceHW
109  */
110 //=============================================================================
111 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceHW (CORBA::Double theH,
112                                                             CORBA::Double theW,
113                                                             CORBA::Short  theOrientation)
114 {
115   GEOM::GEOM_Object_var aGEOMObject;
116
117   //Set a not done flag
118   GetOperations()->SetNotDone();
119
120   if (theH == 0 || theW == 0)
121     return aGEOMObject._retn();
122
123   //Create the Face
124   Handle(GEOM_Object) anObject = GetOperations()->MakeFaceHW(theH, theW, theOrientation);
125   if (!GetOperations()->IsDone() || anObject.IsNull())
126     return aGEOMObject._retn();
127
128   return GetObject(anObject);
129 }
130
131 //=============================================================================
132 /*!
133  *  MakeFaceObjHW
134  */
135 //=============================================================================
136 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceObjHW
137                                                (GEOM::GEOM_Object_ptr theObj,
138                                                 CORBA::Double theH,
139                                                 CORBA::Double theW)
140 {
141   GEOM::GEOM_Object_var aGEOMObject;
142
143   //Set a not done flag
144   GetOperations()->SetNotDone();
145
146   //Get the reference object
147   Handle(GEOM_Object) anObj = GetObjectImpl(theObj);
148
149   if (anObj.IsNull())
150     return aGEOMObject._retn();
151
152   //Create the Face
153   Handle(GEOM_Object) anObject = GetOperations()->MakeFaceObjHW(anObj, theH, theW);
154   if (!GetOperations()->IsDone() || anObject.IsNull())
155     return aGEOMObject._retn();
156
157   return GetObject(anObject);
158 }
159
160 //=============================================================================
161 /*!
162  *  MakeDiskPntVecR
163  */
164 //=============================================================================
165 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDiskPntVecR
166                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
167                        CORBA::Double theR)
168 {
169   GEOM::GEOM_Object_var aGEOMObject;
170
171   //Set a not done flag
172   GetOperations()->SetNotDone();
173
174   //Get the reference points
175   Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
176   Handle(GEOM_Object) aVec = GetObjectImpl(theVec);
177
178   if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
179
180   // Make Disk
181   Handle(GEOM_Object) anObject =
182     GetOperations()->MakeDiskPntVecR(aPnt, aVec, theR);
183   if (!GetOperations()->IsDone() || anObject.IsNull())
184     return aGEOMObject._retn();
185
186   return GetObject(anObject);
187 }
188
189 //=============================================================================
190 /*!
191  *  MakeDiskThreePnt
192  */
193 //=============================================================================
194 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDiskThreePnt
195                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
196                        GEOM::GEOM_Object_ptr thePnt3)
197 {
198   GEOM::GEOM_Object_var aGEOMObject;
199
200   //Set a not done flag
201   GetOperations()->SetNotDone();
202
203   //Get the reference points
204   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
205   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
206   Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
207
208   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
209
210   // Make Disk
211   Handle(GEOM_Object) anObject =
212       GetOperations()->MakeDiskThreePnt(aPnt1, aPnt2, aPnt3);
213   if (!GetOperations()->IsDone() || anObject.IsNull())
214     return aGEOMObject._retn();
215
216   return GetObject(anObject);
217 }
218
219 //=============================================================================
220 /*!
221  *  MakeDiskR
222  */
223 //=============================================================================
224 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDiskR (CORBA::Double theR,
225                                                            CORBA::Short  theOrientation)
226 {
227   GEOM::GEOM_Object_var aGEOMObject;
228
229   //Set a not done flag
230   GetOperations()->SetNotDone();
231
232   if (theR == 0)
233     return aGEOMObject._retn();
234
235   //Create the Face
236   Handle(GEOM_Object) anObject = GetOperations()->MakeDiskR(theR, theOrientation);
237   if (!GetOperations()->IsDone() || anObject.IsNull())
238     return aGEOMObject._retn();
239
240   return GetObject(anObject);
241 }
242
243 //=============================================================================
244 /*!
245  *  MakeCylinderRH
246  */
247 //=============================================================================
248 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double theR,
249                                                                 CORBA::Double theH)
250 {
251   GEOM::GEOM_Object_var aGEOMObject;
252
253   //Set a not done flag
254   GetOperations()->SetNotDone();
255
256   //Create the Cylinder
257   Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderRH(theR, theH);
258   if (!GetOperations()->IsDone() || anObject.IsNull())
259     return aGEOMObject._retn();
260
261   return GetObject(anObject);
262 }
263
264 //=============================================================================
265 /*!
266  *  MakeCylinderPntVecRH
267  */
268 //=============================================================================
269 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH
270                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
271                        CORBA::Double theR, CORBA::Double theH)
272 {
273   GEOM::GEOM_Object_var aGEOMObject;
274
275   //Set a not done flag
276   GetOperations()->SetNotDone();
277
278   //Get the reference points
279   Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
280   Handle(GEOM_Object) aVec = GetObjectImpl(theVec);
281
282   if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
283
284   //Create the Cylinder
285   Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderPntVecRH(aPnt, aVec, theR, theH);
286   if (!GetOperations()->IsDone() || anObject.IsNull())
287     return aGEOMObject._retn();
288
289   return GetObject(anObject);
290 }
291
292 //=============================================================================
293 /*!
294  *  MakeConeR1R2H
295  */
296 //=============================================================================
297 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeConeR1R2H (CORBA::Double theR1,
298                                                                CORBA::Double theR2,
299                                                                CORBA::Double theH)
300 {
301   GEOM::GEOM_Object_var aGEOMObject;
302
303   //Set a not done flag
304   GetOperations()->SetNotDone();
305
306   //Create the Cone
307   Handle(GEOM_Object) anObject = GetOperations()->MakeConeR1R2H(theR1, theR2, theH);
308   if (!GetOperations()->IsDone() || anObject.IsNull())
309     return aGEOMObject._retn();
310
311   return GetObject(anObject);
312 }
313
314 //=============================================================================
315 /*!
316  *  MakeConePntVecR1R2H
317  */
318 //=============================================================================
319 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeConePntVecR1R2H
320                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
321                        CORBA::Double theR1, CORBA::Double theR2, CORBA::Double theH)
322 {
323   GEOM::GEOM_Object_var aGEOMObject;
324
325   //Set a not done flag
326   GetOperations()->SetNotDone();
327
328   //Get the reference points
329   Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
330   Handle(GEOM_Object) aVec = GetObjectImpl(theVec);
331
332   if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
333
334   //Create the Cone
335   Handle(GEOM_Object) anObject =
336       GetOperations()->MakeConePntVecR1R2H(aPnt, aVec, theR1, theR2, theH);
337   if (!GetOperations()->IsDone() || anObject.IsNull())
338     return aGEOMObject._retn();
339
340   return GetObject(anObject);
341 }
342
343 //=============================================================================
344 /*!
345  *  MakeSphereR
346  */
347 //=============================================================================
348 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeSphereR (CORBA::Double theR)
349 {
350   GEOM::GEOM_Object_var aGEOMObject;
351
352   //Set a not done flag
353   GetOperations()->SetNotDone();
354
355   //Create the Cone
356   Handle(GEOM_Object) anObject = GetOperations()->MakeSphereR(theR);
357   if (!GetOperations()->IsDone() || anObject.IsNull())
358     return aGEOMObject._retn();
359
360   return GetObject(anObject);
361 }
362
363 //=============================================================================
364 /*!
365  *  MakeSpherePntR
366  */
367 //=============================================================================
368 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeSpherePntR
369                       (GEOM::GEOM_Object_ptr thePnt, CORBA::Double theR)
370 {
371   GEOM::GEOM_Object_var aGEOMObject;
372
373   //Set a not done flag
374   GetOperations()->SetNotDone();
375
376   //Get the reference point
377   Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
378
379   if (aPnt.IsNull()) return aGEOMObject._retn();
380
381   //Create the Sphere
382   Handle(GEOM_Object) anObject =
383     GetOperations()->MakeSpherePntR(aPnt, theR);
384   if (!GetOperations()->IsDone() || anObject.IsNull())
385     return aGEOMObject._retn();
386
387   return GetObject(anObject);
388 }
389
390 //=============================================================================
391 /*!
392  *  MakeTorusRR
393  */
394 //=============================================================================
395 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeTorusRR
396                       (CORBA::Double theRMajor, CORBA::Double theRMinor)
397 {
398   GEOM::GEOM_Object_var aGEOMObject;
399
400   //Set a not done flag
401   GetOperations()->SetNotDone();
402
403   // Make Torus
404   Handle(GEOM_Object) anObject =
405     GetOperations()->MakeTorusRR(theRMajor, theRMinor);
406   if (!GetOperations()->IsDone() || anObject.IsNull())
407     return aGEOMObject._retn();
408
409   return GetObject(anObject);
410 }
411
412 //=============================================================================
413 /*!
414  *  MakeTorusPntVecRR
415  */
416 //=============================================================================
417 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeTorusPntVecRR
418                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
419                        CORBA::Double theRMajor, CORBA::Double theRMinor)
420 {
421   GEOM::GEOM_Object_var aGEOMObject;
422
423   //Set a not done flag
424   GetOperations()->SetNotDone();
425
426   //Get the reference points
427   Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
428   Handle(GEOM_Object) aVec = GetObjectImpl(theVec);
429
430   if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
431
432   // Make Torus
433   Handle(GEOM_Object) anObject =
434     GetOperations()->MakeTorusPntVecRR(aPnt, aVec, theRMajor, theRMinor);
435   if (!GetOperations()->IsDone() || anObject.IsNull())
436     return aGEOMObject._retn();
437
438   return GetObject(anObject);
439 }
440
441 //=============================================================================
442 /*!
443  *  MakePrismVecH
444  */
445 //=============================================================================
446 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismVecH
447                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theVec,
448                        CORBA::Double theH)
449 {
450   GEOM::GEOM_Object_var aGEOMObject;
451
452   //Set a not done flag
453   GetOperations()->SetNotDone();
454
455   //Get the reference objects
456   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
457   Handle(GEOM_Object) aVec = GetObjectImpl(theVec);
458
459   if (aBase.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
460
461   //Create the Prism
462   Handle(GEOM_Object) anObject =
463     GetOperations()->MakePrismVecH(aBase, aVec, theH);
464   if (!GetOperations()->IsDone() || anObject.IsNull())
465     return aGEOMObject._retn();
466
467   return GetObject(anObject);
468 }
469
470 //=============================================================================
471 /*!
472  *  MakePrismVecH2Ways
473  */
474 //=============================================================================
475 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismVecH2Ways
476                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theVec,
477                        CORBA::Double theH)
478 {
479   GEOM::GEOM_Object_var aGEOMObject;
480
481   //Set a not done flag
482   GetOperations()->SetNotDone();
483
484   //Get the reference objects
485   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
486   Handle(GEOM_Object) aVec = GetObjectImpl(theVec);
487
488   if (aBase.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
489
490   //Create the Prism
491   Handle(GEOM_Object) anObject =
492       GetOperations()->MakePrismVecH2Ways(aBase, aVec, theH);
493   if (!GetOperations()->IsDone() || anObject.IsNull())
494     return aGEOMObject._retn();
495
496   return GetObject(anObject);
497 }
498
499 //=============================================================================
500 /*!
501  *  MakePrismVecH
502  */
503 //=============================================================================
504 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismVecHWithScaling
505                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theVec,
506                        CORBA::Double theH, CORBA::Double theScaleFactor)
507 {
508   GEOM::GEOM_Object_var aGEOMObject;
509
510   //Set a not done flag
511   GetOperations()->SetNotDone();
512
513   //Get the reference objects
514   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
515   Handle(GEOM_Object) aVec = GetObjectImpl(theVec);
516
517   if (aBase.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
518
519   //Create the Prism
520   Handle(GEOM_Object) anObject =
521     GetOperations()->MakePrismVecH(aBase, aVec, theH, theScaleFactor);
522   if (!GetOperations()->IsDone() || anObject.IsNull())
523     return aGEOMObject._retn();
524
525   return GetObject(anObject);
526 }
527
528 //=============================================================================
529 /*!
530  *  MakePrismTwoPnt
531  */
532 //=============================================================================
533 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismTwoPnt
534                                              (GEOM::GEOM_Object_ptr theBase,
535                                               GEOM::GEOM_Object_ptr thePoint1,
536                                               GEOM::GEOM_Object_ptr thePoint2)
537 {
538   GEOM::GEOM_Object_var aGEOMObject;
539
540   //Set a not done flag
541   GetOperations()->SetNotDone();
542
543   //Get the reference objects
544   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
545   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
546   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
547
548   if (aBase.IsNull() || aPoint1.IsNull() || aPoint2.IsNull())
549     return aGEOMObject._retn();
550
551   //Create the Prism
552   Handle(GEOM_Object) anObject =
553     GetOperations()->MakePrismTwoPnt(aBase, aPoint1, aPoint2);
554   if (!GetOperations()->IsDone() || anObject.IsNull())
555     return aGEOMObject._retn();
556
557   return GetObject(anObject);
558 }
559
560 //=============================================================================
561 /*!
562  *  MakePrismTwoPnt2Ways
563  */
564 //=============================================================================
565 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismTwoPnt2Ways
566                                              (GEOM::GEOM_Object_ptr theBase,
567                                               GEOM::GEOM_Object_ptr thePoint1,
568                                               GEOM::GEOM_Object_ptr thePoint2)
569 {
570   GEOM::GEOM_Object_var aGEOMObject;
571
572   //Set a not done flag
573   GetOperations()->SetNotDone();
574
575   //Get the reference objects
576   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
577   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
578   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
579
580   if (aBase.IsNull() || aPoint1.IsNull() || aPoint2.IsNull())
581     return aGEOMObject._retn();
582
583   //Create the Prism
584   Handle(GEOM_Object) anObject =
585     GetOperations()->MakePrismTwoPnt2Ways(aBase, aPoint1, aPoint2);
586   if (!GetOperations()->IsDone() || anObject.IsNull())
587     return aGEOMObject._retn();
588
589   return GetObject(anObject);
590 }
591
592 //=============================================================================
593 /*!
594  *  MakePrismTwoPnt
595  */
596 //=============================================================================
597 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismTwoPntWithScaling
598                                              (GEOM::GEOM_Object_ptr theBase,
599                                               GEOM::GEOM_Object_ptr thePoint1,
600                                               GEOM::GEOM_Object_ptr thePoint2,
601                                               CORBA::Double         theScaleFactor)
602 {
603   GEOM::GEOM_Object_var aGEOMObject;
604
605   //Set a not done flag
606   GetOperations()->SetNotDone();
607
608   //Get the reference objects
609   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
610   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
611   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
612
613   if (aBase.IsNull() || aPoint1.IsNull() || aPoint2.IsNull())
614     return aGEOMObject._retn();
615
616   //Create the Prism
617   Handle(GEOM_Object) anObject =
618     GetOperations()->MakePrismTwoPnt(aBase, aPoint1, aPoint2, theScaleFactor);
619   if (!GetOperations()->IsDone() || anObject.IsNull())
620     return aGEOMObject._retn();
621
622   return GetObject(anObject);
623 }
624
625 //=============================================================================
626 /*!
627  *  MakePrismDXDYDZ
628  */
629 //=============================================================================
630 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismDXDYDZ
631                       (GEOM::GEOM_Object_ptr theBase, CORBA::Double theDX,
632                        CORBA::Double theDY, CORBA::Double theDZ)
633 {
634   GEOM::GEOM_Object_var aGEOMObject;
635
636   //Set a not done flag
637   GetOperations()->SetNotDone();
638
639   //Get the reference objects
640   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
641
642   if (aBase.IsNull()) return aGEOMObject._retn();
643
644   //Create the Prism
645   Handle(GEOM_Object) anObject =
646       GetOperations()->MakePrismDXDYDZ(aBase, theDX, theDY, theDZ);
647   if (!GetOperations()->IsDone() || anObject.IsNull())
648     return aGEOMObject._retn();
649
650   return GetObject(anObject);
651 }
652
653 //=============================================================================
654 /*!
655  *  MakePrismDXDYDZ2Ways
656  */
657 //=============================================================================
658 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismDXDYDZ2Ways
659                       (GEOM::GEOM_Object_ptr theBase, CORBA::Double theDX,
660                        CORBA::Double theDY, CORBA::Double theDZ)
661 {
662   GEOM::GEOM_Object_var aGEOMObject;
663
664   //Set a not done flag
665   GetOperations()->SetNotDone();
666
667   //Get the reference objects
668   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
669
670   if (aBase.IsNull()) return aGEOMObject._retn();
671
672   //Create the Prism
673   Handle(GEOM_Object) anObject =
674       GetOperations()->MakePrismDXDYDZ2Ways(aBase, theDX, theDY, theDZ);
675   if (!GetOperations()->IsDone() || anObject.IsNull())
676     return aGEOMObject._retn();
677
678   return GetObject(anObject);
679 }
680
681 //=============================================================================
682 /*!
683  *  MakePrismDXDYDZ
684  */
685 //=============================================================================
686 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismDXDYDZWithScaling
687                       (GEOM::GEOM_Object_ptr theBase, CORBA::Double theDX,
688                        CORBA::Double theDY, CORBA::Double theDZ,
689                        CORBA::Double theScaleFactor)
690 {
691   GEOM::GEOM_Object_var aGEOMObject;
692
693   //Set a not done flag
694   GetOperations()->SetNotDone();
695
696   //Get the reference objects
697   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
698
699   if (aBase.IsNull()) return aGEOMObject._retn();
700
701   //Create the Prism
702   Handle(GEOM_Object) anObject =
703     GetOperations()->MakePrismDXDYDZ(aBase, theDX, theDY, theDZ, theScaleFactor);
704   if (!GetOperations()->IsDone() || anObject.IsNull())
705     return aGEOMObject._retn();
706
707   return GetObject(anObject);
708 }
709
710 //=============================================================================
711 /*!
712  *  MakeDraftPrism
713  */
714 //=============================================================================
715 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDraftPrism
716                       (GEOM::GEOM_Object_ptr theInitShape, GEOM::GEOM_Object_ptr theBase, 
717                        CORBA::Double  theHeight,
718                        CORBA::Double  theAngle,
719                        CORBA::Boolean theFuse)
720 {
721   GEOM::GEOM_Object_var aGEOMObject;
722   
723   //Set a not done flag
724   GetOperations()->SetNotDone();
725
726   //Get the reference objects
727   Handle(GEOM_Object) aInit   = GetObjectImpl(theInitShape);
728   Handle(GEOM_Object) aBase   = GetObjectImpl(theBase);
729
730   if (aBase.IsNull() || aInit.IsNull()) return aGEOMObject._retn();
731
732   //Create the Prism
733   Handle(GEOM_Object) anObject = GetOperations()->MakeDraftPrism(aInit, aBase, theHeight, theAngle, theFuse);
734  
735   if (!GetOperations()->IsDone() || anObject.IsNull())
736     return aGEOMObject._retn();
737
738   return GetObject(anObject);
739 }
740
741 //=============================================================================
742 /*!
743  *  MakePipe
744  */
745 //=============================================================================
746 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipe
747                  (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePath)
748 {
749   GEOM::GEOM_Object_var aGEOMObject;
750
751   //Set a not done flag
752   GetOperations()->SetNotDone();
753
754   //Get the reference objects
755   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
756   Handle(GEOM_Object) aPath = GetObjectImpl(thePath);
757
758   if (aBase.IsNull() || aPath.IsNull()) return aGEOMObject._retn();
759
760   //Create the Pipe
761   Handle(GEOM_Object) anObject =
762     GetOperations()->MakePipe(aBase, aPath);
763   if (!GetOperations()->IsDone() || anObject.IsNull())
764     return aGEOMObject._retn();
765
766   return GetObject(anObject);
767 }
768
769 //=============================================================================
770 /*!
771  *  MakeRevolutionAxisAngle
772  */
773 //=============================================================================
774 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle
775                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theAxis,
776                        CORBA::Double theAngle)
777 {
778   GEOM::GEOM_Object_var aGEOMObject;
779
780   //Set a not done flag
781   GetOperations()->SetNotDone();
782
783   //Get the reference objects
784   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
785   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
786
787   if (aBase.IsNull() || anAxis.IsNull()) return aGEOMObject._retn();
788
789   //Create the Revolution
790   Handle(GEOM_Object) anObject =
791       GetOperations()->MakeRevolutionAxisAngle(aBase, anAxis, theAngle);
792   if (!GetOperations()->IsDone() || anObject.IsNull())
793     return aGEOMObject._retn();
794
795   return GetObject(anObject);
796 }
797
798 //=============================================================================
799 /*!
800  *  MakeRevolutionAxisAngle2Ways
801  */
802 //=============================================================================
803 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle2Ways
804                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theAxis,
805                        CORBA::Double theAngle)
806 {
807   GEOM::GEOM_Object_var aGEOMObject;
808
809   //Set a not done flag
810   GetOperations()->SetNotDone();
811
812   //Get the reference objects
813   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
814   Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
815
816   if (aBase.IsNull() || anAxis.IsNull()) return aGEOMObject._retn();
817
818   //Create the Revolution
819   Handle(GEOM_Object) anObject =
820       GetOperations()->MakeRevolutionAxisAngle2Ways(aBase, anAxis, theAngle);
821   if (!GetOperations()->IsDone() || anObject.IsNull())
822     return aGEOMObject._retn();
823
824   return GetObject(anObject);
825 }
826
827 //=============================================================================
828 /*!
829  *  MakeFilling
830  */
831 //=============================================================================
832 GEOM::GEOM_Object_ptr
833 GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_ptr theShape,
834                                       CORBA::Long theMinDeg,
835                                       CORBA::Long theMaxDeg,
836                                       CORBA::Double theTol2D,
837                                       CORBA::Double theTol3D,
838                                       CORBA::Long theNbIter,
839                                       GEOM::filling_oper_method theMethod,
840                                       CORBA::Boolean theApprox)
841 {
842   GEOM::GEOM_Object_var aGEOMObject;
843
844   //Set a not done flag
845   GetOperations()->SetNotDone();
846
847   //Get the reference objects
848   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
849
850   if (aShape.IsNull()) return aGEOMObject._retn();
851
852   int aMethod = 0;
853   switch (theMethod) {
854   case GEOM::FOM_Default:
855     {
856       // Default (standard behaviour)
857       aMethod = 0;
858     }
859     break;
860   case GEOM::FOM_UseOri:
861     {
862       // Use edges orientation
863       aMethod = 1;
864     }
865     break;
866   case GEOM::FOM_AutoCorrect:
867     {
868       // Auto-correct edges orientation
869       aMethod = 2;
870     }
871     break;
872   default:
873     {}
874   }
875
876   //Create the Solid
877   Handle(GEOM_Object) anObject = GetOperations()->MakeFilling
878     (aShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter,
879      aMethod, theApprox);
880   if (!GetOperations()->IsDone() || anObject.IsNull())
881     return aGEOMObject._retn();
882
883   return GetObject(anObject);
884 }
885
886 //=============================================================================
887 /*!
888  *  MakeThruSections
889  */
890 //=============================================================================
891 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeThruSections(const GEOM::ListOfGO& theSeqSections,
892                                                                  CORBA::Boolean theModeSolid,
893                                                                  CORBA::Double thePreci,
894                                                                  CORBA::Boolean theRuled)
895 {
896    GEOM::GEOM_Object_var aGEOMObject;
897
898   //Set a not done flag
899   GetOperations()->SetNotDone();
900   Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
901   int ind, aLen;
902
903   //Get the shapes
904   aLen = theSeqSections.length();
905   for (ind = 0; ind < aLen; ind++) {
906     Handle(GEOM_Object) aSh = GetObjectImpl(theSeqSections[ind]);
907     if (!aSh.IsNull())
908       aSeqSections->Append(aSh);
909   }
910   if (!aSeqSections->Length())
911     return aGEOMObject._retn();
912
913   // Make shell or solid
914   Handle(GEOM_Object) anObject =
915     GetOperations()->MakeThruSections(aSeqSections,theModeSolid,thePreci,theRuled);
916   if (!GetOperations()->IsDone() || anObject.IsNull())
917     return aGEOMObject._retn();
918
919   return GetObject(anObject);
920 }
921
922 //=============================================================================
923 /*!
924  *  MakePipeWithDifferentSections
925  */
926 //=============================================================================
927 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeWithDifferentSections
928                       (const GEOM::ListOfGO& theBases,
929                        const GEOM::ListOfGO& theLocations,
930                        GEOM::GEOM_Object_ptr thePath,
931                        CORBA::Boolean theWithContact,
932                        CORBA::Boolean theWithCorrections)
933 {
934   GEOM::GEOM_Object_var aGEOMObject;
935
936   //Set a not done flag
937   GetOperations()->SetNotDone();
938   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
939   Handle(TColStd_HSequenceOfTransient) aSeqLocations = new TColStd_HSequenceOfTransient;
940   int ind=0, aNbBases =0,aNbLocs=0;
941
942   //Get the shapes
943   aNbBases = theBases.length();
944   aNbLocs = theLocations.length();
945
946   if (aNbLocs && aNbBases != aNbLocs)
947     return aGEOMObject._retn();
948
949   Handle(GEOM_Object) aPath = GetObjectImpl(thePath);
950   if (aPath.IsNull())
951     return aGEOMObject._retn();
952
953   for (ind = 0; ind < aNbBases; ind++) {
954     Handle(GEOM_Object) aBase = GetObjectImpl(theBases[ind]);
955     if (aBase.IsNull())
956       continue;
957     if (aNbLocs)
958     {
959       Handle(GEOM_Object) aLoc = GetObjectImpl(theLocations[ind]);
960       if (aLoc.IsNull())
961         continue;
962       aSeqLocations->Append(aLoc);
963     }
964     aSeqBases->Append(aBase);
965   }
966   if (!aSeqBases->Length())
967     return aGEOMObject._retn();
968
969   // Make pipe
970   Handle(GEOM_Object) anObject =
971     GetOperations()->MakePipeWithDifferentSections(aSeqBases,aSeqLocations ,aPath,
972                                                    theWithContact,theWithCorrections);
973   if (!GetOperations()->IsDone() || anObject.IsNull())
974     return aGEOMObject._retn();
975
976   return GetObject(anObject);
977 }
978
979
980 //=============================================================================
981 /*!
982  *  MakePipeWithShellSections
983  */
984 //=============================================================================
985 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeWithShellSections
986                  (const GEOM::ListOfGO& theBases,
987                   const GEOM::ListOfGO& theSubBases,
988                   const GEOM::ListOfGO& theLocations,
989                   GEOM::GEOM_Object_ptr thePath,
990                   CORBA::Boolean theWithContact,
991                   CORBA::Boolean theWithCorrections)
992 {
993   GEOM::GEOM_Object_var aGEOMObject;
994
995   //Set a not done flag
996   GetOperations()->SetNotDone();
997   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
998   Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
999   Handle(TColStd_HSequenceOfTransient) aSeqLocations = new TColStd_HSequenceOfTransient;
1000   int ind=0, aNbBases=0, aNbSubBases=0, aNbLocs=0;
1001
1002   //Get the shapes
1003   aNbBases = theBases.length();
1004   aNbSubBases = theSubBases.length();
1005   aNbLocs = theLocations.length();
1006
1007   if (aNbLocs && aNbBases != aNbLocs)
1008     return aGEOMObject._retn();
1009
1010   Handle(GEOM_Object) aPath = GetObjectImpl(thePath);
1011   if (aPath.IsNull())
1012     return aGEOMObject._retn();
1013
1014   for (ind = 0; ind < aNbBases; ind++) {
1015     Handle(GEOM_Object) aBase = GetObjectImpl(theBases[ind]);
1016     if (aBase.IsNull())
1017       continue;
1018     if (aNbLocs) {
1019       Handle(GEOM_Object) aLoc = GetObjectImpl(theLocations[ind]);
1020       if (aLoc.IsNull())
1021         continue;
1022       aSeqLocations->Append(aLoc);
1023     }
1024     aSeqBases->Append(aBase);
1025
1026     if (aNbSubBases >= aNbBases) {
1027       Handle(GEOM_Object) aSubBase = GetObjectImpl(theSubBases[ind]);
1028       if (aSubBase.IsNull()) {
1029         aSeqSubBases->Clear();
1030         aNbSubBases = 0;
1031         continue;
1032       }
1033       aSeqSubBases->Append(aSubBase);
1034     }
1035   }
1036   if (!aSeqBases->Length())
1037     return aGEOMObject._retn();
1038
1039   // Make pipe
1040   Handle(GEOM_Object) anObject =
1041     GetOperations()->MakePipeWithShellSections(aSeqBases, aSeqSubBases,
1042                                                aSeqLocations, aPath,
1043                                                theWithContact, theWithCorrections);
1044   if (!GetOperations()->IsDone() || anObject.IsNull())
1045     return aGEOMObject._retn();
1046
1047   return GetObject(anObject);
1048 }
1049
1050
1051 //=============================================================================
1052 /*!
1053  *  MakePipeShellsWithoutPath
1054  */
1055 //=============================================================================
1056 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeShellsWithoutPath
1057                  (const GEOM::ListOfGO& theBases,
1058                   const GEOM::ListOfGO& theLocations)
1059 {
1060   GEOM::GEOM_Object_var aGEOMObject;
1061
1062   //Set a not done flag
1063   GetOperations()->SetNotDone();
1064   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1065   Handle(TColStd_HSequenceOfTransient) aSeqLocations = new TColStd_HSequenceOfTransient;
1066   int ind=0, aNbBases=0, aNbLocs=0;
1067
1068   //Get the shapes
1069   aNbBases = theBases.length();
1070   aNbLocs = theLocations.length();
1071
1072   if (aNbLocs && aNbBases != aNbLocs)
1073     return aGEOMObject._retn();
1074
1075   for (ind = 0; ind < aNbBases; ind++) {
1076     Handle(GEOM_Object) aBase = GetObjectImpl(theBases[ind]);
1077     if (aBase.IsNull())
1078       continue;
1079     if (aNbLocs) {
1080       Handle(GEOM_Object) aLoc = GetObjectImpl(theLocations[ind]);
1081       if (aLoc.IsNull())
1082         continue;
1083       aSeqLocations->Append(aLoc);
1084     }
1085     aSeqBases->Append(aBase);
1086   }
1087
1088   if (!aSeqBases->Length())
1089     return aGEOMObject._retn();
1090
1091   // Make pipe
1092   Handle(GEOM_Object) anObject =
1093     GetOperations()->MakePipeShellsWithoutPath(aSeqBases,aSeqLocations);
1094
1095   if (!GetOperations()->IsDone() || anObject.IsNull())
1096     return aGEOMObject._retn();
1097
1098   return GetObject(anObject);
1099 }
1100
1101 //=============================================================================
1102 /*!
1103  *  MakePipeBiNormalAlongVector
1104  */
1105 //=============================================================================
1106 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipeBiNormalAlongVector
1107                  (GEOM::GEOM_Object_ptr theBase,
1108                   GEOM::GEOM_Object_ptr thePath,
1109                   GEOM::GEOM_Object_ptr theVec)
1110 {
1111   GEOM::GEOM_Object_var aGEOMObject;
1112
1113   //Set a not done flag
1114   GetOperations()->SetNotDone();
1115
1116   //Get the reference objects
1117   Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
1118   Handle(GEOM_Object) aPath = GetObjectImpl(thePath);
1119   Handle(GEOM_Object) aVec = GetObjectImpl(theVec);
1120
1121   if (aBase.IsNull() || aPath.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
1122
1123   //Create the Pipe
1124   Handle(GEOM_Object) anObject =
1125     GetOperations()->MakePipeBiNormalAlongVector(aBase, aPath, aVec);
1126   if (!GetOperations()->IsDone() || anObject.IsNull())
1127     return aGEOMObject._retn();
1128
1129   return GetObject(anObject);
1130 }
1131
1132 //=============================================================================
1133 /*!
1134  *  MakeThickening
1135  */
1136 //=============================================================================
1137 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeThickening
1138                  (GEOM::GEOM_Object_ptr theObject,
1139                   CORBA::Double theOffset,
1140                   CORBA::Boolean doCopy)
1141 {
1142   GEOM::GEOM_Object_var aGEOMObject;
1143   //Set a not done flag
1144   GetOperations()->SetNotDone();
1145
1146   if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
1147
1148   //check if the object is a sub-shape
1149   if (!theObject->IsMainShape() && !doCopy) {
1150     GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
1151     return aGEOMObject._retn();
1152   }
1153   
1154   if (!doCopy)
1155     aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1156
1157   //Get the basic object
1158   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1159   if (aBasicObject.IsNull()) return aGEOMObject._retn();
1160   
1161   //Create the thickened shape
1162   if (doCopy)
1163   {
1164     Handle(GEOM_Object) anObject = GetOperations()->MakeThickening(
1165       aBasicObject, theOffset, doCopy);
1166     if (!GetOperations()->IsDone() || anObject.IsNull())
1167       return aGEOMObject._retn();
1168     
1169     return GetObject(anObject);
1170   }
1171   else
1172   {
1173     GetOperations()->MakeThickening(aBasicObject, theOffset, doCopy);
1174     
1175     // Update GUI.
1176     UpdateGUIForObject(theObject);
1177     
1178     return aGEOMObject._retn();
1179   }
1180 }
1181
1182 //=============================================================================
1183 /*!
1184  *  RestorePath
1185  */
1186 //=============================================================================
1187 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::RestorePath
1188                  (GEOM::GEOM_Object_ptr theShape,
1189                   GEOM::GEOM_Object_ptr theBase1,
1190                   GEOM::GEOM_Object_ptr theBase2)
1191 {
1192   GEOM::GEOM_Object_var aGEOMObject;
1193
1194   // Set a not done flag
1195   GetOperations()->SetNotDone();
1196
1197   // Get the reference objects
1198   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1199   Handle(GEOM_Object) aBase1 = GetObjectImpl(theBase1);
1200   Handle(GEOM_Object) aBase2 = GetObjectImpl(theBase2);
1201
1202   if (aShape.IsNull() || aBase1.IsNull() || aBase2.IsNull()) return aGEOMObject._retn();
1203
1204   // Create the Path
1205   Handle(GEOM_Object) anObject = GetOperations()->RestorePath(aShape, aBase1, aBase2);
1206   if (!GetOperations()->IsDone() || anObject.IsNull())
1207     return aGEOMObject._retn();
1208
1209   return GetObject(anObject);
1210 }
1211
1212 //=============================================================================
1213 /*!
1214  *  RestorePathEdges
1215  */
1216 //=============================================================================
1217 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::RestorePathEdges
1218                  (GEOM::GEOM_Object_ptr theShape,
1219                   const GEOM::ListOfGO& theBase1,
1220                   const GEOM::ListOfGO& theBase2)
1221 {
1222   GEOM::GEOM_Object_var aGEOMObject;
1223
1224   // Set a not done flag
1225   GetOperations()->SetNotDone();
1226
1227   // Get the reference objects
1228   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1229   if (aShape.IsNull()) return aGEOMObject._retn();
1230
1231   Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
1232   Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
1233
1234   int ind;
1235   int aNbBases1 = theBase1.length();
1236   int aNbBases2 = theBase2.length();
1237
1238   for (ind = 0; ind < aNbBases1; ind++) {
1239     Handle(GEOM_Object) aBase = GetObjectImpl(theBase1[ind]);
1240     if (!aBase.IsNull())
1241       aSeqBases1->Append(aBase);
1242   }
1243   for (ind = 0; ind < aNbBases2; ind++) {
1244     Handle(GEOM_Object) aBase = GetObjectImpl(theBase2[ind]);
1245     if (!aBase.IsNull())
1246       aSeqBases2->Append(aBase);
1247   }
1248
1249   if (!aSeqBases1->Length() || !aSeqBases2->Length())
1250     return aGEOMObject._retn();
1251
1252   // Create the Path
1253   Handle(GEOM_Object) anObject = GetOperations()->RestorePath(aShape, aSeqBases1, aSeqBases2);
1254   if (!GetOperations()->IsDone() || anObject.IsNull())
1255     return aGEOMObject._retn();
1256
1257   return GetObject(anObject);
1258 }