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