1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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);
280 //=============================================================================
284 //=============================================================================
285 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnFace (GEOM::GEOM_Object_ptr theFace)
287 GEOM::GEOM_Object_var aGEOMObject;
289 //Set a not done flag
290 GetOperations()->SetNotDone();
292 //Get the reference face
293 Handle(GEOM_Object) aReference = GetObjectImpl(theFace);
294 if (aReference.IsNull()) return aGEOMObject._retn();
297 Handle(GEOM_Object) anObject = GetOperations()->MakePointOnFace(aReference);
298 if (!GetOperations()->IsDone() || anObject.IsNull())
299 return aGEOMObject._retn();
301 return GetObject(anObject);
304 //=============================================================================
308 //=============================================================================
309 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
310 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
312 GEOM::GEOM_Object_var aGEOMObject;
314 //Set a not done flag
315 GetOperations()->SetNotDone();
317 //Get the reference curve
318 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
319 if (aReference.IsNull()) return aGEOMObject._retn();
322 Handle(GEOM_Object) anObject =
323 GetOperations()->MakeTangentOnCurve(aReference, theParameter);
324 if (!GetOperations()->IsDone() || anObject.IsNull())
325 return aGEOMObject._retn();
327 return GetObject(anObject);
330 //=============================================================================
334 //=============================================================================
335 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
336 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
338 GEOM::GEOM_Object_var aGEOMObject;
340 //Set a not done flag
341 GetOperations()->SetNotDone();
345 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
346 if (!GetOperations()->IsDone() || anObject.IsNull())
347 return aGEOMObject._retn();
349 return GetObject(anObject);
352 //=============================================================================
356 //=============================================================================
357 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
358 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
360 GEOM::GEOM_Object_var aGEOMObject;
362 //Set a not done flag
363 GetOperations()->SetNotDone();
365 //Get the reference points
366 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
367 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
368 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
371 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
372 if (!GetOperations()->IsDone() || anObject.IsNull())
373 return aGEOMObject._retn();
375 return GetObject(anObject);
379 //=============================================================================
383 //=============================================================================
384 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
385 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
387 GEOM::GEOM_Object_var aGEOMObject;
389 //Set a not done flag
390 GetOperations()->SetNotDone();
392 //Get the reference objects
393 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
394 Handle(GEOM_Object) aRef2 = GetObjectImpl(theDir);
395 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
398 Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
399 if (!GetOperations()->IsDone() || anObject.IsNull())
400 return aGEOMObject._retn();
402 return GetObject(anObject);
405 //=============================================================================
409 //=============================================================================
410 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
411 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
413 GEOM::GEOM_Object_var aGEOMObject;
415 //Set a not done flag
416 GetOperations()->SetNotDone();
418 //Get the reference points
419 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
420 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
421 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
424 Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
425 if (!GetOperations()->IsDone() || anObject.IsNull())
426 return aGEOMObject._retn();
428 return GetObject(anObject);
431 //=============================================================================
435 //=============================================================================
436 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
437 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
439 GEOM::GEOM_Object_var aGEOMObject;
441 //Set a not done flag
442 GetOperations()->SetNotDone();
444 //Get the reference points
445 Handle(GEOM_Object) aRef1 = GetObjectImpl(theFace1);
446 Handle(GEOM_Object) aRef2 = GetObjectImpl(theFace2);
447 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
450 Handle(GEOM_Object) anObject =
451 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
452 if (!GetOperations()->IsDone() || anObject.IsNull())
453 return aGEOMObject._retn();
455 return GetObject(anObject);
459 //=============================================================================
463 //=============================================================================
464 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
465 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
466 CORBA::Double theTrimSize)
468 GEOM::GEOM_Object_var aGEOMObject;
470 //Set a not done flag
471 GetOperations()->SetNotDone();
474 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
475 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
476 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
479 Handle(GEOM_Object) anObject =
480 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
481 if (!GetOperations()->IsDone() || anObject.IsNull())
482 return aGEOMObject._retn();
484 return GetObject(anObject);
487 //=============================================================================
491 //=============================================================================
492 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
493 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
494 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
496 GEOM::GEOM_Object_var aGEOMObject;
498 //Set a not done flag
499 GetOperations()->SetNotDone();
501 //Get the reference points
502 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
503 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
504 Handle(GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
505 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
506 return aGEOMObject._retn();
509 Handle(GEOM_Object) anObject =
510 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
511 if (!GetOperations()->IsDone() || anObject.IsNull())
512 return aGEOMObject._retn();
514 return GetObject(anObject);
517 //=============================================================================
521 //=============================================================================
522 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
523 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
525 GEOM::GEOM_Object_var aGEOMObject;
527 //Set a not done flag
528 GetOperations()->SetNotDone();
530 //Get the reference face
531 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
532 if (aRef.IsNull()) return aGEOMObject._retn();
535 Handle(GEOM_Object) anObject =
536 GetOperations()->MakePlaneFace(aRef, 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::MakePlane2Vec
549 (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
550 CORBA::Double theTrimSize)
552 GEOM::GEOM_Object_var aGEOMObject;
554 //Set a not done flag
555 GetOperations()->SetNotDone();
558 Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
559 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
560 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
563 Handle(GEOM_Object) anObject =
564 GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
565 if (!GetOperations()->IsDone() || anObject.IsNull())
566 return aGEOMObject._retn();
568 return GetObject(anObject);
571 //=============================================================================
575 //=============================================================================
576 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
577 (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
578 CORBA::Double theOrientation)
580 GEOM::GEOM_Object_var aGEOMObject;
582 //Set a not done flag
583 GetOperations()->SetNotDone();
586 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
589 Handle(GEOM_Object) anObject =
590 GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
591 if (!GetOperations()->IsDone() || anObject.IsNull())
592 return aGEOMObject._retn();
594 return GetObject(anObject);
597 //=============================================================================
601 //=============================================================================
602 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
603 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
604 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
605 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
607 GEOM::GEOM_Object_var aGEOMObject;
609 //Set a not done flag
610 GetOperations()->SetNotDone();
613 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
614 theXDX, theXDY, theXDZ,
615 theYDX, theYDY, theYDZ);
616 if (!GetOperations()->IsDone() || anObject.IsNull())
617 return aGEOMObject._retn();
619 return GetObject(anObject);
622 //=============================================================================
624 * MakeMarkerFromShape
626 //=============================================================================
627 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerFromShape
628 (GEOM::GEOM_Object_ptr theShape)
630 GEOM::GEOM_Object_var aGEOMObject;
632 //Set a not done flag
633 GetOperations()->SetNotDone();
635 //Get the referenced object
636 Handle(GEOM_Object) aRef = GetObjectImpl(theShape);
637 if (aRef.IsNull()) return aGEOMObject._retn();
640 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerFromShape(aRef);
641 if (!GetOperations()->IsDone() || anObject.IsNull())
642 return aGEOMObject._retn();
644 return GetObject(anObject);
647 //=============================================================================
649 * MakeMarkerPntTwoVec
651 //=============================================================================
652 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerPntTwoVec
653 (GEOM::GEOM_Object_ptr theOrigin,
654 GEOM::GEOM_Object_ptr theXVec,
655 GEOM::GEOM_Object_ptr theYVec)
657 GEOM::GEOM_Object_var aGEOMObject;
659 //Set a not done flag
660 GetOperations()->SetNotDone();
662 //Get the referenced objects
663 Handle(GEOM_Object) aRef1 = GetObjectImpl(theOrigin);
664 Handle(GEOM_Object) aRef2 = GetObjectImpl(theXVec);
665 Handle(GEOM_Object) aRef3 = GetObjectImpl(theYVec);
666 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return aGEOMObject._retn();
669 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerPntTwoVec(aRef1,
672 if (!GetOperations()->IsDone() || anObject.IsNull())
673 return aGEOMObject._retn();
675 return GetObject(anObject);
678 //=============================================================================
680 * MakeTangentPlaneOnFace
682 //=============================================================================
684 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
685 (GEOM::GEOM_Object_ptr theFace,
686 CORBA::Double theParameterU,
687 CORBA::Double theParameterV,
688 CORBA::Double theTrimSize)
690 GEOM::GEOM_Object_var aGEOMObject;
692 //Set a not done flag
693 GetOperations()->SetNotDone();
695 //Get the reference face
696 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
697 if (aRef.IsNull()) return aGEOMObject._retn();
700 Handle(GEOM_Object) anObject =
701 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
702 if (!GetOperations()->IsDone() || anObject.IsNull())
703 return aGEOMObject._retn();
705 return GetObject(anObject);