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