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);
142 //=============================================================================
146 //=============================================================================
147 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
148 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
150 GEOM::GEOM_Object_var aGEOMObject;
152 //Set a not done flag
153 GetOperations()->SetNotDone();
155 if (theCurve == NULL) return aGEOMObject._retn();
157 //Get the reference curve
159 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
160 (theCurve->GetStudyID(), theCurve->GetEntry());
161 if (aRefernce.IsNull()) return aGEOMObject._retn();
165 Handle(GEOM_Object) anObject =
166 GetOperations()->MakePointOnCurve(aRefernce, theParameter);
167 if (!GetOperations()->IsDone() || anObject.IsNull())
168 return aGEOMObject._retn();
170 return GetObject(anObject);
174 //=============================================================================
178 //=============================================================================
179 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
180 (GEOM::GEOM_Object_ptr theSurface,
181 CORBA::Double theUParameter,
182 CORBA::Double theVParameter)
184 GEOM::GEOM_Object_var aGEOMObject;
186 //Set a not done flag
187 GetOperations()->SetNotDone();
189 if (theSurface == NULL) return aGEOMObject._retn();
191 //Get the reference surface
192 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
193 (theSurface->GetStudyID(), theSurface->GetEntry());
194 if (aRefernce.IsNull()) return aGEOMObject._retn();
197 Handle(GEOM_Object) anObject =
198 GetOperations()->MakePointOnSurface(aRefernce, theUParameter, theVParameter);
199 if (!GetOperations()->IsDone() || anObject.IsNull())
200 return aGEOMObject._retn();
202 return GetObject(anObject);
206 //=============================================================================
210 //=============================================================================
211 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
212 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
214 GEOM::GEOM_Object_var aGEOMObject;
216 //Set a not done flag
217 GetOperations()->SetNotDone();
219 if (theCurve == NULL) return aGEOMObject._retn();
221 //Get the reference curve
223 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
224 (theCurve->GetStudyID(), theCurve->GetEntry());
225 if (aRefernce.IsNull()) return aGEOMObject._retn();
229 Handle(GEOM_Object) anObject =
230 GetOperations()->MakeTangentOnCurve(aRefernce, theParameter);
231 if (!GetOperations()->IsDone() || anObject.IsNull())
232 return aGEOMObject._retn();
234 return GetObject(anObject);
238 //=============================================================================
242 //=============================================================================
243 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
244 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
246 GEOM::GEOM_Object_var aGEOMObject;
248 //Set a not done flag
249 GetOperations()->SetNotDone();
253 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
254 if (!GetOperations()->IsDone() || anObject.IsNull())
255 return aGEOMObject._retn();
257 return GetObject(anObject);
260 //=============================================================================
264 //=============================================================================
265 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
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()->MakeVectorTwoPnt(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::MakeLine
300 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
302 GEOM::GEOM_Object_var aGEOMObject;
304 //Set a not done flag
305 GetOperations()->SetNotDone();
307 if (thePnt == NULL || theDir == NULL) return aGEOMObject._retn();
309 //Get the reference objects
311 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
312 (thePnt->GetStudyID(), thePnt->GetEntry());
313 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
314 (theDir->GetStudyID(), theDir->GetEntry());
315 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
319 Handle(GEOM_Object) anObject =
320 GetOperations()->MakeLine(aRef1, aRef2);
321 if (!GetOperations()->IsDone() || anObject.IsNull())
322 return aGEOMObject._retn();
324 return GetObject(anObject);
327 //=============================================================================
331 //=============================================================================
332 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
333 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
335 GEOM::GEOM_Object_var aGEOMObject;
337 //Set a not done flag
338 GetOperations()->SetNotDone();
340 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
342 //Get the reference points
344 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
345 (thePnt1->GetStudyID(), thePnt1->GetEntry());
346 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
347 (thePnt2->GetStudyID(), thePnt2->GetEntry());
348 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
352 Handle(GEOM_Object) anObject =
353 GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
354 if (!GetOperations()->IsDone() || anObject.IsNull())
355 return aGEOMObject._retn();
357 return GetObject(anObject);
360 //=============================================================================
364 //=============================================================================
365 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
366 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
368 GEOM::GEOM_Object_var aGEOMObject;
370 //Set a not done flag
371 GetOperations()->SetNotDone();
373 if (theFace1 == NULL || theFace2 == NULL) return aGEOMObject._retn();
375 //Get the reference points
377 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
378 (theFace1->GetStudyID(), theFace1->GetEntry());
379 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
380 (theFace2->GetStudyID(), theFace2->GetEntry());
381 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
385 Handle(GEOM_Object) anObject =
386 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
387 if (!GetOperations()->IsDone() || anObject.IsNull())
388 return aGEOMObject._retn();
390 return GetObject(anObject);
393 //=============================================================================
397 //=============================================================================
398 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
399 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
400 CORBA::Double theTrimSize)
402 GEOM::GEOM_Object_var aGEOMObject;
404 //Set a not done flag
405 GetOperations()->SetNotDone();
407 if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
411 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
412 (thePnt->GetStudyID(), thePnt->GetEntry());
413 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
414 (theVec->GetStudyID(), theVec->GetEntry());
415 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
419 Handle(GEOM_Object) anObject =
420 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
421 if (!GetOperations()->IsDone() || anObject.IsNull())
422 return aGEOMObject._retn();
424 return GetObject(anObject);
427 //=============================================================================
431 //=============================================================================
432 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
433 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
434 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
436 GEOM::GEOM_Object_var aGEOMObject;
438 //Set a not done flag
439 GetOperations()->SetNotDone();
441 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL)
442 return aGEOMObject._retn();
444 //Get the reference points
446 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
447 (thePnt1->GetStudyID(), thePnt1->GetEntry());
448 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
449 (thePnt2->GetStudyID(), thePnt2->GetEntry());
450 Handle(GEOM_Object) aRef3 = GetOperations()->GetEngine()->GetObject
451 (thePnt3->GetStudyID(), thePnt3->GetEntry());
452 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
453 return aGEOMObject._retn();
457 Handle(GEOM_Object) anObject =
458 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
459 if (!GetOperations()->IsDone() || anObject.IsNull())
460 return aGEOMObject._retn();
462 return GetObject(anObject);
465 //=============================================================================
469 //=============================================================================
470 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
471 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
473 GEOM::GEOM_Object_var aGEOMObject;
475 //Set a not done flag
476 GetOperations()->SetNotDone();
478 if (theFace == NULL) return aGEOMObject._retn();
480 //Get the reference face
482 Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
483 (theFace->GetStudyID(), theFace->GetEntry());
484 if (aRef.IsNull()) return aGEOMObject._retn();
488 Handle(GEOM_Object) anObject =
489 GetOperations()->MakePlaneFace(aRef, theTrimSize);
490 if (!GetOperations()->IsDone() || anObject.IsNull())
491 return aGEOMObject._retn();
493 return GetObject(anObject);
497 //=============================================================================
501 //=============================================================================
502 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
503 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
504 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
505 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
507 GEOM::GEOM_Object_var aGEOMObject;
509 //Set a not done flag
510 GetOperations()->SetNotDone();
513 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
514 theXDX, theXDY, theXDZ,
515 theYDX, theYDY, theYDZ);
516 if (!GetOperations()->IsDone() || anObject.IsNull())
517 return aGEOMObject._retn();
519 return GetObject(anObject);
522 //=============================================================================
524 * MakeTangentPlaneOnFace
526 //=============================================================================
528 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
529 (GEOM::GEOM_Object_ptr theFace,
530 CORBA::Double theParameterU,
531 CORBA::Double theParameterV,
532 CORBA::Double theTrimSize)
534 GEOM::GEOM_Object_var aGEOMObject;
536 //Set a not done flag
537 GetOperations()->SetNotDone();
539 if (theFace == NULL) return aGEOMObject._retn();
541 //Get the reference face
543 Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
544 (theFace->GetStudyID(), theFace->GetEntry());
545 if (aRef.IsNull()) return aGEOMObject._retn();
549 Handle(GEOM_Object) anObject =
550 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
551 if (!GetOperations()->IsDone() || anObject.IsNull())
552 return aGEOMObject._retn();
554 return GetObject(anObject);