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, CORBA::Double theLength)
166 GEOM::GEOM_Object_var aGEOMObject;
168 //Set a not done flag
169 GetOperations()->SetNotDone();
171 //Get the reference curve
172 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
173 if (aReference.IsNull()) return aGEOMObject._retn();
176 Handle(GEOM_Object) anObject =
177 GetOperations()->MakePointOnCurveByLength(aReference, theLength);
178 if (!GetOperations()->IsDone() || anObject.IsNull())
179 return aGEOMObject._retn();
181 return GetObject(anObject);
184 //=============================================================================
186 * MakePointOnCurveByCoord
188 //=============================================================================
189 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByCoord
190 (GEOM::GEOM_Object_ptr theCurve,
191 CORBA::Double theXParameter,
192 CORBA::Double theYParameter,
193 CORBA::Double theZParameter)
195 GEOM::GEOM_Object_var aGEOMObject;
197 //Set a not done flag
198 GetOperations()->SetNotDone();
200 //Get the reference curve
201 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
202 if (aReference.IsNull()) return aGEOMObject._retn();
205 Handle(GEOM_Object) anObject =
206 GetOperations()->MakePointOnCurveByCoord(aReference, theXParameter,
207 theYParameter, theZParameter);
208 if (!GetOperations()->IsDone() || anObject.IsNull())
209 return aGEOMObject._retn();
211 return GetObject(anObject);
214 //=============================================================================
218 //=============================================================================
219 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface
220 (GEOM::GEOM_Object_ptr theSurface,
221 CORBA::Double theUParameter,
222 CORBA::Double theVParameter)
224 GEOM::GEOM_Object_var aGEOMObject;
226 //Set a not done flag
227 GetOperations()->SetNotDone();
229 //Get the reference surface
230 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
231 if (aReference.IsNull()) return aGEOMObject._retn();
234 Handle(GEOM_Object) anObject =
235 GetOperations()->MakePointOnSurface(aReference, theUParameter, theVParameter);
236 if (!GetOperations()->IsDone() || anObject.IsNull())
237 return aGEOMObject._retn();
239 return GetObject(anObject);
242 //=============================================================================
244 * MakePointOnSurfaceByCoord
246 //=============================================================================
247 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord
248 (GEOM::GEOM_Object_ptr theSurface,
249 CORBA::Double theXParameter,
250 CORBA::Double theYParameter,
251 CORBA::Double theZParameter)
253 GEOM::GEOM_Object_var aGEOMObject;
255 //Set a not done flag
256 GetOperations()->SetNotDone();
258 //Get the reference surface
259 Handle(GEOM_Object) aReference = GetObjectImpl(theSurface);
260 if (aReference.IsNull()) return aGEOMObject._retn();
263 Handle(GEOM_Object) anObject =
264 GetOperations()->MakePointOnSurfaceByCoord(aReference, theXParameter,
265 theYParameter, theZParameter);
266 if (!GetOperations()->IsDone() || anObject.IsNull())
267 return aGEOMObject._retn();
269 return GetObject(anObject);
273 //=============================================================================
277 //=============================================================================
278 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentOnCurve
279 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter)
281 GEOM::GEOM_Object_var aGEOMObject;
283 //Set a not done flag
284 GetOperations()->SetNotDone();
286 //Get the reference curve
287 Handle(GEOM_Object) aReference = GetObjectImpl(theCurve);
288 if (aReference.IsNull()) return aGEOMObject._retn();
291 Handle(GEOM_Object) anObject =
292 GetOperations()->MakeTangentOnCurve(aReference, theParameter);
293 if (!GetOperations()->IsDone() || anObject.IsNull())
294 return aGEOMObject._retn();
296 return GetObject(anObject);
299 //=============================================================================
303 //=============================================================================
304 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ
305 (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
307 GEOM::GEOM_Object_var aGEOMObject;
309 //Set a not done flag
310 GetOperations()->SetNotDone();
314 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ);
315 if (!GetOperations()->IsDone() || anObject.IsNull())
316 return aGEOMObject._retn();
318 return GetObject(anObject);
321 //=============================================================================
325 //=============================================================================
326 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt
327 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
329 GEOM::GEOM_Object_var aGEOMObject;
331 //Set a not done flag
332 GetOperations()->SetNotDone();
334 //Get the reference points
335 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
336 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
337 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
340 Handle(GEOM_Object) anObject = GetOperations()->MakeVectorTwoPnt(aRef1, aRef2);
341 if (!GetOperations()->IsDone() || anObject.IsNull())
342 return aGEOMObject._retn();
344 return GetObject(anObject);
348 //=============================================================================
352 //=============================================================================
353 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine
354 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir)
356 GEOM::GEOM_Object_var aGEOMObject;
358 //Set a not done flag
359 GetOperations()->SetNotDone();
361 //Get the reference objects
362 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
363 Handle(GEOM_Object) aRef2 = GetObjectImpl(theDir);
364 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
367 Handle(GEOM_Object) anObject = GetOperations()->MakeLine(aRef1, aRef2);
368 if (!GetOperations()->IsDone() || anObject.IsNull())
369 return aGEOMObject._retn();
371 return GetObject(anObject);
374 //=============================================================================
378 //=============================================================================
379 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt
380 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
382 GEOM::GEOM_Object_var aGEOMObject;
384 //Set a not done flag
385 GetOperations()->SetNotDone();
387 //Get the reference points
388 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
389 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
390 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
393 Handle(GEOM_Object) anObject = GetOperations()->MakeLineTwoPnt(aRef1, aRef2);
394 if (!GetOperations()->IsDone() || anObject.IsNull())
395 return aGEOMObject._retn();
397 return GetObject(anObject);
400 //=============================================================================
404 //=============================================================================
405 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoFaces
406 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
408 GEOM::GEOM_Object_var aGEOMObject;
410 //Set a not done flag
411 GetOperations()->SetNotDone();
413 //Get the reference points
414 Handle(GEOM_Object) aRef1 = GetObjectImpl(theFace1);
415 Handle(GEOM_Object) aRef2 = GetObjectImpl(theFace2);
416 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
419 Handle(GEOM_Object) anObject =
420 GetOperations()->MakeLineTwoFaces(aRef1, aRef2);
421 if (!GetOperations()->IsDone() || anObject.IsNull())
422 return aGEOMObject._retn();
424 return GetObject(anObject);
428 //=============================================================================
432 //=============================================================================
433 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec
434 (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
435 CORBA::Double theTrimSize)
437 GEOM::GEOM_Object_var aGEOMObject;
439 //Set a not done flag
440 GetOperations()->SetNotDone();
443 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt);
444 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec);
445 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
448 Handle(GEOM_Object) anObject =
449 GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize);
450 if (!GetOperations()->IsDone() || anObject.IsNull())
451 return aGEOMObject._retn();
453 return GetObject(anObject);
456 //=============================================================================
460 //=============================================================================
461 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt
462 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
463 GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize)
465 GEOM::GEOM_Object_var aGEOMObject;
467 //Set a not done flag
468 GetOperations()->SetNotDone();
470 //Get the reference points
471 Handle(GEOM_Object) aRef1 = GetObjectImpl(thePnt1);
472 Handle(GEOM_Object) aRef2 = GetObjectImpl(thePnt2);
473 Handle(GEOM_Object) aRef3 = GetObjectImpl(thePnt3);
474 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull())
475 return aGEOMObject._retn();
478 Handle(GEOM_Object) anObject =
479 GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, 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::MakePlaneFace
492 (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize)
494 GEOM::GEOM_Object_var aGEOMObject;
496 //Set a not done flag
497 GetOperations()->SetNotDone();
499 //Get the reference face
500 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
501 if (aRef.IsNull()) return aGEOMObject._retn();
504 Handle(GEOM_Object) anObject =
505 GetOperations()->MakePlaneFace(aRef, theTrimSize);
506 if (!GetOperations()->IsDone() || anObject.IsNull())
507 return aGEOMObject._retn();
509 return GetObject(anObject);
512 //=============================================================================
516 //=============================================================================
517 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlane2Vec
518 (GEOM::GEOM_Object_ptr theVec1, GEOM::GEOM_Object_ptr theVec2,
519 CORBA::Double theTrimSize)
521 GEOM::GEOM_Object_var aGEOMObject;
523 //Set a not done flag
524 GetOperations()->SetNotDone();
527 Handle(GEOM_Object) aRef1 = GetObjectImpl(theVec1);
528 Handle(GEOM_Object) aRef2 = GetObjectImpl(theVec2);
529 if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn();
532 Handle(GEOM_Object) anObject =
533 GetOperations()->MakePlane2Vec(aRef1, aRef2, theTrimSize);
534 if (!GetOperations()->IsDone() || anObject.IsNull())
535 return aGEOMObject._retn();
537 return GetObject(anObject);
540 //=============================================================================
544 //=============================================================================
545 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneLCS
546 (GEOM::GEOM_Object_ptr theLCS, CORBA::Double theTrimSize,
547 CORBA::Double theOrientation)
549 GEOM::GEOM_Object_var aGEOMObject;
551 //Set a not done flag
552 GetOperations()->SetNotDone();
555 Handle(GEOM_Object) aRef1 = GetObjectImpl(theLCS);
558 Handle(GEOM_Object) anObject =
559 GetOperations()->MakePlaneLCS(aRef1, theTrimSize, theOrientation);
560 if (!GetOperations()->IsDone() || anObject.IsNull())
561 return aGEOMObject._retn();
563 return GetObject(anObject);
566 //=============================================================================
570 //=============================================================================
571 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
572 (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ,
573 CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
574 CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ)
576 GEOM::GEOM_Object_var aGEOMObject;
578 //Set a not done flag
579 GetOperations()->SetNotDone();
582 Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ,
583 theXDX, theXDY, theXDZ,
584 theYDX, theYDY, theYDZ);
585 if (!GetOperations()->IsDone() || anObject.IsNull())
586 return aGEOMObject._retn();
588 return GetObject(anObject);
591 //=============================================================================
593 * MakeMarkerFromShape
595 //=============================================================================
596 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerFromShape
597 (GEOM::GEOM_Object_ptr theShape)
599 GEOM::GEOM_Object_var aGEOMObject;
601 //Set a not done flag
602 GetOperations()->SetNotDone();
604 //Get the referenced object
605 Handle(GEOM_Object) aRef = GetObjectImpl(theShape);
606 if (aRef.IsNull()) return aGEOMObject._retn();
609 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerFromShape(aRef);
610 if (!GetOperations()->IsDone() || anObject.IsNull())
611 return aGEOMObject._retn();
613 return GetObject(anObject);
616 //=============================================================================
618 * MakeMarkerPntTwoVec
620 //=============================================================================
621 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerPntTwoVec
622 (GEOM::GEOM_Object_ptr theOrigin,
623 GEOM::GEOM_Object_ptr theXVec,
624 GEOM::GEOM_Object_ptr theYVec)
626 GEOM::GEOM_Object_var aGEOMObject;
628 //Set a not done flag
629 GetOperations()->SetNotDone();
631 //Get the referenced objects
632 Handle(GEOM_Object) aRef1 = GetObjectImpl(theOrigin);
633 Handle(GEOM_Object) aRef2 = GetObjectImpl(theXVec);
634 Handle(GEOM_Object) aRef3 = GetObjectImpl(theYVec);
635 if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return aGEOMObject._retn();
638 Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerPntTwoVec(aRef1,
641 if (!GetOperations()->IsDone() || anObject.IsNull())
642 return aGEOMObject._retn();
644 return GetObject(anObject);
647 //=============================================================================
649 * MakeTangentPlaneOnFace
651 //=============================================================================
653 GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace
654 (GEOM::GEOM_Object_ptr theFace,
655 CORBA::Double theParameterU,
656 CORBA::Double theParameterV,
657 CORBA::Double theTrimSize)
659 GEOM::GEOM_Object_var aGEOMObject;
661 //Set a not done flag
662 GetOperations()->SetNotDone();
664 //Get the reference face
665 Handle(GEOM_Object) aRef = GetObjectImpl(theFace);
666 if (aRef.IsNull()) return aGEOMObject._retn();
669 Handle(GEOM_Object) anObject =
670 GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize);
671 if (!GetOperations()->IsDone() || anObject.IsNull())
672 return aGEOMObject._retn();
674 return GetObject(anObject);