1 // Copyright (C) 2007-2010 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
23 #include <Standard_Stream.hxx>
25 #include "GEOM_IBasicOperations_i.hh"
27 #include "utilities.h"
29 #include "Utils_ExceptHandlers.hxx"
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
34 //=============================================================================
38 //=============================================================================
39 GEOM_IBasicOperations_i::GEOM_IBasicOperations_i (PortableServer::POA_ptr thePOA,
40 GEOM::GEOM_Gen_ptr theEngine,
41 ::GEOMImpl_IBasicOperations* theImpl)
42 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
44 MESSAGE("GEOM_IBasicOperations_i::GEOM_IBasicOperations_i");
47 //=============================================================================
51 //=============================================================================
52 GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i()
54 MESSAGE("GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i");
58 //=============================================================================
62 //=============================================================================
63 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointXYZ
64 (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
66 GEOM::GEOM_Object_var aGEOMObject;
69 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 //Get the reference point
93 Handle(GEOM_Object) aReference = GetObjectImpl(theReference);
94 if (aReference.IsNull()) return aGEOMObject._retn();
97 Handle(GEOM_Object) anObject =
98 GetOperations()->MakePointWithReference(aReference, theX, theY, theZ);
99 if (!GetOperations()->IsDone() || anObject.IsNull())
100 return aGEOMObject._retn();
102 return GetObject(anObject);
105 //=============================================================================
107 * MakePointOnLinesIntersection
109 //=============================================================================
110 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnLinesIntersection
111 (GEOM::GEOM_Object_ptr theLine1, GEOM::GEOM_Object_ptr theLine2)
113 GEOM::GEOM_Object_var aGEOMObject;
115 //Set a not done flag
116 GetOperations()->SetNotDone();
118 //Get the reference Lines
119 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLine1);
120 Handle(GEOM_Object) aRef2 = GetObjectImpl(theLine2);
121 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
124 Handle(GEOM_Object) anObject =
125 GetOperations()->MakePointOnLinesIntersection(aRef1, aRef2);
126 if (!GetOperations()->IsDone() || anObject.IsNull())
127 return aGEOMObject._retn();
129 return GetObject(anObject);
132 //=============================================================================
136 //=============================================================================
137 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
138 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
140 GEOM::GEOM_Object_var aGEOMObject;
142 //Set a not done flag
143 GetOperations()->SetNotDone();
145 //Get the reference curve
146 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
147 if (aReference.IsNull()) return aGEOMObject._retn();
150 Handle(GEOM_Object) anObject =
151 GetOperations()->MakePointOnCurve(aReference, theParameter);
152 if (!GetOperations()->IsDone() || anObject.IsNull())
153 return aGEOMObject._retn();
155 return GetObject(anObject);
158 //=============================================================================
160 * MakePointOnCurveByLength
162 //=============================================================================
163 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength
164 (GEOM::GEOM_Object_ptr theCurve,
165 CORBA::Double theLength,
166 CORBA::Double theDirection)
168 GEOM::GEOM_Object_var aGEOMObject;
170 //Set a not done flag
171 GetOperations()->SetNotDone();
173 //Get the reference curve
174 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
175 if (aReference.IsNull()) return aGEOMObject._retn();
178 Handle(GEOM_Object) anObject =
179 GetOperations()->MakePointOnCurveByLength(aReference, theLength,
181 if (!GetOperations()->IsDone() || anObject.IsNull())
182 return aGEOMObject._retn();
184 return GetObject(anObject);
187 //=============================================================================
189 * MakePointOnCurveByCoord
191 //=============================================================================
192 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByCoord
193 (GEOM::GEOM_Object_ptr theCurve,
194 CORBA::Double theXParameter,
195 CORBA::Double theYParameter,
196 CORBA::Double theZParameter)
198 GEOM::GEOM_Object_var aGEOMObject;
200 //Set a not done flag
201 GetOperations()->SetNotDone();
203 //Get the reference curve
204 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
205 if (aReference.IsNull()) return aGEOMObject._retn();
208 Handle(GEOM_Object) anObject =
209 GetOperations()->MakePointOnCurveByCoord(aReference, theXParameter,
210 theYParameter, theZParameter);
211 if (!GetOperations()->IsDone() || anObject.IsNull())
212 return aGEOMObject._retn();
214 return GetObject(anObject);
217 //=============================================================================
221 //=============================================================================
222 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
223 (GEOM::GEOM_Object_ptr theSurface,
224 CORBA::Double theUParameter,
225 CORBA::Double theVParameter)
227 GEOM::GEOM_Object_var aGEOMObject;
229 //Set a not done flag
230 GetOperations()->SetNotDone();
232 //Get the reference surface
233 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
234 if (aReference.IsNull()) return aGEOMObject._retn();
237 Handle(GEOM_Object) anObject =
238 GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
239 if (!GetOperations()->IsDone() || anObject.IsNull())
240 return aGEOMObject._retn();
242 return GetObject(anObject);
245 //=============================================================================
247 * MakePointOnSurfaceByCoord
249 //=============================================================================
250 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord
251 (GEOM::GEOM_Object_ptr theSurface,
252 CORBA::Double theXParameter,
253 CORBA::Double theYParameter,
254 CORBA::Double theZParameter)
256 GEOM::GEOM_Object_var aGEOMObject;
258 //Set a not done flag
259 GetOperations()->SetNotDone();
261 //Get the reference surface
262 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
263 if (aReference.IsNull()) return aGEOMObject._retn();
266 Handle(GEOM_Object) anObject =
267 GetOperations()->MakePointOnSurfaceByCoord(aReference, theXParameter,
268 theYParameter, theZParameter);
269 if (!GetOperations()->IsDone() || anObject.IsNull())
270 return aGEOMObject._retn();
272 return GetObject(anObject);
276 //=============================================================================
280 //=============================================================================
281 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
282 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
284 GEOM::GEOM_Object_var aGEOMObject;
286 //Set a not done flag
287 GetOperations()->SetNotDone();
289 //Get the reference curve
290 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
291 if (aReference.IsNull()) return aGEOMObject._retn();
294 Handle(GEOM_Object) anObject =
295 GetOperations()->MakeTangentOnCurve(aReference, theParameter);
296 if (!GetOperations()->IsDone() || anObject.IsNull())
297 return aGEOMObject._retn();
299 return GetObject(anObject);
302 //=============================================================================
306 //=============================================================================
307 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
308 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
310 GEOM::GEOM_Object_var aGEOMObject;
312 //Set a not done flag
313 GetOperations()->SetNotDone();
317 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
318 if (!GetOperations()->IsDone() || anObject.IsNull())
319 return aGEOMObject._retn();
321 return GetObject(anObject);
324 //=============================================================================
328 //=============================================================================
329 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
330 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
332 GEOM::GEOM_Object_var aGEOMObject;
334 //Set a not done flag
335 GetOperations()->SetNotDone();
337 //Get the reference points
338 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
339 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
340 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
343 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
344 if (!GetOperations()->IsDone() || anObject.IsNull())
345 return aGEOMObject._retn();
347 return GetObject(anObject);
351 //=============================================================================
355 //=============================================================================
356 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
357 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
359 GEOM::GEOM_Object_var aGEOMObject;
361 //Set a not done flag
362 GetOperations()->SetNotDone();
364 //Get the reference objects
365 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
366 Handle(GEOM_Object) aRef2 = GetObjectImpl(theDir);
367 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
370 Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
371 if (!GetOperations()->IsDone() || anObject.IsNull())
372 return aGEOMObject._retn();
374 return GetObject(anObject);
377 //=============================================================================
381 //=============================================================================
382 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
383 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
385 GEOM::GEOM_Object_var aGEOMObject;
387 //Set a not done flag
388 GetOperations()->SetNotDone();
390 //Get the reference points
391 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
392 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
393 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
396 Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
397 if (!GetOperations()->IsDone() || anObject.IsNull())
398 return aGEOMObject._retn();
400 return GetObject(anObject);
403 //=============================================================================
407 //=============================================================================
408 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
409 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
411 GEOM::GEOM_Object_var aGEOMObject;
413 //Set a not done flag
414 GetOperations()->SetNotDone();
416 //Get the reference points
417 Handle(GEOM_Object) aRef1 = GetObjectImpl(theFace1);
418 Handle(GEOM_Object) aRef2 = GetObjectImpl(theFace2);
419 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
422 Handle(GEOM_Object) anObject =
423 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
424 if (!GetOperations()->IsDone() || anObject.IsNull())
425 return aGEOMObject._retn();
427 return GetObject(anObject);
431 //=============================================================================
435 //=============================================================================
436 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
437 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
438 CORBA::Double theTrimSize)
440 GEOM::GEOM_Object_var aGEOMObject;
442 //Set a not done flag
443 GetOperations()->SetNotDone();
446 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
447 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
448 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
451 Handle(GEOM_Object) anObject =
452 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
453 if (!GetOperations()->IsDone() || anObject.IsNull())
454 return aGEOMObject._retn();
456 return GetObject(anObject);
459 //=============================================================================
463 //=============================================================================
464 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
465 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
466 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
468 GEOM::GEOM_Object_var aGEOMObject;
470 //Set a not done flag
471 GetOperations()->SetNotDone();
473 //Get the reference points
474 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
475 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
476 Handle(GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
477 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
478 return aGEOMObject._retn();
481 Handle(GEOM_Object) anObject =
482 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
483 if (!GetOperations()->IsDone() || anObject.IsNull())
484 return aGEOMObject._retn();
486 return GetObject(anObject);
489 //=============================================================================
493 //=============================================================================
494 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
495 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
497 GEOM::GEOM_Object_var aGEOMObject;
499 //Set a not done flag
500 GetOperations()->SetNotDone();
502 //Get the reference face
503 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
504 if (aRef.IsNull()) return aGEOMObject._retn();
507 Handle(GEOM_Object) anObject =
508 GetOperations()->MakePlaneFace(aRef, theTrimSize);
509 if (!GetOperations()->IsDone() || anObject.IsNull())
510 return aGEOMObject._retn();
512 return GetObject(anObject);
515 //=============================================================================
519 //=============================================================================
520 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec
521 (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
522 CORBA::Double theTrimSize)
524 GEOM::GEOM_Object_var aGEOMObject;
526 //Set a not done flag
527 GetOperations()->SetNotDone();
530 Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
531 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
532 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
535 Handle(GEOM_Object) anObject =
536 GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
537 if (!GetOperations()->IsDone() || anObject.IsNull())
538 return aGEOMObject._retn();
540 return GetObject(anObject);
543 //=============================================================================
547 //=============================================================================
548 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
549 (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
550 CORBA::Double theOrientation)
552 GEOM::GEOM_Object_var aGEOMObject;
554 //Set a not done flag
555 GetOperations()->SetNotDone();
558 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
561 Handle(GEOM_Object) anObject =
562 GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
563 if (!GetOperations()->IsDone() || anObject.IsNull())
564 return aGEOMObject._retn();
566 return GetObject(anObject);
569 //=============================================================================
573 //=============================================================================
574 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
575 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
576 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
577 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
579 GEOM::GEOM_Object_var aGEOMObject;
581 //Set a not done flag
582 GetOperations()->SetNotDone();
585 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
586 theXDX, theXDY, theXDZ,
587 theYDX, theYDY, theYDZ);
588 if (!GetOperations()->IsDone() || anObject.IsNull())
589 return aGEOMObject._retn();
591 return GetObject(anObject);
594 //=============================================================================
596 * MakeMarkerFromShape
598 //=============================================================================
599 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerFromShape
600 (GEOM::GEOM_Object_ptr theShape)
602 GEOM::GEOM_Object_var aGEOMObject;
604 //Set a not done flag
605 GetOperations()->SetNotDone();
607 //Get the referenced object
608 Handle(GEOM_Object) aRef = GetObjectImpl(theShape);
609 if (aRef.IsNull()) return aGEOMObject._retn();
612 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerFromShape(aRef);
613 if (!GetOperations()->IsDone() || anObject.IsNull())
614 return aGEOMObject._retn();
616 return GetObject(anObject);
619 //=============================================================================
621 * MakeMarkerPntTwoVec
623 //=============================================================================
624 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerPntTwoVec
625 (GEOM::GEOM_Object_ptr theOrigin,
626 GEOM::GEOM_Object_ptr theXVec,
627 GEOM::GEOM_Object_ptr theYVec)
629 GEOM::GEOM_Object_var aGEOMObject;
631 //Set a not done flag
632 GetOperations()->SetNotDone();
634 //Get the referenced objects
635 Handle(GEOM_Object) aRef1 = GetObjectImpl(theOrigin);
636 Handle(GEOM_Object) aRef2 = GetObjectImpl(theXVec);
637 Handle(GEOM_Object) aRef3 = GetObjectImpl(theYVec);
638 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return aGEOMObject._retn();
641 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerPntTwoVec(aRef1,
644 if (!GetOperations()->IsDone() || anObject.IsNull())
645 return aGEOMObject._retn();
647 return GetObject(anObject);
650 //=============================================================================
652 * MakeTangentPlaneOnFace
654 //=============================================================================
656 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
657 (GEOM::GEOM_Object_ptr theFace,
658 CORBA::Double theParameterU,
659 CORBA::Double theParameterV,
660 CORBA::Double theTrimSize)
662 GEOM::GEOM_Object_var aGEOMObject;
664 //Set a not done flag
665 GetOperations()->SetNotDone();
667 //Get the reference face
668 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
669 if (aRef.IsNull()) return aGEOMObject._retn();
672 Handle(GEOM_Object) anObject =
673 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
674 if (!GetOperations()->IsDone() || anObject.IsNull())
675 return aGEOMObject._retn();
677 return GetObject(anObject);