Salome HOME
fcee420ebcd2b2d10f4ec8cf9264c4b737f39a89
[modules/geom.git] / src / GEOM_I / GEOM_I3DPrimOperations_i.cc
1 using namespace std;
2
3 #include "GEOM_I3DPrimOperations_i.hh"
4
5 #include "utilities.h"
6 #include "OpUtil.hxx"
7 #include "Utils_ExceptHandlers.hxx"
8
9 #include "GEOM_Engine.hxx"
10 #include "GEOM_Object.hxx"
11
12 //=============================================================================
13 /*!
14  *   constructor:
15  */
16 //=============================================================================
17 GEOM_I3DPrimOperations_i::GEOM_I3DPrimOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_I3DPrimOperations* theImpl)
18 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
19 {
20   MESSAGE("GEOM_I3DPrimOperations_i::GEOM_I3DPrimOperations_i");
21 }
22
23 //=============================================================================
24 /*!
25  *  destructor
26  */
27 //=============================================================================
28 GEOM_I3DPrimOperations_i::~GEOM_I3DPrimOperations_i()
29 {
30   MESSAGE("GEOM_I3DPrimOperations_i::~GEOM_I3DPrimOperations_i");
31 }
32
33
34 //=============================================================================
35 /*!
36  *  MakeBoxDXDYDZ
37  */
38 //=============================================================================
39 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxDXDYDZ (CORBA::Double theDX,
40                                                                CORBA::Double theDY,
41                                                                CORBA::Double theDZ)
42 {
43   GEOM::GEOM_Object_var aGEOMObject;
44
45   //Set a not done flag
46   GetOperations()->SetNotDone();
47    
48   //Create the Box
49   Handle(GEOM_Object) anObject = GetOperations()->MakeBoxDXDYDZ(theDX, theDY, theDZ);
50   if (!GetOperations()->IsDone() || anObject.IsNull())
51     return aGEOMObject._retn();
52  
53   return GetObject(anObject);
54 }
55
56 //=============================================================================
57 /*!
58  *  MakeBoxTwoPnt
59  */
60 //=============================================================================
61 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxTwoPnt
62                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
63 {
64   GEOM::GEOM_Object_var aGEOMObject;
65
66   //Set a not done flag
67   GetOperations()->SetNotDone();
68
69   if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
70
71   //Get the reference points
72   Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
73     (thePnt1->GetStudyID(), thePnt1->GetEntry());
74   Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
75     (thePnt2->GetStudyID(), thePnt2->GetEntry());
76
77   if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
78
79   //Create the Box
80   Handle(GEOM_Object) anObject = GetOperations()->MakeBoxTwoPnt(aPnt1, aPnt2);
81   if (!GetOperations()->IsDone() || anObject.IsNull())
82     return aGEOMObject._retn();
83
84   return GetObject(anObject);
85 }
86
87 //=============================================================================
88 /*!
89  *  MakeCylinderRH
90  */
91 //=============================================================================
92 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double theR,
93                                                                 CORBA::Double theH)
94 {
95   GEOM::GEOM_Object_var aGEOMObject;
96
97   //Set a not done flag
98   GetOperations()->SetNotDone();
99
100   //Create the Cylinder
101   Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderRH(theR, theH);
102   if (!GetOperations()->IsDone() || anObject.IsNull())
103     return aGEOMObject._retn();
104
105   return GetObject(anObject);
106 }
107
108 //=============================================================================
109 /*!
110  *  MakeCylinderPntVecRH
111  */
112 //=============================================================================
113 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH
114                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
115                        CORBA::Double theR, CORBA::Double theH)
116 {
117   GEOM::GEOM_Object_var aGEOMObject;
118
119   //Set a not done flag
120   GetOperations()->SetNotDone();
121
122   if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
123
124   //Get the reference points
125   Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
126     (thePnt->GetStudyID(), thePnt->GetEntry());
127   Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
128     (theVec->GetStudyID(), theVec->GetEntry());
129
130   if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
131
132   //Create the Cylinder
133   Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderPntVecRH(aPnt, aVec, theR, theH);
134   if (!GetOperations()->IsDone() || anObject.IsNull())
135     return aGEOMObject._retn();
136
137   return GetObject(anObject);
138 }
139
140 //=============================================================================
141 /*!
142  *  MakeConeR1R2H
143  */
144 //=============================================================================
145 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeConeR1R2H (CORBA::Double theR1,
146                                                                CORBA::Double theR2,
147                                                                CORBA::Double theH)
148 {
149   GEOM::GEOM_Object_var aGEOMObject;
150
151   //Set a not done flag
152   GetOperations()->SetNotDone();
153
154   //Create the Cone
155   Handle(GEOM_Object) anObject = GetOperations()->MakeConeR1R2H(theR1, theR2, theH);
156   if (!GetOperations()->IsDone() || anObject.IsNull())
157     return aGEOMObject._retn();
158
159   return GetObject(anObject);
160 }
161
162 //=============================================================================
163 /*!
164  *  MakeConePntVecR1R2H
165  */
166 //=============================================================================
167 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeConePntVecR1R2H
168                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
169                        CORBA::Double theR1, CORBA::Double theR2, CORBA::Double theH)
170 {
171   GEOM::GEOM_Object_var aGEOMObject;
172
173   //Set a not done flag
174   GetOperations()->SetNotDone();
175
176   if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
177
178   //Get the reference points
179   Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
180     (thePnt->GetStudyID(), thePnt->GetEntry());
181   Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
182     (theVec->GetStudyID(), theVec->GetEntry());
183
184   if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
185
186   //Create the Cone
187   Handle(GEOM_Object) anObject =
188       GetOperations()->MakeConePntVecR1R2H(aPnt, aVec, theR1, theR2, theH);
189   if (!GetOperations()->IsDone() || anObject.IsNull())
190     return aGEOMObject._retn();
191
192   return GetObject(anObject);
193 }
194
195 //=============================================================================
196 /*!
197  *  MakeSphereR
198  */
199 //=============================================================================
200 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeSphereR (CORBA::Double theR)
201 {
202   GEOM::GEOM_Object_var aGEOMObject;
203
204   //Set a not done flag
205   GetOperations()->SetNotDone();
206
207   //Create the Cone
208   Handle(GEOM_Object) anObject = GetOperations()->MakeSphereR(theR);
209   if (!GetOperations()->IsDone() || anObject.IsNull())
210     return aGEOMObject._retn();
211
212   return GetObject(anObject);
213 }
214
215 //=============================================================================
216 /*!
217  *  MakeSpherePntR
218  */
219 //=============================================================================
220 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeSpherePntR
221                       (GEOM::GEOM_Object_ptr thePnt, CORBA::Double theR)
222 {
223   GEOM::GEOM_Object_var aGEOMObject;
224
225   //Set a not done flag
226   GetOperations()->SetNotDone();
227
228   if (thePnt == NULL) return aGEOMObject._retn();
229
230   //Get the reference point
231   Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
232     (thePnt->GetStudyID(), thePnt->GetEntry());
233
234   if (aPnt.IsNull()) return aGEOMObject._retn();
235
236   //Create the Sphere
237   Handle(GEOM_Object) anObject =
238       GetOperations()->MakeSpherePntR(aPnt, theR);
239   if (!GetOperations()->IsDone() || anObject.IsNull())
240     return aGEOMObject._retn();
241
242   return GetObject(anObject);
243 }
244
245 //=============================================================================
246 /*!
247  *  MakeTorusRR
248  */
249 //=============================================================================
250 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeTorusRR
251                       (CORBA::Double theRMajor, CORBA::Double theRMinor)
252 {
253   GEOM::GEOM_Object_var aGEOMObject;
254
255   //Set a not done flag
256   GetOperations()->SetNotDone();
257
258   // Make Torus
259   Handle(GEOM_Object) anObject =
260     GetOperations()->MakeTorusRR(theRMajor, theRMinor);
261   if (!GetOperations()->IsDone() || anObject.IsNull())
262     return aGEOMObject._retn();
263
264   return GetObject(anObject);
265 }
266
267 //=============================================================================
268 /*!
269  *  MakeTorusPntVecRR
270  */
271 //=============================================================================
272 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeTorusPntVecRR
273                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
274                        CORBA::Double theRMajor, CORBA::Double theRMinor)
275 {
276   GEOM::GEOM_Object_var aGEOMObject;
277
278   //Set a not done flag
279   GetOperations()->SetNotDone();
280
281   if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
282
283   //Get the reference points
284   Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
285     (thePnt->GetStudyID(), thePnt->GetEntry());
286   Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
287     (theVec->GetStudyID(), theVec->GetEntry());
288
289   if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
290
291   // Make Torus
292   Handle(GEOM_Object) anObject =
293     GetOperations()->MakeTorusPntVecRR(aPnt, aVec, theRMajor, theRMinor);
294   if (!GetOperations()->IsDone() || anObject.IsNull())
295     return aGEOMObject._retn();
296
297   return GetObject(anObject);
298 }
299
300 //=============================================================================
301 /*!
302  *  MakePrismVecH
303  */
304 //=============================================================================
305 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismVecH
306                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theVec,
307                        CORBA::Double theH)
308 {
309   GEOM::GEOM_Object_var aGEOMObject;
310
311   //Set a not done flag
312   GetOperations()->SetNotDone();
313
314   if (theBase == NULL || theVec == NULL) return aGEOMObject._retn();
315
316   //Get the reference objects
317   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
318     (theBase->GetStudyID(), theBase->GetEntry());
319   Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
320     (theVec->GetStudyID(), theVec->GetEntry());
321
322   if (aBase.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
323
324   //Create the Prism
325   Handle(GEOM_Object) anObject =
326       GetOperations()->MakePrismVecH(aBase, aVec, theH);
327   if (!GetOperations()->IsDone() || anObject.IsNull())
328     return aGEOMObject._retn();
329
330   return GetObject(anObject);
331 }
332
333 //=============================================================================
334 /*!
335  *  MakePrismTwoPnt
336  */
337 //=============================================================================
338 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismTwoPnt
339                                              (GEOM::GEOM_Object_ptr theBase,
340                                               GEOM::GEOM_Object_ptr thePoint1,
341                                               GEOM::GEOM_Object_ptr thePoint2)
342 {
343   GEOM::GEOM_Object_var aGEOMObject;
344
345   //Set a not done flag
346   GetOperations()->SetNotDone();
347
348   if (theBase == NULL || thePoint1 == NULL || thePoint2 == NULL)
349     return aGEOMObject._retn();
350
351   //Get the reference objects
352   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
353     (theBase->GetStudyID(), theBase->GetEntry());
354   Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject
355     (thePoint1->GetStudyID(), thePoint1->GetEntry());
356   Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject
357     (thePoint2->GetStudyID(), thePoint2->GetEntry());
358
359   if (aBase.IsNull() || aPoint1.IsNull() || aPoint2.IsNull())
360     return aGEOMObject._retn();
361
362   //Create the Prism
363   Handle(GEOM_Object) anObject =
364     GetOperations()->MakePrismTwoPnt(aBase, aPoint1, aPoint2);
365   if (!GetOperations()->IsDone() || anObject.IsNull())
366     return aGEOMObject._retn();
367
368   return GetObject(anObject);
369 }
370
371 //=============================================================================
372 /*!
373  *  MakePipe
374  */
375 //=============================================================================
376 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipe
377                  (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePath)
378 {
379   GEOM::GEOM_Object_var aGEOMObject;
380
381   //Set a not done flag
382   GetOperations()->SetNotDone();
383
384   if (theBase == NULL || thePath == NULL) return aGEOMObject._retn();
385
386   //Get the reference objects
387   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
388     (theBase->GetStudyID(), theBase->GetEntry());
389   Handle(GEOM_Object) aPath = GetOperations()->GetEngine()->GetObject
390     (thePath->GetStudyID(), thePath->GetEntry());
391
392   if (aBase.IsNull() || aPath.IsNull()) return aGEOMObject._retn();
393
394   //Create the Pipe
395   Handle(GEOM_Object) anObject =
396     GetOperations()->MakePipe(aBase, aPath);
397   if (!GetOperations()->IsDone() || anObject.IsNull())
398     return aGEOMObject._retn();
399
400   return GetObject(anObject);
401 }
402
403 //=============================================================================
404 /*!
405  *  MakeRevolutionAxisAngle
406  */
407 //=============================================================================
408 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle
409                       (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theAxis,
410                        CORBA::Double theAngle)
411 {
412   GEOM::GEOM_Object_var aGEOMObject;
413
414   //Set a not done flag
415   GetOperations()->SetNotDone();
416
417   if (theBase == NULL || theAxis == NULL) return aGEOMObject._retn();
418
419   //Get the reference objects
420   Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject
421     (theBase->GetStudyID(), theBase->GetEntry());
422   Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
423     (theAxis->GetStudyID(), theAxis->GetEntry());
424
425   if (aBase.IsNull() || anAxis.IsNull()) return aGEOMObject._retn();
426
427   //Create the Revolution
428   Handle(GEOM_Object) anObject =
429       GetOperations()->MakeRevolutionAxisAngle(aBase, anAxis, theAngle);
430   if (!GetOperations()->IsDone() || anObject.IsNull())
431     return aGEOMObject._retn();
432
433   return GetObject(anObject);
434 }
435
436 //=============================================================================
437 /*!
438  *  MakeFilling
439  */
440 //=============================================================================
441 GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_ptr theShape,
442                                                             CORBA::Long theMinDeg,
443                                                             CORBA::Long theMaxDeg,
444                                                             CORBA::Double theTol2D,
445                                                             CORBA::Double theTol3D,
446                                                             CORBA::Long theNbIter)
447 {
448   GEOM::GEOM_Object_var aGEOMObject;
449
450   //Set a not done flag
451   GetOperations()->SetNotDone();
452
453   if (theShape == NULL) return aGEOMObject._retn();
454
455   //Get the reference objects
456   Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
457     (theShape->GetStudyID(), theShape->GetEntry());
458
459   if (aShape.IsNull()) return aGEOMObject._retn();
460
461   //Create the Solid
462   Handle(GEOM_Object) anObject = GetOperations()->MakeFilling(aShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter);
463   if (!GetOperations()->IsDone() || anObject.IsNull())
464     return aGEOMObject._retn();
465
466   return GetObject(anObject);
467 }