1 // Copyright (C) 2007-2012 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();
71 Handle(GEOM_Object) anObject = GetOperations()->MakePointXYZ(theX, theY, theZ);
72 if (!GetOperations()->IsDone() || anObject.IsNull())
73 return aGEOMObject._retn();
75 return GetObject(anObject);
78 //=============================================================================
80 * MakePointWithReference
82 //=============================================================================
83 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointWithReference
84 (GEOM::GEOM_Object_ptr theReference, CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ)
86 GEOM::GEOM_Object_var aGEOMObject;
89 GetOperations()->SetNotDone();
91 //Get the reference point
92 Handle(GEOM_Object) aReference = GetObjectImpl(theReference);
93 if (aReference.IsNull()) return aGEOMObject._retn();
96 Handle(GEOM_Object) anObject =
97 GetOperations()->MakePointWithReference(aReference, theX, theY, theZ);
98 if (!GetOperations()->IsDone() || anObject.IsNull())
99 return aGEOMObject._retn();
101 return GetObject(anObject);
104 //=============================================================================
106 * MakePointOnLinesIntersection
108 //=============================================================================
109 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnLinesIntersection
110 (GEOM::GEOM_Object_ptr theLine1, GEOM::GEOM_Object_ptr theLine2)
112 GEOM::GEOM_Object_var aGEOMObject;
114 //Set a not done flag
115 GetOperations()->SetNotDone();
117 //Get the reference Lines
118 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLine1);
119 Handle(GEOM_Object) aRef2 = GetObjectImpl(theLine2);
120 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
123 Handle(GEOM_Object) anObject =
124 GetOperations()->MakePointOnLinesIntersection(aRef1, aRef2);
125 if (!GetOperations()->IsDone() || anObject.IsNull())
126 return aGEOMObject._retn();
128 return GetObject(anObject);
131 //=============================================================================
135 //=============================================================================
136 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve
137 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
139 GEOM::GEOM_Object_var aGEOMObject;
141 //Set a not done flag
142 GetOperations()->SetNotDone();
144 //Get the reference curve
145 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
146 if (aReference.IsNull()) return aGEOMObject._retn();
149 Handle(GEOM_Object) anObject =
150 GetOperations()->MakePointOnCurve(aReference, theParameter);
151 if (!GetOperations()->IsDone() || anObject.IsNull())
152 return aGEOMObject._retn();
154 return GetObject(anObject);
157 //=============================================================================
159 * MakePointOnCurveByLength
161 //=============================================================================
162 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByLength
163 (GEOM::GEOM_Object_ptr theCurve,
164 CORBA::Double theLength,
165 GEOM::GEOM_Object_ptr theStartPoint)
167 GEOM::GEOM_Object_var aGEOMObject;
169 //Set a not done flag
170 GetOperations()->SetNotDone();
172 //Get the reference curve
173 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
174 if (aReference.IsNull()) return aGEOMObject._retn();
176 //Get the reference point (can be NULL)
177 Handle(GEOM_Object) aRefPoint;
178 if (!CORBA::is_nil(theStartPoint)) {
179 aRefPoint = GetObjectImpl(theStartPoint);
183 Handle(GEOM_Object) anObject =
184 GetOperations()->MakePointOnCurveByLength(aReference, theLength, aRefPoint);
185 if (!GetOperations()->IsDone() || anObject.IsNull())
186 return aGEOMObject._retn();
188 return GetObject(anObject);
191 //=============================================================================
193 * MakePointOnCurveByCoord
195 //=============================================================================
196 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByCoord
197 (GEOM::GEOM_Object_ptr theCurve,
198 CORBA::Double theXParameter,
199 CORBA::Double theYParameter,
200 CORBA::Double theZParameter)
202 GEOM::GEOM_Object_var aGEOMObject;
204 //Set a not done flag
205 GetOperations()->SetNotDone();
207 //Get the reference curve
208 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
209 if (aReference.IsNull()) return aGEOMObject._retn();
212 Handle(GEOM_Object) anObject =
213 GetOperations()->MakePointOnCurveByCoord(aReference, theXParameter,
214 theYParameter, theZParameter);
215 if (!GetOperations()->IsDone() || anObject.IsNull())
216 return aGEOMObject._retn();
218 return GetObject(anObject);
221 //=============================================================================
225 //=============================================================================
226 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
227 (GEOM::GEOM_Object_ptr theSurface,
228 CORBA::Double theUParameter,
229 CORBA::Double theVParameter)
231 GEOM::GEOM_Object_var aGEOMObject;
233 //Set a not done flag
234 GetOperations()->SetNotDone();
236 //Get the reference surface
237 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
238 if (aReference.IsNull()) return aGEOMObject._retn();
241 Handle(GEOM_Object) anObject =
242 GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
243 if (!GetOperations()->IsDone() || anObject.IsNull())
244 return aGEOMObject._retn();
246 return GetObject(anObject);
249 //=============================================================================
251 * MakePointOnSurfaceByCoord
253 //=============================================================================
254 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord
255 (GEOM::GEOM_Object_ptr theSurface,
256 CORBA::Double theXParameter,
257 CORBA::Double theYParameter,
258 CORBA::Double theZParameter)
260 GEOM::GEOM_Object_var aGEOMObject;
262 //Set a not done flag
263 GetOperations()->SetNotDone();
265 //Get the reference surface
266 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
267 if (aReference.IsNull()) return aGEOMObject._retn();
270 Handle(GEOM_Object) anObject =
271 GetOperations()->MakePointOnSurfaceByCoord(aReference, theXParameter,
272 theYParameter, theZParameter);
273 if (!GetOperations()->IsDone() || anObject.IsNull())
274 return aGEOMObject._retn();
276 return GetObject(anObject);
279 //=============================================================================
283 //=============================================================================
284 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnFace (GEOM::GEOM_Object_ptr theFace)
286 GEOM::GEOM_Object_var aGEOMObject;
288 //Set a not done flag
289 GetOperations()->SetNotDone();
291 //Get the reference face
292 Handle(GEOM_Object) aReference = GetObjectImpl(theFace);
293 if (aReference.IsNull()) return aGEOMObject._retn();
296 Handle(GEOM_Object) anObject = GetOperations()->MakePointOnFace(aReference);
297 if (!GetOperations()->IsDone() || anObject.IsNull())
298 return aGEOMObject._retn();
300 return GetObject(anObject);
303 //=============================================================================
307 //=============================================================================
308 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
309 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
311 GEOM::GEOM_Object_var aGEOMObject;
313 //Set a not done flag
314 GetOperations()->SetNotDone();
316 //Get the reference curve
317 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
318 if (aReference.IsNull()) return aGEOMObject._retn();
321 Handle(GEOM_Object) anObject =
322 GetOperations()->MakeTangentOnCurve(aReference, theParameter);
323 if (!GetOperations()->IsDone() || anObject.IsNull())
324 return aGEOMObject._retn();
326 return GetObject(anObject);
329 //=============================================================================
333 //=============================================================================
334 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
335 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
337 GEOM::GEOM_Object_var aGEOMObject;
339 //Set a not done flag
340 GetOperations()->SetNotDone();
344 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
345 if (!GetOperations()->IsDone() || anObject.IsNull())
346 return aGEOMObject._retn();
348 return GetObject(anObject);
351 //=============================================================================
355 //=============================================================================
356 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
357 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
359 GEOM::GEOM_Object_var aGEOMObject;
361 //Set a not done flag
362 GetOperations()->SetNotDone();
364 //Get the reference points
365 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
366 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
367 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
370 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
371 if (!GetOperations()->IsDone() || anObject.IsNull())
372 return aGEOMObject._retn();
374 return GetObject(anObject);
378 //=============================================================================
382 //=============================================================================
383 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
384 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
386 GEOM::GEOM_Object_var aGEOMObject;
388 //Set a not done flag
389 GetOperations()->SetNotDone();
391 //Get the reference objects
392 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
393 Handle(GEOM_Object) aRef2 = GetObjectImpl(theDir);
394 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
397 Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
398 if (!GetOperations()->IsDone() || anObject.IsNull())
399 return aGEOMObject._retn();
401 return GetObject(anObject);
404 //=============================================================================
408 //=============================================================================
409 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
410 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
412 GEOM::GEOM_Object_var aGEOMObject;
414 //Set a not done flag
415 GetOperations()->SetNotDone();
417 //Get the reference points
418 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
419 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
420 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
423 Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
424 if (!GetOperations()->IsDone() || anObject.IsNull())
425 return aGEOMObject._retn();
427 return GetObject(anObject);
430 //=============================================================================
434 //=============================================================================
435 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
436 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
438 GEOM::GEOM_Object_var aGEOMObject;
440 //Set a not done flag
441 GetOperations()->SetNotDone();
443 //Get the reference points
444 Handle(GEOM_Object) aRef1 = GetObjectImpl(theFace1);
445 Handle(GEOM_Object) aRef2 = GetObjectImpl(theFace2);
446 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
449 Handle(GEOM_Object) anObject =
450 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
451 if (!GetOperations()->IsDone() || anObject.IsNull())
452 return aGEOMObject._retn();
454 return GetObject(anObject);
458 //=============================================================================
462 //=============================================================================
463 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
464 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
465 CORBA::Double theTrimSize)
467 GEOM::GEOM_Object_var aGEOMObject;
469 //Set a not done flag
470 GetOperations()->SetNotDone();
473 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
474 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
475 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
478 Handle(GEOM_Object) anObject =
479 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
480 if (!GetOperations()->IsDone() || anObject.IsNull())
481 return aGEOMObject._retn();
483 return GetObject(anObject);
486 //=============================================================================
490 //=============================================================================
491 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
492 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
493 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
495 GEOM::GEOM_Object_var aGEOMObject;
497 //Set a not done flag
498 GetOperations()->SetNotDone();
500 //Get the reference points
501 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
502 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
503 Handle(GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
504 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
505 return aGEOMObject._retn();
508 Handle(GEOM_Object) anObject =
509 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize);
510 if (!GetOperations()->IsDone() || anObject.IsNull())
511 return aGEOMObject._retn();
513 return GetObject(anObject);
516 //=============================================================================
520 //=============================================================================
521 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace
522 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
524 GEOM::GEOM_Object_var aGEOMObject;
526 //Set a not done flag
527 GetOperations()->SetNotDone();
529 //Get the reference face
530 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
531 if (aRef.IsNull()) return aGEOMObject._retn();
534 Handle(GEOM_Object) anObject =
535 GetOperations()->MakePlaneFace(aRef, theTrimSize);
536 if (!GetOperations()->IsDone() || anObject.IsNull())
537 return aGEOMObject._retn();
539 return GetObject(anObject);
542 //=============================================================================
546 //=============================================================================
547 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec
548 (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
549 CORBA::Double theTrimSize)
551 GEOM::GEOM_Object_var aGEOMObject;
553 //Set a not done flag
554 GetOperations()->SetNotDone();
557 Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
558 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
559 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
562 Handle(GEOM_Object) anObject =
563 GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
564 if (!GetOperations()->IsDone() || anObject.IsNull())
565 return aGEOMObject._retn();
567 return GetObject(anObject);
570 //=============================================================================
574 //=============================================================================
575 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
576 (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
577 CORBA::Double theOrientation)
579 GEOM::GEOM_Object_var aGEOMObject;
581 //Set a not done flag
582 GetOperations()->SetNotDone();
585 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
588 Handle(GEOM_Object) anObject =
589 GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
590 if (!GetOperations()->IsDone() || anObject.IsNull())
591 return aGEOMObject._retn();
593 return GetObject(anObject);
596 //=============================================================================
600 //=============================================================================
601 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
602 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
603 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
604 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
606 GEOM::GEOM_Object_var aGEOMObject;
608 //Set a not done flag
609 GetOperations()->SetNotDone();
612 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
613 theXDX, theXDY, theXDZ,
614 theYDX, theYDY, theYDZ);
615 if (!GetOperations()->IsDone() || anObject.IsNull())
616 return aGEOMObject._retn();
618 return GetObject(anObject);
621 //=============================================================================
623 * MakeMarkerFromShape
625 //=============================================================================
626 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerFromShape
627 (GEOM::GEOM_Object_ptr theShape)
629 GEOM::GEOM_Object_var aGEOMObject;
631 //Set a not done flag
632 GetOperations()->SetNotDone();
634 //Get the referenced object
635 Handle(GEOM_Object) aRef = GetObjectImpl(theShape);
636 if (aRef.IsNull()) return aGEOMObject._retn();
639 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerFromShape(aRef);
640 if (!GetOperations()->IsDone() || anObject.IsNull())
641 return aGEOMObject._retn();
643 return GetObject(anObject);
646 //=============================================================================
648 * MakeMarkerPntTwoVec
650 //=============================================================================
651 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerPntTwoVec
652 (GEOM::GEOM_Object_ptr theOrigin,
653 GEOM::GEOM_Object_ptr theXVec,
654 GEOM::GEOM_Object_ptr theYVec)
656 GEOM::GEOM_Object_var aGEOMObject;
658 //Set a not done flag
659 GetOperations()->SetNotDone();
661 //Get the referenced objects
662 Handle(GEOM_Object) aRef1 = GetObjectImpl(theOrigin);
663 Handle(GEOM_Object) aRef2 = GetObjectImpl(theXVec);
664 Handle(GEOM_Object) aRef3 = GetObjectImpl(theYVec);
665 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return aGEOMObject._retn();
668 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerPntTwoVec(aRef1,
671 if (!GetOperations()->IsDone() || anObject.IsNull())
672 return aGEOMObject._retn();
674 return GetObject(anObject);
677 //=============================================================================
679 * MakeTangentPlaneOnFace
681 //=============================================================================
683 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
684 (GEOM::GEOM_Object_ptr theFace,
685 CORBA::Double theParameterU,
686 CORBA::Double theParameterV,
687 CORBA::Double theTrimSize)
689 GEOM::GEOM_Object_var aGEOMObject;
691 //Set a not done flag
692 GetOperations()->SetNotDone();
694 //Get the reference face
695 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
696 if (aRef.IsNull()) return aGEOMObject._retn();
699 Handle(GEOM_Object) anObject =
700 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
701 if (!GetOperations()->IsDone() || anObject.IsNull())
702 return aGEOMObject._retn();
704 return GetObject(anObject);