1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include "GEOM_IBasicOperations_i.hh"
26 #include "utilities.h"
28 #include "Utils_ExceptHandlers.hxx"
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
33 //=============================================================================
37 //=============================================================================
38 GEOM_IBasicOperations_i::GEOM_IBasicOperations_i (PortableServer::POA_ptr thePOA,
39 GEOM::GEOM_Gen_ptr theEngine,
40 ::GEOMImpl_IBasicOperations* theImpl)
41 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
43 MESSAGE("GEOM_IBasicOperations_i::GEOM_IBasicOperations_i");
46 //=============================================================================
50 //=============================================================================
51 GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i()
53 MESSAGE("GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i");
57 //=============================================================================
61 //=============================================================================
62 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointXYZ
63 (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
65 GEOM::GEOM_Object_var aGEOMObject;
68 GetOperations()->SetNotDone();
72 Handle(GEOM_Object) anObject = GetOperations()->MakePointXYZ(theX, theY, theZ);
73 if (!GetOperations()->IsDone() || anObject.IsNull())
74 return aGEOMObject._retn();
76 return GetObject(anObject);
79 //=============================================================================
81 * MakePointWithReference
83 //=============================================================================
84 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointWithReference
85 (GEOM::GEOM_Object_ptr theReference, CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
87 GEOM::GEOM_Object_var aGEOMObject;
90 GetOperations()->SetNotDone();
92 if(theReference == NULL) return aGEOMObject._retn();
94 //Get the reference point
96 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
97 (theReference->GetStudyID(), theReference->GetEntry());
98 if (aRefernce.IsNull()) return aGEOMObject._retn();
102 Handle(GEOM_Object) anObject =
103 GetOperations()->MakePointWithReference(aRefernce, theX, theY, theZ);
104 if (!GetOperations()->IsDone() || anObject.IsNull())
105 return aGEOMObject._retn();
107 return GetObject(anObject);
110 //=============================================================================
112 * MakePointOnLinesIntersection
114 //=============================================================================
115 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnLinesIntersection
116 (GEOM::GEOM_Object_ptr theLine1, GEOM::GEOM_Object_ptr theLine2)
118 GEOM::GEOM_Object_var aGEOMObject;
120 //Set a not done flag
121 GetOperations()->SetNotDone();
123 if (theLine1 == NULL || theLine2 == NULL) return aGEOMObject._retn();
125 //Get the reference Lines
127 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
128 (theLine1->GetStudyID(), theLine1->GetEntry());
129 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
130 (theLine2->GetStudyID(), theLine2->GetEntry());
131 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
135 Handle(GEOM_Object) anObject =
136 GetOperations()->MakePointOnLinesIntersection(aRef1, aRef2);
137 if (!GetOperations()->IsDone() || anObject.IsNull())
138 return aGEOMObject._retn();
140 return GetObject(anObject);
144 //=============================================================================
148 //=============================================================================
149 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
150 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
152 GEOM::GEOM_Object_var aGEOMObject;
154 //Set a not done flag
155 GetOperations()->SetNotDone();
157 if (theCurve == NULL) return aGEOMObject._retn();
159 //Get the reference curve
161 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
162 (theCurve->GetStudyID(), theCurve->GetEntry());
163 if (aRefernce.IsNull()) return aGEOMObject._retn();
167 Handle(GEOM_Object) anObject =
168 GetOperations()->MakePointOnCurve(aRefernce, theParameter);
169 if (!GetOperations()->IsDone() || anObject.IsNull())
170 return aGEOMObject._retn();
172 return GetObject(anObject);
176 //=============================================================================
180 //=============================================================================
181 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
182 (GEOM::GEOM_Object_ptr theSurface,
183 CORBA::Double theUParameter,
184 CORBA::Double theVParameter)
186 GEOM::GEOM_Object_var aGEOMObject;
188 //Set a not done flag
189 GetOperations()->SetNotDone();
191 if (theSurface == NULL) return aGEOMObject._retn();
193 //Get the reference surface
194 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
195 (theSurface->GetStudyID(), theSurface->GetEntry());
196 if (aRefernce.IsNull()) return aGEOMObject._retn();
199 Handle(GEOM_Object) anObject =
200 GetOperations()->MakePointOnSurface(aRefernce, theUParameter, theVParameter);
201 if (!GetOperations()->IsDone() || anObject.IsNull())
202 return aGEOMObject._retn();
204 return GetObject(anObject);
208 //=============================================================================
212 //=============================================================================
213 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
214 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
216 GEOM::GEOM_Object_var aGEOMObject;
218 //Set a not done flag
219 GetOperations()->SetNotDone();
221 if (theCurve == NULL) return aGEOMObject._retn();
223 //Get the reference curve
225 Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject
226 (theCurve->GetStudyID(), theCurve->GetEntry());
227 if (aRefernce.IsNull()) return aGEOMObject._retn();
231 Handle(GEOM_Object) anObject =
232 GetOperations()->MakeTangentOnCurve(aRefernce, theParameter);
233 if (!GetOperations()->IsDone() || anObject.IsNull())
234 return aGEOMObject._retn();
236 return GetObject(anObject);
240 //=============================================================================
244 //=============================================================================
245 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
246 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
248 GEOM::GEOM_Object_var aGEOMObject;
250 //Set a not done flag
251 GetOperations()->SetNotDone();
255 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
256 if (!GetOperations()->IsDone() || anObject.IsNull())
257 return aGEOMObject._retn();
259 return GetObject(anObject);
262 //=============================================================================
266 //=============================================================================
267 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
268 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
270 GEOM::GEOM_Object_var aGEOMObject;
272 //Set a not done flag
273 GetOperations()->SetNotDone();
275 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
277 //Get the reference points
279 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
280 (thePnt1->GetStudyID(), thePnt1->GetEntry());
281 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
282 (thePnt2->GetStudyID(), thePnt2->GetEntry());
283 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
287 Handle(GEOM_Object) anObject =
288 GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
289 if (!GetOperations()->IsDone() || anObject.IsNull())
290 return aGEOMObject._retn();
292 return GetObject(anObject);
296 //=============================================================================
300 //=============================================================================
301 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
302 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
304 GEOM::GEOM_Object_var aGEOMObject;
306 //Set a not done flag
307 GetOperations()->SetNotDone();
309 if (thePnt == NULL || theDir == NULL) return aGEOMObject._retn();
311 //Get the reference objects
313 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
314 (thePnt->GetStudyID(), thePnt->GetEntry());
315 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
316 (theDir->GetStudyID(), theDir->GetEntry());
317 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
321 Handle(GEOM_Object) anObject =
322 GetOperations()->MakeLine(aRef1, aRef2);
323 if (!GetOperations()->IsDone() || anObject.IsNull())
324 return aGEOMObject._retn();
326 return GetObject(anObject);
329 //=============================================================================
333 //=============================================================================
334 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
335 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
337 GEOM::GEOM_Object_var aGEOMObject;
339 //Set a not done flag
340 GetOperations()->SetNotDone();
342 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
344 //Get the reference points
346 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
347 (thePnt1->GetStudyID(), thePnt1->GetEntry());
348 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
349 (thePnt2->GetStudyID(), thePnt2->GetEntry());
350 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
354 Handle(GEOM_Object) anObject =
355 GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
356 if (!GetOperations()->IsDone() || anObject.IsNull())
357 return aGEOMObject._retn();
359 return GetObject(anObject);
362 //=============================================================================
366 //=============================================================================
367 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
368 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
370 GEOM::GEOM_Object_var aGEOMObject;
372 //Set a not done flag
373 GetOperations()->SetNotDone();
375 if (theFace1 == NULL || theFace2 == NULL) return aGEOMObject._retn();
377 //Get the reference points
379 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
380 (theFace1->GetStudyID(), theFace1->GetEntry());
381 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
382 (theFace2->GetStudyID(), theFace2->GetEntry());
383 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
387 Handle(GEOM_Object) anObject =
388 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
389 if (!GetOperations()->IsDone() || anObject.IsNull())
390 return aGEOMObject._retn();
392 return GetObject(anObject);
395 //=============================================================================
399 //=============================================================================
400 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
401 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
402 CORBA::Double theTrimSize)
404 GEOM::GEOM_Object_var aGEOMObject;
406 //Set a not done flag
407 GetOperations()->SetNotDone();
409 if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
413 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
414 (thePnt->GetStudyID(), thePnt->GetEntry());
415 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
416 (theVec->GetStudyID(), theVec->GetEntry());
417 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
421 Handle(GEOM_Object) anObject =
422 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
423 if (!GetOperations()->IsDone() || anObject.IsNull())
424 return aGEOMObject._retn();
426 return GetObject(anObject);
429 //=============================================================================
433 //=============================================================================
434 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
435 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
436 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
438 GEOM::GEOM_Object_var aGEOMObject;
440 //Set a not done flag
441 GetOperations()->SetNotDone();
443 if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL)
444 return aGEOMObject._retn();
446 //Get the reference points
448 Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject
449 (thePnt1->GetStudyID(), thePnt1->GetEntry());
450 Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject
451 (thePnt2->GetStudyID(), thePnt2->GetEntry());
452 Handle(GEOM_Object) aRef3 = GetOperations()->GetEngine()->GetObject
453 (thePnt3->GetStudyID(), thePnt3->GetEntry());
454 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
455 return aGEOMObject._retn();
459 Handle(GEOM_Object) anObject =
460 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
461 if (!GetOperations()->IsDone() || anObject.IsNull())
462 return aGEOMObject._retn();
464 return GetObject(anObject);
467 //=============================================================================
471 //=============================================================================
472 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
473 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
475 GEOM::GEOM_Object_var aGEOMObject;
477 //Set a not done flag
478 GetOperations()->SetNotDone();
480 if (theFace == NULL) return aGEOMObject._retn();
482 //Get the reference face
484 Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
485 (theFace->GetStudyID(), theFace->GetEntry());
486 if (aRef.IsNull()) return aGEOMObject._retn();
490 Handle(GEOM_Object) anObject =
491 GetOperations()->MakePlaneFace(aRef, theTrimSize);
492 if (!GetOperations()->IsDone() || anObject.IsNull())
493 return aGEOMObject._retn();
495 return GetObject(anObject);
499 //=============================================================================
503 //=============================================================================
504 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
505 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
506 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
507 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
509 GEOM::GEOM_Object_var aGEOMObject;
511 //Set a not done flag
512 GetOperations()->SetNotDone();
515 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
516 theXDX, theXDY, theXDZ,
517 theYDX, theYDY, theYDZ);
518 if (!GetOperations()->IsDone() || anObject.IsNull())
519 return aGEOMObject._retn();
521 return GetObject(anObject);
524 //=============================================================================
526 * MakeTangentPlaneOnFace
528 //=============================================================================
530 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
531 (GEOM::GEOM_Object_ptr theFace,
532 CORBA::Double theParameterU,
533 CORBA::Double theParameterV,
534 CORBA::Double theTrimSize)
536 GEOM::GEOM_Object_var aGEOMObject;
538 //Set a not done flag
539 GetOperations()->SetNotDone();
541 if (theFace == NULL) return aGEOMObject._retn();
543 //Get the reference face
545 Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject
546 (theFace->GetStudyID(), theFace->GetEntry());
547 if (aRef.IsNull()) return aGEOMObject._retn();
551 Handle(GEOM_Object) anObject =
552 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
553 if (!GetOperations()->IsDone() || anObject.IsNull())
554 return aGEOMObject._retn();
556 return GetObject(anObject);