1 // Copyright (C) 2007-2023 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,
139 CORBA::Double theParameter,
140 CORBA::Boolean takeOrientationIntoAccount)
142 GEOM::GEOM_Object_var aGEOMObject;
144 //Set a not done flag
145 GetOperations()->SetNotDone();
147 //Get the reference curve
148 Handle(::GEOM_Object) aReference = GetObjectImpl(theCurve);
149 if (aReference.IsNull()) return aGEOMObject._retn();
152 Handle(::GEOM_Object) anObject = GetOperations()->MakePointOnCurve
153 (aReference, theParameter, takeOrientationIntoAccount);
154 if (!GetOperations()->IsDone() || anObject.IsNull())
155 return aGEOMObject._retn();
157 return GetObject(anObject);
160 //=============================================================================
162 * MakePointOnCurveByLength
164 //=============================================================================
165 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength
166 (GEOM::GEOM_Object_ptr theCurve,
167 CORBA::Double theLength,
168 GEOM::GEOM_Object_ptr theStartPoint)
170 GEOM::GEOM_Object_var aGEOMObject;
172 //Set a not done flag
173 GetOperations()->SetNotDone();
175 //Get the reference curve
176 Handle(::GEOM_Object) aReference = GetObjectImpl(theCurve);
177 if (aReference.IsNull()) return aGEOMObject._retn();
179 //Get the reference point (can be NULL)
180 Handle(::GEOM_Object) aRefPoint;
181 if (!CORBA::is_nil(theStartPoint)) {
182 aRefPoint = GetObjectImpl(theStartPoint);
186 Handle(::GEOM_Object) anObject =
187 GetOperations()->MakePointOnCurveByLength(aReference, theLength, aRefPoint);
188 if (!GetOperations()->IsDone() || anObject.IsNull())
189 return aGEOMObject._retn();
191 return GetObject(anObject);
194 //=============================================================================
196 * MakePointOnCurveByCoord
198 //=============================================================================
199 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByCoord
200 (GEOM::GEOM_Object_ptr theCurve,
201 CORBA::Double theXParameter,
202 CORBA::Double theYParameter,
203 CORBA::Double theZParameter)
205 GEOM::GEOM_Object_var aGEOMObject;
207 //Set a not done flag
208 GetOperations()->SetNotDone();
210 //Get the reference curve
211 Handle(::GEOM_Object) aReference = GetObjectImpl(theCurve);
212 if (aReference.IsNull()) return aGEOMObject._retn();
215 Handle(::GEOM_Object) anObject =
216 GetOperations()->MakePointOnCurveByCoord(aReference, theXParameter,
217 theYParameter, theZParameter);
218 if (!GetOperations()->IsDone() || anObject.IsNull())
219 return aGEOMObject._retn();
221 return GetObject(anObject);
224 //=============================================================================
228 //=============================================================================
229 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
230 (GEOM::GEOM_Object_ptr theSurface,
231 CORBA::Double theUParameter,
232 CORBA::Double theVParameter)
234 GEOM::GEOM_Object_var aGEOMObject;
236 //Set a not done flag
237 GetOperations()->SetNotDone();
239 //Get the reference surface
240 Handle(::GEOM_Object) aReference = GetObjectImpl(theSurface);
241 if (aReference.IsNull()) return aGEOMObject._retn();
244 Handle(::GEOM_Object) anObject =
245 GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
246 if (!GetOperations()->IsDone() || anObject.IsNull())
247 return aGEOMObject._retn();
249 return GetObject(anObject);
252 //=============================================================================
254 * MakePointOnSurfaceByCoord
256 //=============================================================================
257 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord
258 (GEOM::GEOM_Object_ptr theSurface,
259 CORBA::Double theXParameter,
260 CORBA::Double theYParameter,
261 CORBA::Double theZParameter)
263 GEOM::GEOM_Object_var aGEOMObject;
265 //Set a not done flag
266 GetOperations()->SetNotDone();
268 //Get the reference surface
269 Handle(::GEOM_Object) aReference = GetObjectImpl(theSurface);
270 if (aReference.IsNull()) return aGEOMObject._retn();
273 Handle(::GEOM_Object) anObject =
274 GetOperations()->MakePointOnSurfaceByCoord(aReference, theXParameter,
275 theYParameter, theZParameter);
276 if (!GetOperations()->IsDone() || anObject.IsNull())
277 return aGEOMObject._retn();
279 return GetObject(anObject);
282 //=============================================================================
286 //=============================================================================
287 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnFace (GEOM::GEOM_Object_ptr theFace,
288 CORBA::Long theNumberOfPnts)
290 GEOM::GEOM_Object_var aGEOMObject;
292 //Set a not done flag
293 GetOperations()->SetNotDone();
295 //Get the reference face
296 Handle(::GEOM_Object) aReference = GetObjectImpl(theFace);
297 if (aReference.IsNull()) return aGEOMObject._retn();
300 Handle(::GEOM_Object) anObject = GetOperations()->MakePointOnFace(aReference, theNumberOfPnts);
301 if (!GetOperations()->IsDone() || anObject.IsNull())
302 return aGEOMObject._retn();
304 return GetObject(anObject);
307 //=============================================================================
311 //=============================================================================
312 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
313 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
315 GEOM::GEOM_Object_var aGEOMObject;
317 //Set a not done flag
318 GetOperations()->SetNotDone();
320 //Get the reference curve
321 Handle(::GEOM_Object) aReference = GetObjectImpl(theCurve);
322 if (aReference.IsNull()) return aGEOMObject._retn();
325 Handle(::GEOM_Object) anObject =
326 GetOperations()->MakeTangentOnCurve(aReference, theParameter);
327 if (!GetOperations()->IsDone() || anObject.IsNull())
328 return aGEOMObject._retn();
330 return GetObject(anObject);
333 //=============================================================================
337 //=============================================================================
338 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
339 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
341 GEOM::GEOM_Object_var aGEOMObject;
343 //Set a not done flag
344 GetOperations()->SetNotDone();
348 Handle(::GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
349 if (!GetOperations()->IsDone() || anObject.IsNull())
350 return aGEOMObject._retn();
352 return GetObject(anObject);
355 //=============================================================================
359 //=============================================================================
360 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
361 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
363 GEOM::GEOM_Object_var aGEOMObject;
365 //Set a not done flag
366 GetOperations()->SetNotDone();
368 //Get the reference points
369 Handle(::GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
370 Handle(::GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
371 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
374 Handle(::GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
375 if (!GetOperations()->IsDone() || anObject.IsNull())
376 return aGEOMObject._retn();
378 return GetObject(anObject);
382 //=============================================================================
386 //=============================================================================
387 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
388 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
390 GEOM::GEOM_Object_var aGEOMObject;
392 //Set a not done flag
393 GetOperations()->SetNotDone();
395 //Get the reference objects
396 Handle(::GEOM_Object) aRef1 = GetObjectImpl(thePnt);
397 Handle(::GEOM_Object) aRef2 = GetObjectImpl(theDir);
398 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
401 Handle(::GEOM_Object) anObject = GetOperations()->MakeLine(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::MakeLineTwoPnt
414 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
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(thePnt1);
423 Handle(::GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
424 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
427 Handle(::GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
428 if (!GetOperations()->IsDone() || anObject.IsNull())
429 return aGEOMObject._retn();
431 return GetObject(anObject);
434 //=============================================================================
438 //=============================================================================
439 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
440 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
442 GEOM::GEOM_Object_var aGEOMObject;
444 //Set a not done flag
445 GetOperations()->SetNotDone();
447 //Get the reference points
448 Handle(::GEOM_Object) aRef1 = GetObjectImpl(theFace1);
449 Handle(::GEOM_Object) aRef2 = GetObjectImpl(theFace2);
450 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
453 Handle(::GEOM_Object) anObject =
454 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
455 if (!GetOperations()->IsDone() || anObject.IsNull())
456 return aGEOMObject._retn();
458 return GetObject(anObject);
462 //=============================================================================
466 //=============================================================================
467 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
468 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
469 CORBA::Double theTrimSize)
471 GEOM::GEOM_Object_var aGEOMObject;
473 //Set a not done flag
474 GetOperations()->SetNotDone();
477 Handle(::GEOM_Object) aRef1 = GetObjectImpl(thePnt);
478 Handle(::GEOM_Object) aRef2 = GetObjectImpl(theVec);
479 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
482 Handle(::GEOM_Object) anObject =
483 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
484 if (!GetOperations()->IsDone() || anObject.IsNull())
485 return aGEOMObject._retn();
487 return GetObject(anObject);
490 //=============================================================================
494 //=============================================================================
495 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
496 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
497 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
499 GEOM::GEOM_Object_var aGEOMObject;
501 //Set a not done flag
502 GetOperations()->SetNotDone();
504 //Get the reference points
505 Handle(::GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
506 Handle(::GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
507 Handle(::GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
508 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
509 return aGEOMObject._retn();
512 Handle(::GEOM_Object) anObject =
513 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, 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::MakePlaneFace
526 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
528 GEOM::GEOM_Object_var aGEOMObject;
530 //Set a not done flag
531 GetOperations()->SetNotDone();
533 //Get the reference face
534 Handle(::GEOM_Object) aRef = GetObjectImpl(theFace);
535 if (aRef.IsNull()) return aGEOMObject._retn();
538 Handle(::GEOM_Object) anObject =
539 GetOperations()->MakePlaneFace(aRef, theTrimSize);
540 if (!GetOperations()->IsDone() || anObject.IsNull())
541 return aGEOMObject._retn();
543 return GetObject(anObject);
546 //=============================================================================
550 //=============================================================================
551 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec
552 (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
553 CORBA::Double theTrimSize)
555 GEOM::GEOM_Object_var aGEOMObject;
557 //Set a not done flag
558 GetOperations()->SetNotDone();
561 Handle(::GEOM_Object) aRef1 = GetObjectImpl(theVec1);
562 Handle(::GEOM_Object) aRef2 = GetObjectImpl(theVec2);
563 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
566 Handle(::GEOM_Object) anObject =
567 GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
568 if (!GetOperations()->IsDone() || anObject.IsNull())
569 return aGEOMObject._retn();
571 return GetObject(anObject);
574 //=============================================================================
578 //=============================================================================
579 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
580 (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
581 CORBA::Double theOrientation)
583 GEOM::GEOM_Object_var aGEOMObject;
585 //Set a not done flag
586 GetOperations()->SetNotDone();
589 Handle(::GEOM_Object) aRef1 = GetObjectImpl(theLCS);
592 Handle(::GEOM_Object) anObject =
593 GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
594 if (!GetOperations()->IsDone() || anObject.IsNull())
595 return aGEOMObject._retn();
597 return GetObject(anObject);
600 //=============================================================================
604 //=============================================================================
605 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
606 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
607 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
608 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
610 GEOM::GEOM_Object_var aGEOMObject;
612 //Set a not done flag
613 GetOperations()->SetNotDone();
616 Handle(::GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
617 theXDX, theXDY, theXDZ,
618 theYDX, theYDY, theYDZ);
619 if (!GetOperations()->IsDone() || anObject.IsNull())
620 return aGEOMObject._retn();
622 return GetObject(anObject);
625 //=============================================================================
627 * MakeMarkerFromShape
629 //=============================================================================
630 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerFromShape
631 (GEOM::GEOM_Object_ptr theShape)
633 GEOM::GEOM_Object_var aGEOMObject;
635 //Set a not done flag
636 GetOperations()->SetNotDone();
638 //Get the referenced object
639 Handle(::GEOM_Object) aRef = GetObjectImpl(theShape);
640 if (aRef.IsNull()) return aGEOMObject._retn();
643 Handle(::GEOM_Object) anObject = GetOperations()->MakeMarkerFromShape(aRef);
644 if (!GetOperations()->IsDone() || anObject.IsNull())
645 return aGEOMObject._retn();
647 return GetObject(anObject);
650 //=============================================================================
652 * MakeMarkerPntTwoVec
654 //=============================================================================
655 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerPntTwoVec
656 (GEOM::GEOM_Object_ptr theOrigin,
657 GEOM::GEOM_Object_ptr theXVec,
658 GEOM::GEOM_Object_ptr theYVec)
660 GEOM::GEOM_Object_var aGEOMObject;
662 //Set a not done flag
663 GetOperations()->SetNotDone();
665 //Get the referenced objects
666 Handle(::GEOM_Object) aRef1 = GetObjectImpl(theOrigin);
667 Handle(::GEOM_Object) aRef2 = GetObjectImpl(theXVec);
668 Handle(::GEOM_Object) aRef3 = GetObjectImpl(theYVec);
669 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return aGEOMObject._retn();
672 Handle(::GEOM_Object) anObject = GetOperations()->MakeMarkerPntTwoVec(aRef1,
675 if (!GetOperations()->IsDone() || anObject.IsNull())
676 return aGEOMObject._retn();
678 return GetObject(anObject);
681 //=============================================================================
683 * MakeTangentPlaneOnFace
685 //=============================================================================
687 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
688 (GEOM::GEOM_Object_ptr theFace,
689 CORBA::Double theParameterU,
690 CORBA::Double theParameterV,
691 CORBA::Double theTrimSize)
693 GEOM::GEOM_Object_var aGEOMObject;
695 //Set a not done flag
696 GetOperations()->SetNotDone();
698 //Get the reference face
699 Handle(::GEOM_Object) aRef = GetObjectImpl(theFace);
700 if (aRef.IsNull()) return aGEOMObject._retn();
703 Handle(::GEOM_Object) anObject =
704 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
705 if (!GetOperations()->IsDone() || anObject.IsNull())
706 return aGEOMObject._retn();
708 return GetObject(anObject);