1 // Copyright (C) 2007-2011 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 GEOM::GEOM_Object_ptr theStartPoint)
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();
177 //Get the reference point (can be NULL)
178 Handle(GEOM_Object) aRefPoint;
179 if (!CORBA::is_nil(theStartPoint)) {
180 aRefPoint = GetObjectImpl(theStartPoint);
184 Handle(GEOM_Object) anObject =
185 GetOperations()->MakePointOnCurveByLength(aReference, theLength, aRefPoint);
186 if (!GetOperations()->IsDone() || anObject.IsNull())
187 return aGEOMObject._retn();
189 return GetObject(anObject);
192 //=============================================================================
194 * MakePointOnCurveByCoord
196 //=============================================================================
197 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByCoord
198 (GEOM::GEOM_Object_ptr theCurve,
199 CORBA::Double theXParameter,
200 CORBA::Double theYParameter,
201 CORBA::Double theZParameter)
203 GEOM::GEOM_Object_var aGEOMObject;
205 //Set a not done flag
206 GetOperations()->SetNotDone();
208 //Get the reference curve
209 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
210 if (aReference.IsNull()) return aGEOMObject._retn();
213 Handle(GEOM_Object) anObject =
214 GetOperations()->MakePointOnCurveByCoord(aReference, theXParameter,
215 theYParameter, theZParameter);
216 if (!GetOperations()->IsDone() || anObject.IsNull())
217 return aGEOMObject._retn();
219 return GetObject(anObject);
222 //=============================================================================
226 //=============================================================================
227 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
228 (GEOM::GEOM_Object_ptr theSurface,
229 CORBA::Double theUParameter,
230 CORBA::Double theVParameter)
232 GEOM::GEOM_Object_var aGEOMObject;
234 //Set a not done flag
235 GetOperations()->SetNotDone();
237 //Get the reference surface
238 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
239 if (aReference.IsNull()) return aGEOMObject._retn();
242 Handle(GEOM_Object) anObject =
243 GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
244 if (!GetOperations()->IsDone() || anObject.IsNull())
245 return aGEOMObject._retn();
247 return GetObject(anObject);
250 //=============================================================================
252 * MakePointOnSurfaceByCoord
254 //=============================================================================
255 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord
256 (GEOM::GEOM_Object_ptr theSurface,
257 CORBA::Double theXParameter,
258 CORBA::Double theYParameter,
259 CORBA::Double theZParameter)
261 GEOM::GEOM_Object_var aGEOMObject;
263 //Set a not done flag
264 GetOperations()->SetNotDone();
266 //Get the reference surface
267 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
268 if (aReference.IsNull()) return aGEOMObject._retn();
271 Handle(GEOM_Object) anObject =
272 GetOperations()->MakePointOnSurfaceByCoord(aReference, theXParameter,
273 theYParameter, theZParameter);
274 if (!GetOperations()->IsDone() || anObject.IsNull())
275 return aGEOMObject._retn();
277 return GetObject(anObject);
281 //=============================================================================
285 //=============================================================================
286 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
287 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
289 GEOM::GEOM_Object_var aGEOMObject;
291 //Set a not done flag
292 GetOperations()->SetNotDone();
294 //Get the reference curve
295 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
296 if (aReference.IsNull()) return aGEOMObject._retn();
299 Handle(GEOM_Object) anObject =
300 GetOperations()->MakeTangentOnCurve(aReference, theParameter);
301 if (!GetOperations()->IsDone() || anObject.IsNull())
302 return aGEOMObject._retn();
304 return GetObject(anObject);
307 //=============================================================================
311 //=============================================================================
312 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
313 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
315 GEOM::GEOM_Object_var aGEOMObject;
317 //Set a not done flag
318 GetOperations()->SetNotDone();
322 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
323 if (!GetOperations()->IsDone() || anObject.IsNull())
324 return aGEOMObject._retn();
326 return GetObject(anObject);
329 //=============================================================================
333 //=============================================================================
334 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
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 //Get the reference points
343 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
344 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
345 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
348 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
349 if (!GetOperations()->IsDone() || anObject.IsNull())
350 return aGEOMObject._retn();
352 return GetObject(anObject);
356 //=============================================================================
360 //=============================================================================
361 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
362 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
364 GEOM::GEOM_Object_var aGEOMObject;
366 //Set a not done flag
367 GetOperations()->SetNotDone();
369 //Get the reference objects
370 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
371 Handle(GEOM_Object) aRef2 = GetObjectImpl(theDir);
372 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
375 Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
376 if (!GetOperations()->IsDone() || anObject.IsNull())
377 return aGEOMObject._retn();
379 return GetObject(anObject);
382 //=============================================================================
386 //=============================================================================
387 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
388 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
390 GEOM::GEOM_Object_var aGEOMObject;
392 //Set a not done flag
393 GetOperations()->SetNotDone();
395 //Get the reference points
396 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
397 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
398 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
401 Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
402 if (!GetOperations()->IsDone() || anObject.IsNull())
403 return aGEOMObject._retn();
405 return GetObject(anObject);
408 //=============================================================================
412 //=============================================================================
413 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
414 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
416 GEOM::GEOM_Object_var aGEOMObject;
418 //Set a not done flag
419 GetOperations()->SetNotDone();
421 //Get the reference points
422 Handle(GEOM_Object) aRef1 = GetObjectImpl(theFace1);
423 Handle(GEOM_Object) aRef2 = GetObjectImpl(theFace2);
424 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
427 Handle(GEOM_Object) anObject =
428 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
429 if (!GetOperations()->IsDone() || anObject.IsNull())
430 return aGEOMObject._retn();
432 return GetObject(anObject);
436 //=============================================================================
440 //=============================================================================
441 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
442 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
443 CORBA::Double theTrimSize)
445 GEOM::GEOM_Object_var aGEOMObject;
447 //Set a not done flag
448 GetOperations()->SetNotDone();
451 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
452 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
453 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
456 Handle(GEOM_Object) anObject =
457 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
458 if (!GetOperations()->IsDone() || anObject.IsNull())
459 return aGEOMObject._retn();
461 return GetObject(anObject);
464 //=============================================================================
468 //=============================================================================
469 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
470 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
471 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
473 GEOM::GEOM_Object_var aGEOMObject;
475 //Set a not done flag
476 GetOperations()->SetNotDone();
478 //Get the reference points
479 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
480 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
481 Handle(GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
482 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
483 return aGEOMObject._retn();
486 Handle(GEOM_Object) anObject =
487 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
488 if (!GetOperations()->IsDone() || anObject.IsNull())
489 return aGEOMObject._retn();
491 return GetObject(anObject);
494 //=============================================================================
498 //=============================================================================
499 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
500 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
502 GEOM::GEOM_Object_var aGEOMObject;
504 //Set a not done flag
505 GetOperations()->SetNotDone();
507 //Get the reference face
508 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
509 if (aRef.IsNull()) return aGEOMObject._retn();
512 Handle(GEOM_Object) anObject =
513 GetOperations()->MakePlaneFace(aRef, theTrimSize);
514 if (!GetOperations()->IsDone() || anObject.IsNull())
515 return aGEOMObject._retn();
517 return GetObject(anObject);
520 //=============================================================================
524 //=============================================================================
525 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec
526 (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
527 CORBA::Double theTrimSize)
529 GEOM::GEOM_Object_var aGEOMObject;
531 //Set a not done flag
532 GetOperations()->SetNotDone();
535 Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
536 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
537 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
540 Handle(GEOM_Object) anObject =
541 GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
542 if (!GetOperations()->IsDone() || anObject.IsNull())
543 return aGEOMObject._retn();
545 return GetObject(anObject);
548 //=============================================================================
552 //=============================================================================
553 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
554 (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
555 CORBA::Double theOrientation)
557 GEOM::GEOM_Object_var aGEOMObject;
559 //Set a not done flag
560 GetOperations()->SetNotDone();
563 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
566 Handle(GEOM_Object) anObject =
567 GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
568 if (!GetOperations()->IsDone() || anObject.IsNull())
569 return aGEOMObject._retn();
571 return GetObject(anObject);
574 //=============================================================================
578 //=============================================================================
579 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
580 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
581 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
582 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
584 GEOM::GEOM_Object_var aGEOMObject;
586 //Set a not done flag
587 GetOperations()->SetNotDone();
590 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
591 theXDX, theXDY, theXDZ,
592 theYDX, theYDY, theYDZ);
593 if (!GetOperations()->IsDone() || anObject.IsNull())
594 return aGEOMObject._retn();
596 return GetObject(anObject);
599 //=============================================================================
601 * MakeMarkerFromShape
603 //=============================================================================
604 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerFromShape
605 (GEOM::GEOM_Object_ptr theShape)
607 GEOM::GEOM_Object_var aGEOMObject;
609 //Set a not done flag
610 GetOperations()->SetNotDone();
612 //Get the referenced object
613 Handle(GEOM_Object) aRef = GetObjectImpl(theShape);
614 if (aRef.IsNull()) return aGEOMObject._retn();
617 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerFromShape(aRef);
618 if (!GetOperations()->IsDone() || anObject.IsNull())
619 return aGEOMObject._retn();
621 return GetObject(anObject);
624 //=============================================================================
626 * MakeMarkerPntTwoVec
628 //=============================================================================
629 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerPntTwoVec
630 (GEOM::GEOM_Object_ptr theOrigin,
631 GEOM::GEOM_Object_ptr theXVec,
632 GEOM::GEOM_Object_ptr theYVec)
634 GEOM::GEOM_Object_var aGEOMObject;
636 //Set a not done flag
637 GetOperations()->SetNotDone();
639 //Get the referenced objects
640 Handle(GEOM_Object) aRef1 = GetObjectImpl(theOrigin);
641 Handle(GEOM_Object) aRef2 = GetObjectImpl(theXVec);
642 Handle(GEOM_Object) aRef3 = GetObjectImpl(theYVec);
643 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return aGEOMObject._retn();
646 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerPntTwoVec(aRef1,
649 if (!GetOperations()->IsDone() || anObject.IsNull())
650 return aGEOMObject._retn();
652 return GetObject(anObject);
655 //=============================================================================
657 * MakeTangentPlaneOnFace
659 //=============================================================================
661 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
662 (GEOM::GEOM_Object_ptr theFace,
663 CORBA::Double theParameterU,
664 CORBA::Double theParameterV,
665 CORBA::Double theTrimSize)
667 GEOM::GEOM_Object_var aGEOMObject;
669 //Set a not done flag
670 GetOperations()->SetNotDone();
672 //Get the reference face
673 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
674 if (aRef.IsNull()) return aGEOMObject._retn();
677 Handle(GEOM_Object) anObject =
678 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
679 if (!GetOperations()->IsDone() || anObject.IsNull())
680 return aGEOMObject._retn();
682 return GetObject(anObject);