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