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 //=============================================================================
110 * MakePointOnLinesIntersection
112 //=============================================================================
113 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnLinesIntersection
114 (GEOM::GEOM_Object_ptr theLine1, GEOM::GEOM_Object_ptr theLine2)
116 GEOM::GEOM_Object_var aGEOMObject;
118 //Set a not done flag
119 GetOperations()->SetNotDone();
121 if (theLine1 == NULL || theLine2 == NULL) return aGEOMObject._retn();
123 //Get the reference Lines
125 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
126 (theLine1->GetStudyID(), theLine1->GetEntry());
127 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
128 (theLine2->GetStudyID(), theLine2->GetEntry());
129 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
133 Handle(GEOM_Object) anObject =
134 GetOperations()->MakePointOnLinesIntersection(aRef1, aRef2);
135 if (!GetOperations()->IsDone() || anObject.IsNull())
136 return aGEOMObject._retn();
138 return GetObject(anObject);
141 //=============================================================================
145 //=============================================================================
146 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
147 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
149 GEOM::GEOM_Object_var aGEOMObject;
151 //Set a not done flag
152 GetOperations()->SetNotDone();
154 if (theCurve == NULL) return aGEOMObject._retn();
156 //Get the reference curve
158 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
159 (theCurve->GetStudyID(), theCurve->GetEntry());
160 if (aRefernce.IsNull()) return aGEOMObject._retn();
164 Handle(GEOM_Object) anObject =
165 GetOperations()->MakePointOnCurve(aRefernce, theParameter);
166 if (!GetOperations()->IsDone() || anObject.IsNull())
167 return aGEOMObject._retn();
169 return GetObject(anObject);
172 //=============================================================================
176 //=============================================================================
177 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
178 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
180 GEOM::GEOM_Object_var aGEOMObject;
182 //Set a not done flag
183 GetOperations()->SetNotDone();
185 if (theCurve == NULL) return aGEOMObject._retn();
187 //Get the reference curve
189 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
190 (theCurve->GetStudyID(), theCurve->GetEntry());
191 if (aRefernce.IsNull()) return aGEOMObject._retn();
195 Handle(GEOM_Object) anObject =
196 GetOperations()->MakeTangentOnCurve(aRefernce, theParameter);
197 if (!GetOperations()->IsDone() || anObject.IsNull())
198 return aGEOMObject._retn();
200 return GetObject(anObject);
204 //=============================================================================
208 //=============================================================================
209 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
210 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
212 GEOM::GEOM_Object_var aGEOMObject;
214 //Set a not done flag
215 GetOperations()->SetNotDone();
219 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
220 if (!GetOperations()->IsDone() || anObject.IsNull())
221 return aGEOMObject._retn();
223 return GetObject(anObject);
226 //=============================================================================
230 //=============================================================================
231 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
232 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
234 GEOM::GEOM_Object_var aGEOMObject;
236 //Set a not done flag
237 GetOperations()->SetNotDone();
239 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
241 //Get the reference points
243 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
244 (thePnt1->GetStudyID(), thePnt1->GetEntry());
245 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
246 (thePnt2->GetStudyID(), thePnt2->GetEntry());
247 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
251 Handle(GEOM_Object) anObject =
252 GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
253 if (!GetOperations()->IsDone() || anObject.IsNull())
254 return aGEOMObject._retn();
256 return GetObject(anObject);
260 //=============================================================================
264 //=============================================================================
265 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
266 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
268 GEOM::GEOM_Object_var aGEOMObject;
270 //Set a not done flag
271 GetOperations()->SetNotDone();
273 if (thePnt == NULL || theDir == NULL) return aGEOMObject._retn();
275 //Get the reference objects
277 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
278 (thePnt->GetStudyID(), thePnt->GetEntry());
279 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
280 (theDir->GetStudyID(), theDir->GetEntry());
281 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
285 Handle(GEOM_Object) anObject =
286 GetOperations()->MakeLine(aRef1, aRef2);
287 if (!GetOperations()->IsDone() || anObject.IsNull())
288 return aGEOMObject._retn();
290 return GetObject(anObject);
293 //=============================================================================
297 //=============================================================================
298 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
299 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
301 GEOM::GEOM_Object_var aGEOMObject;
303 //Set a not done flag
304 GetOperations()->SetNotDone();
306 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
308 //Get the reference points
310 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
311 (thePnt1->GetStudyID(), thePnt1->GetEntry());
312 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
313 (thePnt2->GetStudyID(), thePnt2->GetEntry());
314 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
318 Handle(GEOM_Object) anObject =
319 GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
320 if (!GetOperations()->IsDone() || anObject.IsNull())
321 return aGEOMObject._retn();
323 return GetObject(anObject);
326 //=============================================================================
330 //=============================================================================
331 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
332 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
334 GEOM::GEOM_Object_var aGEOMObject;
336 //Set a not done flag
337 GetOperations()->SetNotDone();
339 if (theFace1 == NULL || theFace2 == NULL) return aGEOMObject._retn();
341 //Get the reference points
343 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
344 (theFace1->GetStudyID(), theFace1->GetEntry());
345 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
346 (theFace2->GetStudyID(), theFace2->GetEntry());
347 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
351 Handle(GEOM_Object) anObject =
352 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
353 if (!GetOperations()->IsDone() || anObject.IsNull())
354 return aGEOMObject._retn();
356 return GetObject(anObject);
359 //=============================================================================
363 //=============================================================================
364 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
365 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
366 CORBA::Double theTrimSize)
368 GEOM::GEOM_Object_var aGEOMObject;
370 //Set a not done flag
371 GetOperations()->SetNotDone();
373 if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
377 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
378 (thePnt->GetStudyID(), thePnt->GetEntry());
379 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
380 (theVec->GetStudyID(), theVec->GetEntry());
381 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
385 Handle(GEOM_Object) anObject =
386 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
387 if (!GetOperations()->IsDone() || anObject.IsNull())
388 return aGEOMObject._retn();
390 return GetObject(anObject);
393 //=============================================================================
397 //=============================================================================
398 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
399 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
400 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
402 GEOM::GEOM_Object_var aGEOMObject;
404 //Set a not done flag
405 GetOperations()->SetNotDone();
407 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL)
408 return aGEOMObject._retn();
410 //Get the reference points
412 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
413 (thePnt1->GetStudyID(), thePnt1->GetEntry());
414 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
415 (thePnt2->GetStudyID(), thePnt2->GetEntry());
416 Handle(GEOM_Object) aRef3 = GetOperations()->GetEngine()->GetObject
417 (thePnt3->GetStudyID(), thePnt3->GetEntry());
418 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
419 return aGEOMObject._retn();
423 Handle(GEOM_Object) anObject =
424 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
425 if (!GetOperations()->IsDone() || anObject.IsNull())
426 return aGEOMObject._retn();
428 return GetObject(anObject);
431 //=============================================================================
435 //=============================================================================
436 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
437 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
439 GEOM::GEOM_Object_var aGEOMObject;
441 //Set a not done flag
442 GetOperations()->SetNotDone();
444 if (theFace == NULL) return aGEOMObject._retn();
446 //Get the reference face
448 Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
449 (theFace->GetStudyID(), theFace->GetEntry());
450 if (aRef.IsNull()) return aGEOMObject._retn();
454 Handle(GEOM_Object) anObject =
455 GetOperations()->MakePlaneFace(aRef, theTrimSize);
456 if (!GetOperations()->IsDone() || anObject.IsNull())
457 return aGEOMObject._retn();
459 return GetObject(anObject);
463 //=============================================================================
467 //=============================================================================
468 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
469 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
470 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
471 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
473 GEOM::GEOM_Object_var aGEOMObject;
475 //Set a not done flag
476 GetOperations()->SetNotDone();
479 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
480 theXDX, theXDY, theXDZ,
481 theYDX, theYDY, theYDZ);
482 if (!GetOperations()->IsDone() || anObject.IsNull())
483 return aGEOMObject._retn();
485 return GetObject(anObject);
488 //=============================================================================
490 * MakeTangentPlaneOnFace
492 //=============================================================================
494 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
495 (GEOM::GEOM_Object_ptr theFace,
496 CORBA::Double theParameterU,
497 CORBA::Double theParameterV,
498 CORBA::Double theTrimSize)
500 GEOM::GEOM_Object_var aGEOMObject;
502 //Set a not done flag
503 GetOperations()->SetNotDone();
505 if (theFace == NULL) return aGEOMObject._retn();
507 //Get the reference face
509 Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
510 (theFace->GetStudyID(), theFace->GetEntry());
511 if (aRef.IsNull()) return aGEOMObject._retn();
515 Handle(GEOM_Object) anObject =
516 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
517 if (!GetOperations()->IsDone() || anObject.IsNull())
518 return aGEOMObject._retn();
520 return GetObject(anObject);