1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/
20 #include <Standard_Stream.hxx>
22 #include "GEOM_IBasicOperations_i.hh"
24 #include "utilities.h"
26 #include "Utils_ExceptHandlers.hxx"
28 #include "GEOM_Engine.hxx"
29 #include "GEOM_Object.hxx"
31 //=============================================================================
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)
41 MESSAGE("GEOM_IBasicOperations_i::GEOM_IBasicOperations_i");
44 //=============================================================================
48 //=============================================================================
49 GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i()
51 MESSAGE("GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i");
55 //=============================================================================
59 //=============================================================================
60 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointXYZ
61 (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
63 GEOM::GEOM_Object_var aGEOMObject;
66 GetOperations()->SetNotDone();
70 Handle(GEOM_Object) anObject = GetOperations()->MakePointXYZ(theX, theY, theZ);
71 if (!GetOperations()->IsDone() || anObject.IsNull())
72 return aGEOMObject._retn();
74 return GetObject(anObject);
77 //=============================================================================
79 * MakePointWithReference
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)
85 GEOM::GEOM_Object_var aGEOMObject;
88 GetOperations()->SetNotDone();
90 if(theReference == NULL) return aGEOMObject._retn();
92 //Get the reference point
94 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
95 (theReference->GetStudyID(), theReference->GetEntry());
96 if (aRefernce.IsNull()) return aGEOMObject._retn();
100 Handle(GEOM_Object) anObject =
101 GetOperations()->MakePointWithReference(aRefernce, theX, theY, theZ);
102 if (!GetOperations()->IsDone() || anObject.IsNull())
103 return aGEOMObject._retn();
105 return GetObject(anObject);
108 //=============================================================================
112 //=============================================================================
113 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
114 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
116 GEOM::GEOM_Object_var aGEOMObject;
118 //Set a not done flag
119 GetOperations()->SetNotDone();
121 if (theCurve == NULL) return aGEOMObject._retn();
123 //Get the reference curve
125 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
126 (theCurve->GetStudyID(), theCurve->GetEntry());
127 if (aRefernce.IsNull()) return aGEOMObject._retn();
131 Handle(GEOM_Object) anObject =
132 GetOperations()->MakePointOnCurve(aRefernce, theParameter);
133 if (!GetOperations()->IsDone() || anObject.IsNull())
134 return aGEOMObject._retn();
136 return GetObject(anObject);
140 //=============================================================================
144 //=============================================================================
145 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
146 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
148 GEOM::GEOM_Object_var aGEOMObject;
150 //Set a not done flag
151 GetOperations()->SetNotDone();
155 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
156 if (!GetOperations()->IsDone() || anObject.IsNull())
157 return aGEOMObject._retn();
159 return GetObject(anObject);
162 //=============================================================================
166 //=============================================================================
167 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
168 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
170 GEOM::GEOM_Object_var aGEOMObject;
172 //Set a not done flag
173 GetOperations()->SetNotDone();
175 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
177 //Get the reference points
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();
187 Handle(GEOM_Object) anObject =
188 GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
189 if (!GetOperations()->IsDone() || anObject.IsNull())
190 return aGEOMObject._retn();
192 return GetObject(anObject);
196 //=============================================================================
200 //=============================================================================
201 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
202 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
204 GEOM::GEOM_Object_var aGEOMObject;
206 //Set a not done flag
207 GetOperations()->SetNotDone();
209 if (thePnt == NULL || theDir == NULL) return aGEOMObject._retn();
211 //Get the reference objects
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();
221 Handle(GEOM_Object) anObject =
222 GetOperations()->MakeLine(aRef1, aRef2);
223 if (!GetOperations()->IsDone() || anObject.IsNull())
224 return aGEOMObject._retn();
226 return GetObject(anObject);
229 //=============================================================================
233 //=============================================================================
234 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
235 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
237 GEOM::GEOM_Object_var aGEOMObject;
239 //Set a not done flag
240 GetOperations()->SetNotDone();
242 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
244 //Get the reference points
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();
254 Handle(GEOM_Object) anObject =
255 GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
256 if (!GetOperations()->IsDone() || anObject.IsNull())
257 return aGEOMObject._retn();
259 return GetObject(anObject);
263 //=============================================================================
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)
272 GEOM::GEOM_Object_var aGEOMObject;
274 //Set a not done flag
275 GetOperations()->SetNotDone();
277 if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
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();
289 Handle(GEOM_Object) anObject =
290 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
291 if (!GetOperations()->IsDone() || anObject.IsNull())
292 return aGEOMObject._retn();
294 return GetObject(anObject);
297 //=============================================================================
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)
306 GEOM::GEOM_Object_var aGEOMObject;
308 //Set a not done flag
309 GetOperations()->SetNotDone();
311 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL)
312 return aGEOMObject._retn();
314 //Get the reference points
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();
327 Handle(GEOM_Object) anObject =
328 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
329 if (!GetOperations()->IsDone() || anObject.IsNull())
330 return aGEOMObject._retn();
332 return GetObject(anObject);
335 //=============================================================================
339 //=============================================================================
340 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
341 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
343 GEOM::GEOM_Object_var aGEOMObject;
345 //Set a not done flag
346 GetOperations()->SetNotDone();
348 if (theFace == NULL) return aGEOMObject._retn();
350 //Get the reference face
352 Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
353 (theFace->GetStudyID(), theFace->GetEntry());
354 if (aRef.IsNull()) return aGEOMObject._retn();
358 Handle(GEOM_Object) anObject =
359 GetOperations()->MakePlaneFace(aRef, theTrimSize);
360 if (!GetOperations()->IsDone() || anObject.IsNull())
361 return aGEOMObject._retn();
363 return GetObject(anObject);
367 //=============================================================================
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)
377 GEOM::GEOM_Object_var aGEOMObject;
379 //Set a not done flag
380 GetOperations()->SetNotDone();
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();
389 return GetObject(anObject);