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