Salome HOME
e6e390862b50f1c9e7a82fde7fec4653a91ce48d
[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  *  MakeLineTwoPnt
180  */
181 //=============================================================================
182 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
183                  (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
184 {
185   GEOM::GEOM_Object_var aGEOMObject;
186
187   //Set a not done flag
188   GetOperations()->SetNotDone();
189
190   if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
191
192   //Get the reference points
193
194   Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
195     (thePnt1->GetStudyID(), thePnt1->GetEntry());
196   Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
197     (thePnt2->GetStudyID(), thePnt2->GetEntry());
198   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
199
200   //Create the Line
201
202   Handle(GEOM_Object) anObject =
203     GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
204   if (!GetOperations()->IsDone() || anObject.IsNull())
205     return aGEOMObject._retn();
206
207   return GetObject(anObject);
208 }
209
210
211 //=============================================================================
212 /*!
213  *  MakePlanePntVec
214  */
215 //=============================================================================
216 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
217                  (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
218                   CORBA::Double theTrimSize)
219 {
220   GEOM::GEOM_Object_var aGEOMObject;
221
222   //Set a not done flag
223   GetOperations()->SetNotDone();
224
225   if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
226
227   //Get the references
228
229   Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
230     (thePnt->GetStudyID(), thePnt->GetEntry());
231   Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
232     (theVec->GetStudyID(), theVec->GetEntry());
233   if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
234
235   //Create the plane
236
237   Handle(GEOM_Object) anObject =
238     GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
239   if (!GetOperations()->IsDone() || anObject.IsNull())
240     return aGEOMObject._retn();
241
242   return GetObject(anObject);
243 }
244
245 //=============================================================================
246 /*!
247  *  MakePlaneThreePnt
248  */
249 //=============================================================================
250 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
251                  (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
252                   GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
253 {
254   GEOM::GEOM_Object_var aGEOMObject;
255
256   //Set a not done flag
257   GetOperations()->SetNotDone();
258
259   if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL)
260     return aGEOMObject._retn();
261
262   //Get the reference points
263
264   Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
265     (thePnt1->GetStudyID(), thePnt1->GetEntry());
266   Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
267     (thePnt2->GetStudyID(), thePnt2->GetEntry());
268   Handle(GEOM_Object) aRef3 = GetOperations()->GetEngine()->GetObject
269     (thePnt3->GetStudyID(), thePnt3->GetEntry());
270   if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
271     return aGEOMObject._retn();
272
273   //Create the plane
274
275   Handle(GEOM_Object) anObject =
276     GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
277   if (!GetOperations()->IsDone() || anObject.IsNull())
278     return aGEOMObject._retn();
279
280   return GetObject(anObject);
281 }
282
283 //=============================================================================
284 /*!
285  *  MakePlaneFace
286  */
287 //=============================================================================
288 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
289                      (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
290 {
291   GEOM::GEOM_Object_var aGEOMObject;
292
293   //Set a not done flag
294   GetOperations()->SetNotDone();
295
296   if (theFace == NULL) return aGEOMObject._retn();
297
298   //Get the reference face
299
300   Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
301     (theFace->GetStudyID(), theFace->GetEntry());
302   if (aRef.IsNull()) return aGEOMObject._retn();
303
304   //Create the plane
305
306   Handle(GEOM_Object) anObject =
307     GetOperations()->MakePlaneFace(aRef, theTrimSize);
308   if (!GetOperations()->IsDone() || anObject.IsNull())
309     return aGEOMObject._retn();
310
311   return GetObject(anObject);
312 }
313
314
315 //=============================================================================
316 /*!
317  *  MakeMarker
318  */
319 //=============================================================================
320 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
321   (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
322    CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
323    CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
324 {
325   GEOM::GEOM_Object_var aGEOMObject;
326
327   //Set a not done flag
328   GetOperations()->SetNotDone();
329
330   //Create the point
331   Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
332                                                              theXDX, theXDY, theXDZ,
333                                                              theYDX, theYDY, theYDZ);
334   if (!GetOperations()->IsDone() || anObject.IsNull())
335     return aGEOMObject._retn();
336
337   return GetObject(anObject);
338 }