Salome HOME
Merge with version on tag OCC-V2_1_0d
[modules/geom.git] / src / GEOM_I / GEOM_IBasicOperations_i.cc
1 using namespace std;
2
3 #include "GEOM_IBasicOperations_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_IBasicOperations_i::GEOM_IBasicOperations_i (PortableServer::POA_ptr thePOA,
18                                                   GEOM::GEOM_Gen_ptr theEngine,
19                                                   ::GEOMImpl_IBasicOperations* theImpl)
20      :GEOM_IOperations_i(thePOA, theEngine, theImpl)
21 {
22   MESSAGE("GEOM_IBasicOperations_i::GEOM_IBasicOperations_i");
23 }
24
25 //=============================================================================
26 /*!
27  *  destructor
28  */
29 //=============================================================================
30 GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i()
31 {
32   MESSAGE("GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i");
33 }
34
35
36 //=============================================================================
37 /*!
38  *  MakePointXYZ
39  */
40 //=============================================================================
41 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointXYZ
42   (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
43 {
44   GEOM::GEOM_Object_var aGEOMObject;
45
46   //Set a not done flag
47   GetOperations()->SetNotDone();
48
49    //Create the point
50
51   Handle(GEOM_Object) anObject = GetOperations()->MakePointXYZ(theX, theY, theZ);
52   if (!GetOperations()->IsDone() || anObject.IsNull())
53     return aGEOMObject._retn();
54
55   return GetObject(anObject);
56 }
57
58 //=============================================================================
59 /*!
60  *  MakePointWithReference
61  */
62 //=============================================================================
63 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointWithReference
64   (GEOM::GEOM_Object_ptr theReference, CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
65 {
66   GEOM::GEOM_Object_var aGEOMObject;
67
68   //Set a not done flag
69   GetOperations()->SetNotDone();
70
71   if(theReference == NULL) return aGEOMObject._retn();
72
73   //Get the reference point
74
75   Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
76     (theReference->GetStudyID(), theReference->GetEntry());
77   if (aRefernce.IsNull()) return aGEOMObject._retn();
78
79   //Create the point
80
81   Handle(GEOM_Object) anObject =
82     GetOperations()->MakePointWithReference(aRefernce, theX, theY, theZ);
83   if (!GetOperations()->IsDone() || anObject.IsNull())
84     return aGEOMObject._retn();
85
86   return GetObject(anObject);
87 }
88
89 //=============================================================================
90 /*!
91  *  MakePointOnCurve
92  */
93 //=============================================================================
94 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
95                   (GEOM::GEOM_Object_ptr theCurve,  CORBA::Double theParameter)
96 {
97   GEOM::GEOM_Object_var aGEOMObject;
98
99   //Set a not done flag
100   GetOperations()->SetNotDone();
101
102   if (theCurve == NULL) return aGEOMObject._retn();
103
104   //Get the reference curve
105
106   Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
107     (theCurve->GetStudyID(), theCurve->GetEntry());
108   if (aRefernce.IsNull()) return aGEOMObject._retn();
109
110   //Create the point
111
112   Handle(GEOM_Object) anObject =
113     GetOperations()->MakePointOnCurve(aRefernce, theParameter);
114   if (!GetOperations()->IsDone() || anObject.IsNull())
115     return aGEOMObject._retn();
116
117   return GetObject(anObject);
118 }
119
120
121 //=============================================================================
122 /*!
123  *  MakeVectorDXDYDZ
124  */
125 //=============================================================================
126 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
127   (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
128 {
129   GEOM::GEOM_Object_var aGEOMObject;
130
131   //Set a not done flag
132   GetOperations()->SetNotDone();
133
134   //Create the Vector
135
136   Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
137   if (!GetOperations()->IsDone() || anObject.IsNull())
138     return aGEOMObject._retn();
139
140   return GetObject(anObject);
141 }
142
143 //=============================================================================
144 /*!
145  *  MakeVectorTwoPnt
146  */
147 //=============================================================================
148 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
149                  (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
150 {
151   GEOM::GEOM_Object_var aGEOMObject;
152
153   //Set a not done flag
154   GetOperations()->SetNotDone();
155
156   if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
157
158   //Get the reference points
159
160   Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
161     (thePnt1->GetStudyID(), thePnt1->GetEntry());
162   Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
163     (thePnt2->GetStudyID(), thePnt2->GetEntry());
164   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
165
166   //Create the vector
167
168   Handle(GEOM_Object) anObject =
169     GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
170   if (!GetOperations()->IsDone() || anObject.IsNull())
171     return aGEOMObject._retn();
172
173   return GetObject(anObject);
174 }
175
176
177 //=============================================================================
178 /*!
179  *  MakeLine
180  */
181 //=============================================================================
182 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
183                    (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
184 {
185   GEOM::GEOM_Object_var aGEOMObject;
186
187   //Set a not done flag
188   GetOperations()->SetNotDone();
189
190   if (thePnt == NULL || theDir == NULL) return aGEOMObject._retn();
191
192   //Get the reference objects
193
194   Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
195     (thePnt->GetStudyID(), thePnt->GetEntry());
196   Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
197     (theDir->GetStudyID(), theDir->GetEntry());
198   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
199
200   //Create the Line
201
202   Handle(GEOM_Object) anObject =
203     GetOperations()->MakeLine(aRef1, aRef2);
204   if (!GetOperations()->IsDone() || anObject.IsNull())
205     return aGEOMObject._retn();
206
207   return GetObject(anObject);
208 }
209
210 //=============================================================================
211 /*!
212  *  MakeLineTwoPnt
213  */
214 //=============================================================================
215 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
216                  (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
217 {
218   GEOM::GEOM_Object_var aGEOMObject;
219
220   //Set a not done flag
221   GetOperations()->SetNotDone();
222
223   if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
224
225   //Get the reference points
226
227   Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
228     (thePnt1->GetStudyID(), thePnt1->GetEntry());
229   Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
230     (thePnt2->GetStudyID(), thePnt2->GetEntry());
231   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
232
233   //Create the Line
234
235   Handle(GEOM_Object) anObject =
236     GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
237   if (!GetOperations()->IsDone() || anObject.IsNull())
238     return aGEOMObject._retn();
239
240   return GetObject(anObject);
241 }
242
243
244 //=============================================================================
245 /*!
246  *  MakePlanePntVec
247  */
248 //=============================================================================
249 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
250                  (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
251                   CORBA::Double theTrimSize)
252 {
253   GEOM::GEOM_Object_var aGEOMObject;
254
255   //Set a not done flag
256   GetOperations()->SetNotDone();
257
258   if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
259
260   //Get the references
261
262   Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
263     (thePnt->GetStudyID(), thePnt->GetEntry());
264   Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
265     (theVec->GetStudyID(), theVec->GetEntry());
266   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
267
268   //Create the plane
269
270   Handle(GEOM_Object) anObject =
271     GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
272   if (!GetOperations()->IsDone() || anObject.IsNull())
273     return aGEOMObject._retn();
274
275   return GetObject(anObject);
276 }
277
278 //=============================================================================
279 /*!
280  *  MakePlaneThreePnt
281  */
282 //=============================================================================
283 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
284                  (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
285                   GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
286 {
287   GEOM::GEOM_Object_var aGEOMObject;
288
289   //Set a not done flag
290   GetOperations()->SetNotDone();
291
292   if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL)
293     return aGEOMObject._retn();
294
295   //Get the reference points
296
297   Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
298     (thePnt1->GetStudyID(), thePnt1->GetEntry());
299   Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
300     (thePnt2->GetStudyID(), thePnt2->GetEntry());
301   Handle(GEOM_Object) aRef3 = GetOperations()->GetEngine()->GetObject
302     (thePnt3->GetStudyID(), thePnt3->GetEntry());
303   if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
304     return aGEOMObject._retn();
305
306   //Create the plane
307
308   Handle(GEOM_Object) anObject =
309     GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
310   if (!GetOperations()->IsDone() || anObject.IsNull())
311     return aGEOMObject._retn();
312
313   return GetObject(anObject);
314 }
315
316 //=============================================================================
317 /*!
318  *  MakePlaneFace
319  */
320 //=============================================================================
321 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
322                      (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
323 {
324   GEOM::GEOM_Object_var aGEOMObject;
325
326   //Set a not done flag
327   GetOperations()->SetNotDone();
328
329   if (theFace == NULL) return aGEOMObject._retn();
330
331   //Get the reference face
332
333   Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
334     (theFace->GetStudyID(), theFace->GetEntry());
335   if (aRef.IsNull()) return aGEOMObject._retn();
336
337   //Create the plane
338
339   Handle(GEOM_Object) anObject =
340     GetOperations()->MakePlaneFace(aRef, theTrimSize);
341   if (!GetOperations()->IsDone() || anObject.IsNull())
342     return aGEOMObject._retn();
343
344   return GetObject(anObject);
345 }
346
347
348 //=============================================================================
349 /*!
350  *  MakeMarker
351  */
352 //=============================================================================
353 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
354   (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
355    CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
356    CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
357 {
358   GEOM::GEOM_Object_var aGEOMObject;
359
360   //Set a not done flag
361   GetOperations()->SetNotDone();
362
363   //Create the point
364   Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
365                                                              theXDX, theXDY, theXDZ,
366                                                              theYDX, theYDY, theYDZ);
367   if (!GetOperations()->IsDone() || anObject.IsNull())
368     return aGEOMObject._retn();
369
370   return GetObject(anObject);
371 }