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_ITransformOperations_i.hh"
26 #include "utilities.h"
28 #include "Utils_ExceptHandlers.hxx"
30 #include <TDF_Label.hxx>
31 #include <TDF_Tool.hxx>
32 #include <TCollection_AsciiString.hxx>
33 #include "GEOM_Engine.hxx"
34 #include "GEOM_Object.hxx"
36 #define SUBSHAPE_ERROR "Sub shape cannot be transformed"
38 //=============================================================================
42 //=============================================================================
44 GEOM_ITransformOperations_i::GEOM_ITransformOperations_i (PortableServer::POA_ptr thePOA,
45 GEOM::GEOM_Gen_ptr theEngine,
46 ::GEOMImpl_ITransformOperations* theImpl)
47 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
49 MESSAGE("GEOM_ITransformOperations_i::GEOM_ITransformOperations_i");
52 //=============================================================================
56 //=============================================================================
58 GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i()
60 MESSAGE("GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i");
64 //=============================================================================
68 //=============================================================================
69 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPoints
70 (GEOM::GEOM_Object_ptr theObject,
71 GEOM::GEOM_Object_ptr thePoint1,
72 GEOM::GEOM_Object_ptr thePoint2)
75 GetOperations()->SetNotDone();
76 GEOM::GEOM_Object_var aGEOMObject;
78 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
80 //check if the object is a sub-shape
81 if (!theObject->IsMainShape()) {
82 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
83 return aGEOMObject._retn();
86 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
88 //Get the object itself
89 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
90 if (anObject.IsNull()) return aGEOMObject._retn();
92 //Get the first point of translation
93 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
94 if (aPoint1.IsNull()) return aGEOMObject._retn();
96 //Get the second point of translation
97 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
98 if (aPoint2.IsNull()) return aGEOMObject._retn();
100 //Perform the translation
101 GetOperations()->TranslateTwoPoints(anObject, aPoint1, aPoint2);
103 return aGEOMObject._retn();
106 //=============================================================================
108 * TranslateTwoPointsCopy
110 //=============================================================================
111 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy
112 (GEOM::GEOM_Object_ptr theObject,
113 GEOM::GEOM_Object_ptr thePoint1,
114 GEOM::GEOM_Object_ptr thePoint2)
116 GEOM::GEOM_Object_var aGEOMObject;
118 //Set a not done flag
119 GetOperations()->SetNotDone();
121 //Get the object itself
122 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
123 if (aBasicObject.IsNull()) return aGEOMObject._retn();
125 //Get the first point of translation
126 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
127 if (aPoint1.IsNull()) return aGEOMObject._retn();
129 //Get the second point of translation
130 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
131 if (aPoint2.IsNull()) return aGEOMObject._retn();
133 //Create the translated shape
134 Handle(GEOM_Object) anObject =
135 GetOperations()->TranslateTwoPointsCopy(aBasicObject, aPoint1, aPoint2);
136 if (!GetOperations()->IsDone() || anObject.IsNull())
137 return aGEOMObject._retn();
139 return GetObject(anObject);
142 //=============================================================================
146 //=============================================================================
147 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ
148 (GEOM::GEOM_Object_ptr theObject,
149 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
151 //Set a not done flag
152 GetOperations()->SetNotDone();
153 GEOM::GEOM_Object_var aGEOMObject;
155 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
157 //check if the object is a sub-shape
158 if (!theObject->IsMainShape()) {
159 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
160 return aGEOMObject._retn();
163 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
165 //Get the object itself
166 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
167 if (anObject.IsNull()) return aGEOMObject._retn();
169 //Perform the translation
170 GetOperations()->TranslateDXDYDZ(anObject, theDX, theDY, theDZ);
172 return aGEOMObject._retn();
175 //=============================================================================
177 * TranslateDXDYDZCopy
179 //=============================================================================
180 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy
181 (GEOM::GEOM_Object_ptr theObject,
182 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
184 GEOM::GEOM_Object_var aGEOMObject;
186 //Set a not done flag
187 GetOperations()->SetNotDone();
189 //Get the object itself
190 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
191 if (aBasicObject.IsNull()) return aGEOMObject._retn();
193 //Create the translated shape
194 Handle(GEOM_Object) anObject =
195 GetOperations()->TranslateDXDYDZCopy(aBasicObject, theDX, theDY, theDZ);
196 if (!GetOperations()->IsDone() || anObject.IsNull())
197 return aGEOMObject._retn();
199 return GetObject(anObject);
202 //=============================================================================
206 //=============================================================================
207 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector
208 (GEOM::GEOM_Object_ptr theObject,
209 GEOM::GEOM_Object_ptr theVector)
211 //Set a not done flag
212 GetOperations()->SetNotDone();
213 GEOM::GEOM_Object_var aGEOMObject;
215 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
217 //check if the object is a sub-shape
218 if (!theObject->IsMainShape()) {
219 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
220 return aGEOMObject._retn();
223 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
225 //Get the object itself
226 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
227 if (anObject.IsNull()) return aGEOMObject._retn();
229 //Get the vector of translation
230 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
231 if (aVector.IsNull()) return aGEOMObject._retn();
233 //Perform the translation
234 GetOperations()->TranslateVector(anObject, aVector);
236 return aGEOMObject._retn();
239 //=============================================================================
241 * TranslateVectorCopy
243 //=============================================================================
244 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy
245 (GEOM::GEOM_Object_ptr theObject,
246 GEOM::GEOM_Object_ptr theVector)
248 GEOM::GEOM_Object_var aGEOMObject;
250 //Set a not done flag
251 GetOperations()->SetNotDone();
253 //Get the object itself
254 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
255 if (aBasicObject.IsNull()) return aGEOMObject._retn();
257 //Get the vector of translation
258 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
259 if (aVector.IsNull()) return aGEOMObject._retn();
261 //Perform the translation
262 Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector);
263 if (!GetOperations()->IsDone() || anObject.IsNull())
264 return aGEOMObject._retn();
266 return GetObject(anObject);
269 //=============================================================================
271 * TranslateVectorDistance
273 //=============================================================================
274 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorDistance
275 (GEOM::GEOM_Object_ptr theObject,
276 GEOM::GEOM_Object_ptr theVector,
277 CORBA::Double theDistance,
278 CORBA::Boolean theCopy)
280 GEOM::GEOM_Object_var aGEOMObject;
281 GetOperations()->SetNotDone(); //Set a not done flag
283 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
285 //check if the object is a sub-shape
286 if (!theCopy && !theObject->IsMainShape()) {
287 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
288 return aGEOMObject._retn();
292 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
294 //Get the object itself
295 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
296 if (aBasicObject.IsNull()) return aGEOMObject._retn();
298 //Get the vector of translation
299 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
300 if (aVector.IsNull()) return aGEOMObject._retn();
302 //Perform the translation
304 Handle(GEOM_Object) anObject = GetOperations()->
305 TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
306 if (!GetOperations()->IsDone() || anObject.IsNull())
307 return aGEOMObject._retn();
309 return GetObject(anObject);
312 GetOperations()->TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
313 return aGEOMObject._retn();
316 //=============================================================================
320 //=============================================================================
321 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject,
322 GEOM::GEOM_Object_ptr theAxis,
323 CORBA::Double theAngle)
325 //Set a not done flag
326 GetOperations()->SetNotDone();
327 GEOM::GEOM_Object_var aGEOMObject;
329 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
331 //check if the object is a sub-shape
332 if (!theObject->IsMainShape()) {
333 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
334 return aGEOMObject._retn();
337 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
339 //Get the object itself
340 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
341 if (anObject.IsNull()) return aGEOMObject._retn();
343 //Get the axis of revolution
344 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
345 if (anAxis.IsNull()) return aGEOMObject._retn();
347 //Perform the rotation
348 GetOperations()->Rotate(anObject, anAxis, theAngle);
350 return aGEOMObject._retn();
353 //=============================================================================
357 //=============================================================================
358 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject,
359 GEOM::GEOM_Object_ptr theAxis,
360 CORBA::Double theAngle)
362 GEOM::GEOM_Object_var aGEOMObject;
364 //Set a not done flag
365 GetOperations()->SetNotDone();
367 //Get the object itself
368 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
369 if (aBasicObject.IsNull()) return aGEOMObject._retn();
371 //Get the axis of rotation
372 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
373 if (anAxis.IsNull()) return aGEOMObject._retn();
375 //Perform the rotation
376 Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle);
377 if (!GetOperations()->IsDone() || anObject.IsNull())
378 return aGEOMObject._retn();
380 return GetObject(anObject);
383 //=============================================================================
387 //=============================================================================
388 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
389 (GEOM::GEOM_Object_ptr theObject,
390 GEOM::GEOM_Object_ptr thePlane)
392 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
394 //Set a not done flag
395 GetOperations()->SetNotDone();
397 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
399 //check if the object is a sub-shape
400 if (!theObject->IsMainShape()) {
401 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
402 return aGEOMObject._retn();
405 //Get the object itself
406 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
407 if (anObject.IsNull()) return aGEOMObject._retn();
410 Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
411 if (aPlane.IsNull()) return aGEOMObject._retn();
414 GetOperations()->MirrorPlane(anObject, aPlane);
416 return aGEOMObject._retn();
419 //=============================================================================
423 //=============================================================================
424 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy
425 (GEOM::GEOM_Object_ptr theObject,
426 GEOM::GEOM_Object_ptr thePlane)
428 GEOM::GEOM_Object_var aGEOMObject;
430 //Set a not done flag
431 GetOperations()->SetNotDone();
433 //Get the object itself
434 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
435 if (aBasicObject.IsNull()) return aGEOMObject._retn();
437 //Get the vector of translation
438 Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
439 if (aPlane.IsNull()) return aGEOMObject._retn();
442 Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane);
443 if (!GetOperations()->IsDone() || anObject.IsNull())
444 return aGEOMObject._retn();
446 return GetObject(anObject);
449 //=============================================================================
453 //=============================================================================
454 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis
455 (GEOM::GEOM_Object_ptr theObject,
456 GEOM::GEOM_Object_ptr theAxis)
458 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
460 //Set a not done flag
461 GetOperations()->SetNotDone();
463 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
465 //check if the object is a sub-shape
466 if (!theObject->IsMainShape()) {
467 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
468 return aGEOMObject._retn();
471 //Get the object itself
472 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
473 if (anObject.IsNull()) return aGEOMObject._retn();
476 Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
477 if (aAxis.IsNull()) return aGEOMObject._retn();
480 GetOperations()->MirrorAxis(anObject, aAxis);
482 return aGEOMObject._retn();
485 //=============================================================================
489 //=============================================================================
490 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy
491 (GEOM::GEOM_Object_ptr theObject,
492 GEOM::GEOM_Object_ptr theAxis)
494 GEOM::GEOM_Object_var aGEOMObject;
496 //Set a not done flag
497 GetOperations()->SetNotDone();
499 //Get the object itself
500 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
501 if (aBasicObject.IsNull()) return aGEOMObject._retn();
503 //Get the vector of translation
504 Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
505 if (aAxis.IsNull()) return aGEOMObject._retn();
508 Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis);
509 if (!GetOperations()->IsDone() || anObject.IsNull())
510 return aGEOMObject._retn();
512 return GetObject(anObject);
515 //=============================================================================
519 //=============================================================================
520 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint
521 (GEOM::GEOM_Object_ptr theObject,
522 GEOM::GEOM_Object_ptr thePoint)
524 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
526 //Set a not done flag
527 GetOperations()->SetNotDone();
529 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
531 //check if the object is a sub-shape
532 if (!theObject->IsMainShape()) {
533 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
534 return aGEOMObject._retn();
537 //Get the object itself
538 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
539 if (anObject.IsNull()) return aGEOMObject._retn();
542 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
543 if (aPoint.IsNull()) return aGEOMObject._retn();
546 GetOperations()->MirrorPoint(anObject, aPoint);
548 return aGEOMObject._retn();
551 //=============================================================================
555 //=============================================================================
556 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy
557 (GEOM::GEOM_Object_ptr theObject,
558 GEOM::GEOM_Object_ptr thePoint)
560 GEOM::GEOM_Object_var aGEOMObject;
562 //Set a not done flag
563 GetOperations()->SetNotDone();
565 //Get the object itself
566 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
567 if (aBasicObject.IsNull()) return aGEOMObject._retn();
569 //Get the vector of translation
570 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
571 if (aPoint.IsNull()) return aGEOMObject._retn();
574 Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint);
575 if (!GetOperations()->IsDone() || anObject.IsNull())
576 return aGEOMObject._retn();
578 return GetObject(anObject);
581 //=============================================================================
585 //=============================================================================
586 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
587 (GEOM::GEOM_Object_ptr theObject,
588 CORBA::Double theOffset)
590 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
592 //Set a not done flag
593 GetOperations()->SetNotDone();
595 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
597 //check if the object is a sub-shape
598 if (!theObject->IsMainShape()) {
599 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
600 return aGEOMObject._retn();
603 //Get the basic object
604 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
605 if (aBasicObject.IsNull()) return aGEOMObject._retn();
607 //Create the offset shape
608 GetOperations()->OffsetShape(aBasicObject, theOffset);
610 return aGEOMObject._retn();
613 //=============================================================================
617 //=============================================================================
618 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
619 (GEOM::GEOM_Object_ptr theObject,
620 CORBA::Double theOffset)
622 GEOM::GEOM_Object_var aGEOMObject;
624 //Set a not done flag
625 GetOperations()->SetNotDone();
627 //Get the basic object
628 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
629 if (aBasicObject.IsNull()) return aGEOMObject._retn();
631 //Create the offset shape
632 Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset);
633 if (!GetOperations()->IsDone() || anObject.IsNull())
634 return aGEOMObject._retn();
636 return GetObject(anObject);
639 //=============================================================================
643 //=============================================================================
644 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ProjectShapeCopy
645 (GEOM::GEOM_Object_ptr theSource,
646 GEOM::GEOM_Object_ptr theTarget)
648 GEOM::GEOM_Object_var aGEOMObject;
650 //Set a not done flag
651 GetOperations()->SetNotDone();
653 //Get the input objects
654 Handle(GEOM_Object) aSource = GetObjectImpl(theSource);
655 Handle(GEOM_Object) aTarget = GetObjectImpl(theTarget);
656 if (aSource.IsNull() || aTarget.IsNull()) return aGEOMObject._retn();
658 //Create the projection
659 Handle(GEOM_Object) anObject = GetOperations()->ProjectShapeCopy(aSource, aTarget);
660 if (!GetOperations()->IsDone() || anObject.IsNull())
661 return aGEOMObject._retn();
663 return GetObject(anObject);
666 //=============================================================================
670 //=============================================================================
671 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
672 (GEOM::GEOM_Object_ptr theObject,
673 GEOM::GEOM_Object_ptr thePoint,
674 CORBA::Double theFactor)
676 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
678 //Set a not done flag
679 GetOperations()->SetNotDone();
681 if (theObject->_is_nil()) return aGEOMObject._retn();
683 //check if the object is a sub-shape
684 if (!theObject->IsMainShape()) {
685 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
686 return aGEOMObject._retn();
689 //Get the object itself
690 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
691 if (anObject.IsNull()) return aGEOMObject._retn();
694 Handle(GEOM_Object) aPoint;
695 if (!thePoint->_is_nil()) {
696 aPoint = GetObjectImpl(thePoint);
697 if (aPoint.IsNull()) return aGEOMObject._retn();
701 GetOperations()->ScaleShape(anObject, aPoint, theFactor);
703 return aGEOMObject._retn();
706 //=============================================================================
710 //=============================================================================
711 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
712 (GEOM::GEOM_Object_ptr theObject,
713 GEOM::GEOM_Object_ptr thePoint,
714 CORBA::Double theFactor)
716 GEOM::GEOM_Object_var aGEOMObject;
718 //Set a not done flag
719 GetOperations()->SetNotDone();
721 //Get the basic object
722 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
723 if (aBasicObject.IsNull()) return aGEOMObject._retn();
726 Handle(GEOM_Object) aPoint;
727 if (!thePoint->_is_nil()) {
728 aPoint = GetObjectImpl(thePoint);
729 if (aPoint.IsNull()) return aGEOMObject._retn();
733 Handle(GEOM_Object) anObject =
734 GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
735 if (!GetOperations()->IsDone() || anObject.IsNull())
736 return aGEOMObject._retn();
738 return GetObject(anObject);
741 //=============================================================================
743 * ScaleShapeAlongAxes
745 //=============================================================================
746 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxes
747 (GEOM::GEOM_Object_ptr theObject,
748 GEOM::GEOM_Object_ptr thePoint,
749 CORBA::Double theFactorX,
750 CORBA::Double theFactorY,
751 CORBA::Double theFactorZ)
753 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
755 //Set a not done flag
756 GetOperations()->SetNotDone();
758 if (theObject->_is_nil()) return aGEOMObject._retn();
760 //check if the object is a sub-shape
761 if (!theObject->IsMainShape()) {
762 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
763 return aGEOMObject._retn();
766 //Get the object itself
767 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
768 if (anObject.IsNull()) return aGEOMObject._retn();
771 Handle(GEOM_Object) aPoint;
772 if (!thePoint->_is_nil()) {
773 aPoint = GetObjectImpl(thePoint);
774 if (aPoint.IsNull()) return aGEOMObject._retn();
778 GetOperations()->ScaleShapeAlongAxes
779 (anObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/false);
781 return aGEOMObject._retn();
784 //=============================================================================
786 * ScaleShapeAlongAxesCopy
788 //=============================================================================
789 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxesCopy
790 (GEOM::GEOM_Object_ptr theObject,
791 GEOM::GEOM_Object_ptr thePoint,
792 CORBA::Double theFactorX,
793 CORBA::Double theFactorY,
794 CORBA::Double theFactorZ)
796 GEOM::GEOM_Object_var aGEOMObject;
798 //Set a not done flag
799 GetOperations()->SetNotDone();
801 //Get the basic object
802 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
803 if (aBasicObject.IsNull()) return aGEOMObject._retn();
806 Handle(GEOM_Object) aPoint;
807 if (!thePoint->_is_nil()) {
808 aPoint = GetObjectImpl(thePoint);
809 if (aPoint.IsNull()) return aGEOMObject._retn();
813 Handle(GEOM_Object) anObject = GetOperations()->ScaleShapeAlongAxes
814 (aBasicObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/true);
815 if (!GetOperations()->IsDone() || anObject.IsNull())
816 return aGEOMObject._retn();
818 return GetObject(anObject);
821 //=============================================================================
825 //=============================================================================
826 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
827 (GEOM::GEOM_Object_ptr theObject,
828 GEOM::GEOM_Object_ptr theStartLCS,
829 GEOM::GEOM_Object_ptr theEndLCS)
831 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
833 //Set a not done flag
834 GetOperations()->SetNotDone();
836 if (CORBA::is_nil(theObject) || CORBA::is_nil(theEndLCS))
837 return aGEOMObject._retn();
839 //check if the object is a sub-shape
840 if (!theObject->IsMainShape()) {
841 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
842 return aGEOMObject._retn();
845 //Get the basic object
846 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
847 if (anObject.IsNull()) return aGEOMObject._retn();
849 //Get the Start LCS (may be NULL for positioning from global LCS)
850 Handle(GEOM_Object) aStartLCS;
851 if (!CORBA::is_nil(theStartLCS)) {
852 aStartLCS = GetObjectImpl(theStartLCS);
853 if (aStartLCS.IsNull()) return aGEOMObject._retn();
857 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
858 if (aEndLCS.IsNull()) return aGEOMObject._retn();
860 //Perform the Position
861 GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
863 return aGEOMObject._retn();
866 //=============================================================================
870 //=============================================================================
871 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
872 (GEOM::GEOM_Object_ptr theObject,
873 GEOM::GEOM_Object_ptr theStartLCS,
874 GEOM::GEOM_Object_ptr theEndLCS)
876 GEOM::GEOM_Object_var aGEOMObject;
878 //Set a not done flag
879 GetOperations()->SetNotDone();
881 //Get the basic object
882 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
883 if (aBasicObject.IsNull()) return aGEOMObject._retn();
885 //Get the Start LCS (may be NULL for positioning from global LCS)
886 Handle(GEOM_Object) aStartLCS;
887 if (!CORBA::is_nil(theStartLCS)) {
888 aStartLCS = GetObjectImpl(theStartLCS);
889 if (aStartLCS.IsNull()) return aGEOMObject._retn();
893 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
894 if (aEndLCS.IsNull()) return aGEOMObject._retn();
896 //Perform the position
897 Handle(GEOM_Object) anObject =
898 GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
899 if (!GetOperations()->IsDone() || anObject.IsNull())
900 return aGEOMObject._retn();
902 return GetObject(anObject);
905 //=============================================================================
909 //=============================================================================
910 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionAlongPath
911 (GEOM::GEOM_Object_ptr theObject,
912 GEOM::GEOM_Object_ptr thePath,
913 CORBA::Double theDistance,
914 CORBA::Boolean theCopy,
915 CORBA::Boolean theReverse)
917 GEOM::GEOM_Object_var aGEOMObject;
919 //Set a not done flag
920 GetOperations()->SetNotDone();
922 //Get the basic object
923 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
924 if (aBasicObject.IsNull()) return aGEOMObject._retn();
926 //Get the path object
927 Handle(GEOM_Object) aPathObject = GetObjectImpl(thePath);
928 if (aPathObject.IsNull()) return aGEOMObject._retn();
930 //Perform the position
931 Handle(GEOM_Object) anObject =
932 GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy, theReverse);
933 if (!GetOperations()->IsDone() || anObject.IsNull())
934 return aGEOMObject._retn();
936 return GetObject(anObject);
939 //=============================================================================
943 //=============================================================================
944 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
945 (GEOM::GEOM_Object_ptr theObject,
946 GEOM::GEOM_Object_ptr theVector,
947 CORBA::Double theStep, CORBA::Long theNbTimes)
949 //Set a not done flag
950 GetOperations()->SetNotDone();
952 GEOM::GEOM_Object_var aGEOMObject;
954 //Get the object itself
955 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
956 if (aBasicObject.IsNull()) return aGEOMObject._retn();
958 //Get the vector of translation
959 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
960 //if (aVector.IsNull()) return aGEOMObject._retn(); // DX by default
962 //Perform the translation
963 Handle(GEOM_Object) anObject =
964 GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
965 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
967 return GetObject(anObject);
970 //=============================================================================
974 //=============================================================================
975 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
976 GEOM::GEOM_Object_ptr theVector1,
977 CORBA::Double theStep1,
978 CORBA::Long theNbTimes1,
979 GEOM::GEOM_Object_ptr theVector2,
980 CORBA::Double theStep2,
981 CORBA::Long theNbTimes2)
983 //Set a not done flag
984 GetOperations()->SetNotDone();
986 GEOM::GEOM_Object_var aGEOMObject;
988 //Get the object itself
989 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
990 if (aBasicObject.IsNull()) return aGEOMObject._retn();
992 //Get the vector1 of translation
993 Handle(GEOM_Object) aVector1 = GetObjectImpl(theVector1);
994 //if (aVector1.IsNull()) return aGEOMObject._retn(); // DX by default
996 //Get the vector2 of translation
997 Handle(GEOM_Object) aVector2 = GetObjectImpl(theVector2);
998 //if (aVector2.IsNull()) return aGEOMObject._retn(); // DY by default
1000 //Perform the translation
1001 Handle(GEOM_Object) anObject = GetOperations()->Translate2D
1002 (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
1003 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1005 return GetObject(anObject);
1008 //=============================================================================
1012 //=============================================================================
1013 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
1014 GEOM::GEOM_Object_ptr theVector,
1015 CORBA::Long theNbTimes)
1017 //Set a not done flag
1018 GetOperations()->SetNotDone();
1020 GEOM::GEOM_Object_var aGEOMObject;
1022 //Get the object itself
1023 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1024 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1026 //Get the a directon of rotation
1027 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1028 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1030 //Perform the rotation
1031 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
1032 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1034 return GetObject(anObject);
1037 //=============================================================================
1039 * MultiRotate1DByStep
1041 //=============================================================================
1042 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1DByStep (GEOM::GEOM_Object_ptr theObject,
1043 GEOM::GEOM_Object_ptr theVector,
1044 CORBA::Double theAngleStep,
1045 CORBA::Long theNbSteps)
1047 //Set a not done flag
1048 GetOperations()->SetNotDone();
1050 GEOM::GEOM_Object_var aGEOMObject;
1052 //Get the object itself
1053 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1054 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1056 //Get the a directon of rotation
1057 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1058 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1060 //Perform the rotation
1061 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theAngleStep, theNbSteps);
1062 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1064 return GetObject(anObject);
1067 //=============================================================================
1069 * MultiRotate2DNbTimes
1071 //=============================================================================
1072 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2DNbTimes (GEOM::GEOM_Object_ptr theObject,
1073 GEOM::GEOM_Object_ptr theVector,
1074 CORBA::Long theNbObjects,
1075 CORBA::Double theRadialStep,
1076 CORBA::Long theNbSteps)
1078 //Set a not done flag
1079 GetOperations()->SetNotDone();
1081 GEOM::GEOM_Object_var aGEOMObject;
1083 //Get the object itself
1084 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1085 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1087 //Get the a directon of rotation
1088 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1089 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1091 //Perform the rotation
1092 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1093 (aBasicObject, aVector, theNbObjects, theRadialStep, theNbSteps);
1094 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1096 return GetObject(anObject);
1099 //=============================================================================
1101 * MultiRotate2DByStep
1103 //=============================================================================
1104 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2DByStep (GEOM::GEOM_Object_ptr theObject,
1105 GEOM::GEOM_Object_ptr theVector,
1106 CORBA::Double theAngle,
1107 CORBA::Long theNbTimes1,
1108 CORBA::Double theStep,
1109 CORBA::Long theNbTimes2)
1111 //Set a not done flag
1112 GetOperations()->SetNotDone();
1114 GEOM::GEOM_Object_var aGEOMObject;
1116 //Get the object itself
1117 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1118 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1120 //Get the a directon of rotation
1121 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1122 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1124 //Perform the rotation
1125 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1126 (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
1127 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1129 return GetObject(anObject);
1132 //=============================================================================
1136 //=============================================================================
1137 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
1138 GEOM::GEOM_Object_ptr theVector,
1139 CORBA::Double theAngle,
1140 CORBA::Long theNbTimes1,
1141 CORBA::Double theStep,
1142 CORBA::Long theNbTimes2)
1144 //Set a not done flag
1145 GetOperations()->SetNotDone();
1147 GEOM::GEOM_Object_var aGEOMObject;
1149 //Get the object itself
1150 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1151 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1153 //Get the a directon of rotation
1154 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1155 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1157 double anAngle = M_PI * theAngle / 180.;
1159 //Perform the rotation
1160 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1161 (aBasicObject, aVector, anAngle, theNbTimes1, theStep, theNbTimes2);
1162 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1164 return GetObject(anObject);
1167 //=============================================================================
1171 //=============================================================================
1172 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
1173 (GEOM::GEOM_Object_ptr theObject,
1174 GEOM::GEOM_Object_ptr theCentPoint,
1175 GEOM::GEOM_Object_ptr thePoint1,
1176 GEOM::GEOM_Object_ptr thePoint2)
1178 //Set a not done flag
1179 GetOperations()->SetNotDone();
1180 GEOM::GEOM_Object_var aGEOMObject;
1182 if (CORBA::is_nil(theObject))
1183 return aGEOMObject._retn();
1185 //check if the object is a sub-shape
1186 if (!theObject->IsMainShape()) {
1187 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
1188 return aGEOMObject._retn();
1191 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1193 //Get the object itself
1194 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1195 if (anObject.IsNull()) return aGEOMObject._retn();
1197 //Get the central point of rotation
1198 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1199 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1201 //Get the first point
1202 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1203 if (aPoint1.IsNull()) return aGEOMObject._retn();
1205 //Get the second point
1206 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1207 if (aPoint2.IsNull()) return aGEOMObject._retn();
1209 //Perform the translation
1210 GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1212 return aGEOMObject._retn();
1215 //=============================================================================
1217 * RotateThreePointsCopy
1219 //=============================================================================
1220 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1221 (GEOM::GEOM_Object_ptr theObject,
1222 GEOM::GEOM_Object_ptr theCentPoint,
1223 GEOM::GEOM_Object_ptr thePoint1,
1224 GEOM::GEOM_Object_ptr thePoint2)
1226 GEOM::GEOM_Object_var aGEOMObject;
1228 //Set a not done flag
1229 GetOperations()->SetNotDone();
1231 //Get the object itself
1232 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1233 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1235 //Get the central point of rotation
1236 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1237 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1239 //Get the first point
1240 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1241 if (aPoint1.IsNull()) return aGEOMObject._retn();
1243 //Get the second point
1244 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1245 if (aPoint2.IsNull()) return aGEOMObject._retn();
1247 //Perform the rotation
1248 Handle(GEOM_Object) anObject =
1249 GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1250 if (!GetOperations()->IsDone() || anObject.IsNull())
1251 return aGEOMObject._retn();
1253 return GetObject(anObject);
1256 //=============================================================================
1258 * TransformLikeOtherCopy
1260 //=============================================================================
1261 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TransformLikeOtherCopy
1262 (GEOM::GEOM_Object_ptr theObject,
1263 GEOM::GEOM_Object_ptr theSample)
1265 GEOM::GEOM_Object_var aGEOMObject;
1267 //Set a not done flag
1268 GetOperations()->SetNotDone();
1270 //Get the object itself
1271 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1272 if (anObject.IsNull()) return aGEOMObject._retn();
1274 //Get the sample object
1275 Handle(GEOM_Object) aSample = GetObjectImpl(theSample);
1276 if (aSample.IsNull()) return aGEOMObject._retn();
1278 //Perform the transformation
1279 Handle(GEOM_Object) aResObject =
1280 GetOperations()->TransformLikeOtherCopy(anObject, aSample);
1281 if (!GetOperations()->IsDone() || aResObject.IsNull())
1282 return aGEOMObject._retn();
1284 return GetObject(aResObject);
1287 //=============================================================================
1291 //=============================================================================
1292 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RecomputeObject
1293 (GEOM::GEOM_Object_ptr theObject)
1295 //Set a not done flag
1296 GetOperations()->SetNotDone();
1297 GEOM::GEOM_Object_var aGEOMObject;
1299 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
1301 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1303 //Get the object itself
1304 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1305 if (anObject.IsNull()) return aGEOMObject._retn();
1307 //Perform the recomputation
1308 Handle(GEOM_Function) aLastFunction = anObject->GetLastFunction();
1309 if (aLastFunction.IsNull()) return aGEOMObject._retn();
1310 GetOperations()->GetSolver()->ComputeFunction(aLastFunction);
1312 return aGEOMObject._retn();