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/ or email : webmaster.salome@opencascade.com
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);
139 //=============================================================================
143 //=============================================================================
144 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
145 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
147 GEOM::GEOM_Object_var aGEOMObject;
149 //Set a not done flag
150 GetOperations()->SetNotDone();
152 if (theCurve == NULL) return aGEOMObject._retn();
154 //Get the reference curve
156 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
157 (theCurve->GetStudyID(), theCurve->GetEntry());
158 if (aRefernce.IsNull()) return aGEOMObject._retn();
162 Handle(GEOM_Object) anObject =
163 GetOperations()->MakeTangentOnCurve(aRefernce, theParameter);
164 if (!GetOperations()->IsDone() || anObject.IsNull())
165 return aGEOMObject._retn();
167 return GetObject(anObject);
171 //=============================================================================
175 //=============================================================================
176 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
177 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
179 GEOM::GEOM_Object_var aGEOMObject;
181 //Set a not done flag
182 GetOperations()->SetNotDone();
186 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
187 if (!GetOperations()->IsDone() || anObject.IsNull())
188 return aGEOMObject._retn();
190 return GetObject(anObject);
193 //=============================================================================
197 //=============================================================================
198 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
199 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
201 GEOM::GEOM_Object_var aGEOMObject;
203 //Set a not done flag
204 GetOperations()->SetNotDone();
206 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
208 //Get the reference points
210 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
211 (thePnt1->GetStudyID(), thePnt1->GetEntry());
212 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
213 (thePnt2->GetStudyID(), thePnt2->GetEntry());
214 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
218 Handle(GEOM_Object) anObject =
219 GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
220 if (!GetOperations()->IsDone() || anObject.IsNull())
221 return aGEOMObject._retn();
223 return GetObject(anObject);
227 //=============================================================================
231 //=============================================================================
232 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
233 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
235 GEOM::GEOM_Object_var aGEOMObject;
237 //Set a not done flag
238 GetOperations()->SetNotDone();
240 if (thePnt == NULL || theDir == NULL) return aGEOMObject._retn();
242 //Get the reference objects
244 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
245 (thePnt->GetStudyID(), thePnt->GetEntry());
246 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
247 (theDir->GetStudyID(), theDir->GetEntry());
248 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
252 Handle(GEOM_Object) anObject =
253 GetOperations()->MakeLine(aRef1, aRef2);
254 if (!GetOperations()->IsDone() || anObject.IsNull())
255 return aGEOMObject._retn();
257 return GetObject(anObject);
260 //=============================================================================
264 //=============================================================================
265 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
266 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
268 GEOM::GEOM_Object_var aGEOMObject;
270 //Set a not done flag
271 GetOperations()->SetNotDone();
273 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
275 //Get the reference points
277 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
278 (thePnt1->GetStudyID(), thePnt1->GetEntry());
279 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
280 (thePnt2->GetStudyID(), thePnt2->GetEntry());
281 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
285 Handle(GEOM_Object) anObject =
286 GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
287 if (!GetOperations()->IsDone() || anObject.IsNull())
288 return aGEOMObject._retn();
290 return GetObject(anObject);
294 //=============================================================================
298 //=============================================================================
299 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
300 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
301 CORBA::Double theTrimSize)
303 GEOM::GEOM_Object_var aGEOMObject;
305 //Set a not done flag
306 GetOperations()->SetNotDone();
308 if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
312 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
313 (thePnt->GetStudyID(), thePnt->GetEntry());
314 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
315 (theVec->GetStudyID(), theVec->GetEntry());
316 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
320 Handle(GEOM_Object) anObject =
321 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
322 if (!GetOperations()->IsDone() || anObject.IsNull())
323 return aGEOMObject._retn();
325 return GetObject(anObject);
328 //=============================================================================
332 //=============================================================================
333 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
334 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
335 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
337 GEOM::GEOM_Object_var aGEOMObject;
339 //Set a not done flag
340 GetOperations()->SetNotDone();
342 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL)
343 return aGEOMObject._retn();
345 //Get the reference points
347 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
348 (thePnt1->GetStudyID(), thePnt1->GetEntry());
349 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
350 (thePnt2->GetStudyID(), thePnt2->GetEntry());
351 Handle(GEOM_Object) aRef3 = GetOperations()->GetEngine()->GetObject
352 (thePnt3->GetStudyID(), thePnt3->GetEntry());
353 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
354 return aGEOMObject._retn();
358 Handle(GEOM_Object) anObject =
359 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
360 if (!GetOperations()->IsDone() || anObject.IsNull())
361 return aGEOMObject._retn();
363 return GetObject(anObject);
366 //=============================================================================
370 //=============================================================================
371 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
372 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
374 GEOM::GEOM_Object_var aGEOMObject;
376 //Set a not done flag
377 GetOperations()->SetNotDone();
379 if (theFace == NULL) return aGEOMObject._retn();
381 //Get the reference face
383 Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
384 (theFace->GetStudyID(), theFace->GetEntry());
385 if (aRef.IsNull()) return aGEOMObject._retn();
389 Handle(GEOM_Object) anObject =
390 GetOperations()->MakePlaneFace(aRef, theTrimSize);
391 if (!GetOperations()->IsDone() || anObject.IsNull())
392 return aGEOMObject._retn();
394 return GetObject(anObject);
398 //=============================================================================
402 //=============================================================================
403 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
404 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
405 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
406 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
408 GEOM::GEOM_Object_var aGEOMObject;
410 //Set a not done flag
411 GetOperations()->SetNotDone();
414 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
415 theXDX, theXDY, theXDZ,
416 theYDX, theYDY, theYDZ);
417 if (!GetOperations()->IsDone() || anObject.IsNull())
418 return aGEOMObject._retn();
420 return GetObject(anObject);
423 //=============================================================================
425 * MakeTangentPlaneOnFace
427 //=============================================================================
429 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
430 (GEOM::GEOM_Object_ptr theFace,
431 CORBA::Double theParameterU,
432 CORBA::Double theParameterV,
433 CORBA::Double theTrimSize)
435 GEOM::GEOM_Object_var aGEOMObject;
437 //Set a not done flag
438 GetOperations()->SetNotDone();
440 if (theFace == NULL) return aGEOMObject._retn();
442 //Get the reference face
444 Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
445 (theFace->GetStudyID(), theFace->GetEntry());
446 if (aRef.IsNull()) return aGEOMObject._retn();
450 Handle(GEOM_Object) anObject =
451 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
452 if (!GetOperations()->IsDone() || anObject.IsNull())
453 return aGEOMObject._retn();
455 return GetObject(anObject);