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);
104 UpdateGUIForObject(theObject);
106 return aGEOMObject._retn();
109 //=============================================================================
111 * TranslateTwoPointsCopy
113 //=============================================================================
114 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy
115 (GEOM::GEOM_Object_ptr theObject,
116 GEOM::GEOM_Object_ptr thePoint1,
117 GEOM::GEOM_Object_ptr thePoint2)
119 GEOM::GEOM_Object_var aGEOMObject;
121 //Set a not done flag
122 GetOperations()->SetNotDone();
124 //Get the object itself
125 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
126 if (aBasicObject.IsNull()) return aGEOMObject._retn();
128 //Get the first point of translation
129 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
130 if (aPoint1.IsNull()) return aGEOMObject._retn();
132 //Get the second point of translation
133 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
134 if (aPoint2.IsNull()) return aGEOMObject._retn();
136 //Create the translated shape
137 Handle(GEOM_Object) anObject =
138 GetOperations()->TranslateTwoPointsCopy(aBasicObject, aPoint1, aPoint2);
139 if (!GetOperations()->IsDone() || anObject.IsNull())
140 return aGEOMObject._retn();
142 return GetObject(anObject);
145 //=============================================================================
149 //=============================================================================
150 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ
151 (GEOM::GEOM_Object_ptr theObject,
152 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
154 //Set a not done flag
155 GetOperations()->SetNotDone();
156 GEOM::GEOM_Object_var aGEOMObject;
158 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
160 //check if the object is a sub-shape
161 if (!theObject->IsMainShape()) {
162 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
163 return aGEOMObject._retn();
166 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
168 //Get the object itself
169 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
170 if (anObject.IsNull()) return aGEOMObject._retn();
172 //Perform the translation
173 GetOperations()->TranslateDXDYDZ(anObject, theDX, theDY, theDZ);
176 UpdateGUIForObject(theObject);
178 return aGEOMObject._retn();
181 //=============================================================================
183 * TranslateDXDYDZCopy
185 //=============================================================================
186 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy
187 (GEOM::GEOM_Object_ptr theObject,
188 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
190 GEOM::GEOM_Object_var aGEOMObject;
192 //Set a not done flag
193 GetOperations()->SetNotDone();
195 //Get the object itself
196 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
197 if (aBasicObject.IsNull()) return aGEOMObject._retn();
199 //Create the translated shape
200 Handle(GEOM_Object) anObject =
201 GetOperations()->TranslateDXDYDZCopy(aBasicObject, theDX, theDY, theDZ);
202 if (!GetOperations()->IsDone() || anObject.IsNull())
203 return aGEOMObject._retn();
205 return GetObject(anObject);
208 //=============================================================================
212 //=============================================================================
213 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector
214 (GEOM::GEOM_Object_ptr theObject,
215 GEOM::GEOM_Object_ptr theVector)
217 //Set a not done flag
218 GetOperations()->SetNotDone();
219 GEOM::GEOM_Object_var aGEOMObject;
221 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
223 //check if the object is a sub-shape
224 if (!theObject->IsMainShape()) {
225 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
226 return aGEOMObject._retn();
229 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
231 //Get the object itself
232 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
233 if (anObject.IsNull()) return aGEOMObject._retn();
235 //Get the vector of translation
236 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
237 if (aVector.IsNull()) return aGEOMObject._retn();
239 //Perform the translation
240 GetOperations()->TranslateVector(anObject, aVector);
243 UpdateGUIForObject(theObject);
245 return aGEOMObject._retn();
248 //=============================================================================
250 * TranslateVectorCopy
252 //=============================================================================
253 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy
254 (GEOM::GEOM_Object_ptr theObject,
255 GEOM::GEOM_Object_ptr theVector)
257 GEOM::GEOM_Object_var aGEOMObject;
259 //Set a not done flag
260 GetOperations()->SetNotDone();
262 //Get the object itself
263 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
264 if (aBasicObject.IsNull()) return aGEOMObject._retn();
266 //Get the vector of translation
267 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
268 if (aVector.IsNull()) return aGEOMObject._retn();
270 //Perform the translation
271 Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector);
272 if (!GetOperations()->IsDone() || anObject.IsNull())
273 return aGEOMObject._retn();
275 return GetObject(anObject);
278 //=============================================================================
280 * TranslateVectorDistance
282 //=============================================================================
283 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorDistance
284 (GEOM::GEOM_Object_ptr theObject,
285 GEOM::GEOM_Object_ptr theVector,
286 CORBA::Double theDistance,
287 CORBA::Boolean theCopy)
289 GEOM::GEOM_Object_var aGEOMObject;
290 GetOperations()->SetNotDone(); //Set a not done flag
292 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
294 //check if the object is a sub-shape
295 if (!theCopy && !theObject->IsMainShape()) {
296 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
297 return aGEOMObject._retn();
301 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
303 //Get the object itself
304 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
305 if (aBasicObject.IsNull()) return aGEOMObject._retn();
307 //Get the vector of translation
308 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
309 if (aVector.IsNull()) return aGEOMObject._retn();
311 //Perform the translation
313 Handle(GEOM_Object) anObject = GetOperations()->
314 TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
315 if (!GetOperations()->IsDone() || anObject.IsNull())
316 return aGEOMObject._retn();
318 return GetObject(anObject);
321 GetOperations()->TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
324 UpdateGUIForObject(theObject);
326 return aGEOMObject._retn();
329 //=============================================================================
333 //=============================================================================
334 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject,
335 GEOM::GEOM_Object_ptr theAxis,
336 CORBA::Double theAngle)
338 //Set a not done flag
339 GetOperations()->SetNotDone();
340 GEOM::GEOM_Object_var aGEOMObject;
342 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
344 //check if the object is a sub-shape
345 if (!theObject->IsMainShape()) {
346 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
347 return aGEOMObject._retn();
350 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
352 //Get the object itself
353 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
354 if (anObject.IsNull()) return aGEOMObject._retn();
356 //Get the axis of revolution
357 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
358 if (anAxis.IsNull()) return aGEOMObject._retn();
360 //Perform the rotation
361 GetOperations()->Rotate(anObject, anAxis, theAngle);
364 UpdateGUIForObject(theObject);
366 return aGEOMObject._retn();
369 //=============================================================================
373 //=============================================================================
374 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject,
375 GEOM::GEOM_Object_ptr theAxis,
376 CORBA::Double theAngle)
378 GEOM::GEOM_Object_var aGEOMObject;
380 //Set a not done flag
381 GetOperations()->SetNotDone();
383 //Get the object itself
384 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
385 if (aBasicObject.IsNull()) return aGEOMObject._retn();
387 //Get the axis of rotation
388 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
389 if (anAxis.IsNull()) return aGEOMObject._retn();
391 //Perform the rotation
392 Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle);
393 if (!GetOperations()->IsDone() || anObject.IsNull())
394 return aGEOMObject._retn();
396 return GetObject(anObject);
399 //=============================================================================
403 //=============================================================================
404 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
405 (GEOM::GEOM_Object_ptr theObject,
406 GEOM::GEOM_Object_ptr thePlane)
408 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
410 //Set a not done flag
411 GetOperations()->SetNotDone();
413 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
415 //check if the object is a sub-shape
416 if (!theObject->IsMainShape()) {
417 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
418 return aGEOMObject._retn();
421 //Get the object itself
422 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
423 if (anObject.IsNull()) return aGEOMObject._retn();
426 Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
427 if (aPlane.IsNull()) return aGEOMObject._retn();
430 GetOperations()->MirrorPlane(anObject, aPlane);
433 UpdateGUIForObject(theObject);
435 return aGEOMObject._retn();
438 //=============================================================================
442 //=============================================================================
443 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy
444 (GEOM::GEOM_Object_ptr theObject,
445 GEOM::GEOM_Object_ptr thePlane)
447 GEOM::GEOM_Object_var aGEOMObject;
449 //Set a not done flag
450 GetOperations()->SetNotDone();
452 //Get the object itself
453 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
454 if (aBasicObject.IsNull()) return aGEOMObject._retn();
456 //Get the vector of translation
457 Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
458 if (aPlane.IsNull()) return aGEOMObject._retn();
461 Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane);
462 if (!GetOperations()->IsDone() || anObject.IsNull())
463 return aGEOMObject._retn();
465 return GetObject(anObject);
468 //=============================================================================
472 //=============================================================================
473 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis
474 (GEOM::GEOM_Object_ptr theObject,
475 GEOM::GEOM_Object_ptr theAxis)
477 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
479 //Set a not done flag
480 GetOperations()->SetNotDone();
482 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
484 //check if the object is a sub-shape
485 if (!theObject->IsMainShape()) {
486 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
487 return aGEOMObject._retn();
490 //Get the object itself
491 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
492 if (anObject.IsNull()) return aGEOMObject._retn();
495 Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
496 if (aAxis.IsNull()) return aGEOMObject._retn();
499 GetOperations()->MirrorAxis(anObject, aAxis);
502 UpdateGUIForObject(theObject);
504 return aGEOMObject._retn();
507 //=============================================================================
511 //=============================================================================
512 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy
513 (GEOM::GEOM_Object_ptr theObject,
514 GEOM::GEOM_Object_ptr theAxis)
516 GEOM::GEOM_Object_var aGEOMObject;
518 //Set a not done flag
519 GetOperations()->SetNotDone();
521 //Get the object itself
522 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
523 if (aBasicObject.IsNull()) return aGEOMObject._retn();
525 //Get the vector of translation
526 Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
527 if (aAxis.IsNull()) return aGEOMObject._retn();
530 Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis);
531 if (!GetOperations()->IsDone() || anObject.IsNull())
532 return aGEOMObject._retn();
534 return GetObject(anObject);
537 //=============================================================================
541 //=============================================================================
542 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint
543 (GEOM::GEOM_Object_ptr theObject,
544 GEOM::GEOM_Object_ptr thePoint)
546 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
548 //Set a not done flag
549 GetOperations()->SetNotDone();
551 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
553 //check if the object is a sub-shape
554 if (!theObject->IsMainShape()) {
555 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
556 return aGEOMObject._retn();
559 //Get the object itself
560 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
561 if (anObject.IsNull()) return aGEOMObject._retn();
564 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
565 if (aPoint.IsNull()) return aGEOMObject._retn();
568 GetOperations()->MirrorPoint(anObject, aPoint);
571 UpdateGUIForObject(theObject);
573 return aGEOMObject._retn();
576 //=============================================================================
580 //=============================================================================
581 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy
582 (GEOM::GEOM_Object_ptr theObject,
583 GEOM::GEOM_Object_ptr thePoint)
585 GEOM::GEOM_Object_var aGEOMObject;
587 //Set a not done flag
588 GetOperations()->SetNotDone();
590 //Get the object itself
591 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
592 if (aBasicObject.IsNull()) return aGEOMObject._retn();
594 //Get the vector of translation
595 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
596 if (aPoint.IsNull()) return aGEOMObject._retn();
599 Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint);
600 if (!GetOperations()->IsDone() || anObject.IsNull())
601 return aGEOMObject._retn();
603 return GetObject(anObject);
606 //=============================================================================
610 //=============================================================================
611 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
612 (GEOM::GEOM_Object_ptr theObject,
613 CORBA::Double theOffset)
615 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
617 //Set a not done flag
618 GetOperations()->SetNotDone();
620 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
622 //check if the object is a sub-shape
623 if (!theObject->IsMainShape()) {
624 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
625 return aGEOMObject._retn();
628 //Get the basic object
629 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
630 if (aBasicObject.IsNull()) return aGEOMObject._retn();
632 //Create the offset shape
633 GetOperations()->OffsetShape(aBasicObject, theOffset);
636 UpdateGUIForObject(theObject);
638 return aGEOMObject._retn();
641 //=============================================================================
645 //=============================================================================
646 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
647 (GEOM::GEOM_Object_ptr theObject,
648 CORBA::Double theOffset)
650 GEOM::GEOM_Object_var aGEOMObject;
652 //Set a not done flag
653 GetOperations()->SetNotDone();
655 //Get the basic object
656 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
657 if (aBasicObject.IsNull()) return aGEOMObject._retn();
659 //Create the offset shape
660 Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset);
661 if (!GetOperations()->IsDone() || anObject.IsNull())
662 return aGEOMObject._retn();
664 return GetObject(anObject);
667 //=============================================================================
671 //=============================================================================
672 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ProjectShapeCopy
673 (GEOM::GEOM_Object_ptr theSource,
674 GEOM::GEOM_Object_ptr theTarget)
676 GEOM::GEOM_Object_var aGEOMObject;
678 //Set a not done flag
679 GetOperations()->SetNotDone();
681 //Get the input objects
682 Handle(GEOM_Object) aSource = GetObjectImpl(theSource);
683 Handle(GEOM_Object) aTarget = GetObjectImpl(theTarget);
684 if (aSource.IsNull() || aTarget.IsNull()) return aGEOMObject._retn();
686 //Create the projection
687 Handle(GEOM_Object) anObject = GetOperations()->ProjectShapeCopy(aSource, aTarget);
688 if (!GetOperations()->IsDone() || anObject.IsNull())
689 return aGEOMObject._retn();
691 return GetObject(anObject);
694 //=============================================================================
698 //=============================================================================
699 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
700 (GEOM::GEOM_Object_ptr theObject,
701 GEOM::GEOM_Object_ptr thePoint,
702 CORBA::Double theFactor)
704 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
706 //Set a not done flag
707 GetOperations()->SetNotDone();
709 if (theObject->_is_nil()) return aGEOMObject._retn();
711 //check if the object is a sub-shape
712 if (!theObject->IsMainShape()) {
713 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
714 return aGEOMObject._retn();
717 //Get the object itself
718 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
719 if (anObject.IsNull()) return aGEOMObject._retn();
722 Handle(GEOM_Object) aPoint;
723 if (!thePoint->_is_nil()) {
724 aPoint = GetObjectImpl(thePoint);
725 if (aPoint.IsNull()) return aGEOMObject._retn();
729 GetOperations()->ScaleShape(anObject, aPoint, theFactor);
732 UpdateGUIForObject(theObject);
734 return aGEOMObject._retn();
737 //=============================================================================
741 //=============================================================================
742 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
743 (GEOM::GEOM_Object_ptr theObject,
744 GEOM::GEOM_Object_ptr thePoint,
745 CORBA::Double theFactor)
747 GEOM::GEOM_Object_var aGEOMObject;
749 //Set a not done flag
750 GetOperations()->SetNotDone();
752 //Get the basic object
753 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
754 if (aBasicObject.IsNull()) return aGEOMObject._retn();
757 Handle(GEOM_Object) aPoint;
758 if (!thePoint->_is_nil()) {
759 aPoint = GetObjectImpl(thePoint);
760 if (aPoint.IsNull()) return aGEOMObject._retn();
764 Handle(GEOM_Object) anObject =
765 GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
766 if (!GetOperations()->IsDone() || anObject.IsNull())
767 return aGEOMObject._retn();
769 return GetObject(anObject);
772 //=============================================================================
774 * ScaleShapeAlongAxes
776 //=============================================================================
777 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxes
778 (GEOM::GEOM_Object_ptr theObject,
779 GEOM::GEOM_Object_ptr thePoint,
780 CORBA::Double theFactorX,
781 CORBA::Double theFactorY,
782 CORBA::Double theFactorZ)
784 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
786 //Set a not done flag
787 GetOperations()->SetNotDone();
789 if (theObject->_is_nil()) return aGEOMObject._retn();
791 //check if the object is a sub-shape
792 if (!theObject->IsMainShape()) {
793 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
794 return aGEOMObject._retn();
797 //Get the object itself
798 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
799 if (anObject.IsNull()) return aGEOMObject._retn();
802 Handle(GEOM_Object) aPoint;
803 if (!thePoint->_is_nil()) {
804 aPoint = GetObjectImpl(thePoint);
805 if (aPoint.IsNull()) return aGEOMObject._retn();
809 GetOperations()->ScaleShapeAlongAxes
810 (anObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/false);
813 UpdateGUIForObject(theObject);
815 return aGEOMObject._retn();
818 //=============================================================================
820 * ScaleShapeAlongAxesCopy
822 //=============================================================================
823 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxesCopy
824 (GEOM::GEOM_Object_ptr theObject,
825 GEOM::GEOM_Object_ptr thePoint,
826 CORBA::Double theFactorX,
827 CORBA::Double theFactorY,
828 CORBA::Double theFactorZ)
830 GEOM::GEOM_Object_var aGEOMObject;
832 //Set a not done flag
833 GetOperations()->SetNotDone();
835 //Get the basic object
836 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
837 if (aBasicObject.IsNull()) return aGEOMObject._retn();
840 Handle(GEOM_Object) aPoint;
841 if (!thePoint->_is_nil()) {
842 aPoint = GetObjectImpl(thePoint);
843 if (aPoint.IsNull()) return aGEOMObject._retn();
847 Handle(GEOM_Object) anObject = GetOperations()->ScaleShapeAlongAxes
848 (aBasicObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/true);
849 if (!GetOperations()->IsDone() || anObject.IsNull())
850 return aGEOMObject._retn();
852 return GetObject(anObject);
855 //=============================================================================
859 //=============================================================================
860 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
861 (GEOM::GEOM_Object_ptr theObject,
862 GEOM::GEOM_Object_ptr theStartLCS,
863 GEOM::GEOM_Object_ptr theEndLCS)
865 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
867 //Set a not done flag
868 GetOperations()->SetNotDone();
870 if (CORBA::is_nil(theObject) || CORBA::is_nil(theEndLCS))
871 return aGEOMObject._retn();
873 //check if the object is a sub-shape
874 if (!theObject->IsMainShape()) {
875 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
876 return aGEOMObject._retn();
879 //Get the basic object
880 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
881 if (anObject.IsNull()) return aGEOMObject._retn();
883 //Get the Start LCS (may be NULL for positioning from global LCS)
884 Handle(GEOM_Object) aStartLCS;
885 if (!CORBA::is_nil(theStartLCS)) {
886 aStartLCS = GetObjectImpl(theStartLCS);
887 if (aStartLCS.IsNull()) return aGEOMObject._retn();
891 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
892 if (aEndLCS.IsNull()) return aGEOMObject._retn();
894 //Perform the Position
895 GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
898 UpdateGUIForObject(theObject);
900 return aGEOMObject._retn();
903 //=============================================================================
907 //=============================================================================
908 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
909 (GEOM::GEOM_Object_ptr theObject,
910 GEOM::GEOM_Object_ptr theStartLCS,
911 GEOM::GEOM_Object_ptr theEndLCS)
913 GEOM::GEOM_Object_var aGEOMObject;
915 //Set a not done flag
916 GetOperations()->SetNotDone();
918 //Get the basic object
919 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
920 if (aBasicObject.IsNull()) return aGEOMObject._retn();
922 //Get the Start LCS (may be NULL for positioning from global LCS)
923 Handle(GEOM_Object) aStartLCS;
924 if (!CORBA::is_nil(theStartLCS)) {
925 aStartLCS = GetObjectImpl(theStartLCS);
926 if (aStartLCS.IsNull()) return aGEOMObject._retn();
930 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
931 if (aEndLCS.IsNull()) return aGEOMObject._retn();
933 //Perform the position
934 Handle(GEOM_Object) anObject =
935 GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
936 if (!GetOperations()->IsDone() || anObject.IsNull())
937 return aGEOMObject._retn();
939 return GetObject(anObject);
942 //=============================================================================
946 //=============================================================================
947 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionAlongPath
948 (GEOM::GEOM_Object_ptr theObject,
949 GEOM::GEOM_Object_ptr thePath,
950 CORBA::Double theDistance,
951 CORBA::Boolean theCopy,
952 CORBA::Boolean theReverse)
954 GEOM::GEOM_Object_var aGEOMObject;
956 //Set a not done flag
957 GetOperations()->SetNotDone();
959 //Get the basic object
960 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
961 if (aBasicObject.IsNull()) return aGEOMObject._retn();
963 //Get the path object
964 Handle(GEOM_Object) aPathObject = GetObjectImpl(thePath);
965 if (aPathObject.IsNull()) return aGEOMObject._retn();
967 //Perform the position
968 Handle(GEOM_Object) anObject =
969 GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy, theReverse);
970 if (!GetOperations()->IsDone() || anObject.IsNull())
971 return aGEOMObject._retn();
975 UpdateGUIForObject(theObject);
978 return GetObject(anObject);
981 //=============================================================================
985 //=============================================================================
986 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
987 (GEOM::GEOM_Object_ptr theObject,
988 GEOM::GEOM_Object_ptr theVector,
989 CORBA::Double theStep, CORBA::Long theNbTimes)
991 //Set a not done flag
992 GetOperations()->SetNotDone();
994 GEOM::GEOM_Object_var aGEOMObject;
996 //Get the object itself
997 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
998 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1000 //Get the vector of translation
1001 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1002 //if (aVector.IsNull()) return aGEOMObject._retn(); // DX by default
1004 //Perform the translation
1005 Handle(GEOM_Object) anObject =
1006 GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
1007 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1009 return GetObject(anObject);
1012 //=============================================================================
1016 //=============================================================================
1017 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
1018 GEOM::GEOM_Object_ptr theVector1,
1019 CORBA::Double theStep1,
1020 CORBA::Long theNbTimes1,
1021 GEOM::GEOM_Object_ptr theVector2,
1022 CORBA::Double theStep2,
1023 CORBA::Long theNbTimes2)
1025 //Set a not done flag
1026 GetOperations()->SetNotDone();
1028 GEOM::GEOM_Object_var aGEOMObject;
1030 //Get the object itself
1031 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1032 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1034 //Get the vector1 of translation
1035 Handle(GEOM_Object) aVector1 = GetObjectImpl(theVector1);
1036 //if (aVector1.IsNull()) return aGEOMObject._retn(); // DX by default
1038 //Get the vector2 of translation
1039 Handle(GEOM_Object) aVector2 = GetObjectImpl(theVector2);
1040 //if (aVector2.IsNull()) return aGEOMObject._retn(); // DY by default
1042 //Perform the translation
1043 Handle(GEOM_Object) anObject = GetOperations()->Translate2D
1044 (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
1045 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1047 return GetObject(anObject);
1050 //=============================================================================
1054 //=============================================================================
1055 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
1056 GEOM::GEOM_Object_ptr theVector,
1057 CORBA::Long theNbTimes)
1059 //Set a not done flag
1060 GetOperations()->SetNotDone();
1062 GEOM::GEOM_Object_var aGEOMObject;
1064 //Get the object itself
1065 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1066 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1068 //Get the a directon of rotation
1069 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1070 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1072 //Perform the rotation
1073 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
1074 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1076 return GetObject(anObject);
1079 //=============================================================================
1081 * MultiRotate1DByStep
1083 //=============================================================================
1084 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1DByStep (GEOM::GEOM_Object_ptr theObject,
1085 GEOM::GEOM_Object_ptr theVector,
1086 CORBA::Double theAngleStep,
1087 CORBA::Long theNbSteps)
1089 //Set a not done flag
1090 GetOperations()->SetNotDone();
1092 GEOM::GEOM_Object_var aGEOMObject;
1094 //Get the object itself
1095 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1096 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1098 //Get the a directon of rotation
1099 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1100 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1102 //Perform the rotation
1103 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theAngleStep, theNbSteps);
1104 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1106 return GetObject(anObject);
1109 //=============================================================================
1111 * MultiRotate2DNbTimes
1113 //=============================================================================
1114 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2DNbTimes (GEOM::GEOM_Object_ptr theObject,
1115 GEOM::GEOM_Object_ptr theVector,
1116 CORBA::Long theNbObjects,
1117 CORBA::Double theRadialStep,
1118 CORBA::Long theNbSteps)
1120 //Set a not done flag
1121 GetOperations()->SetNotDone();
1123 GEOM::GEOM_Object_var aGEOMObject;
1125 //Get the object itself
1126 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1127 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1129 //Get the a directon of rotation
1130 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1131 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1133 //Perform the rotation
1134 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1135 (aBasicObject, aVector, theNbObjects, theRadialStep, theNbSteps);
1136 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1138 return GetObject(anObject);
1141 //=============================================================================
1143 * MultiRotate2DByStep
1145 //=============================================================================
1146 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2DByStep (GEOM::GEOM_Object_ptr theObject,
1147 GEOM::GEOM_Object_ptr theVector,
1148 CORBA::Double theAngle,
1149 CORBA::Long theNbTimes1,
1150 CORBA::Double theStep,
1151 CORBA::Long theNbTimes2)
1153 //Set a not done flag
1154 GetOperations()->SetNotDone();
1156 GEOM::GEOM_Object_var aGEOMObject;
1158 //Get the object itself
1159 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1160 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1162 //Get the a directon of rotation
1163 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1164 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1166 //Perform the rotation
1167 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1168 (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
1169 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1171 return GetObject(anObject);
1174 //=============================================================================
1178 //=============================================================================
1179 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
1180 GEOM::GEOM_Object_ptr theVector,
1181 CORBA::Double theAngle,
1182 CORBA::Long theNbTimes1,
1183 CORBA::Double theStep,
1184 CORBA::Long theNbTimes2)
1186 //Set a not done flag
1187 GetOperations()->SetNotDone();
1189 GEOM::GEOM_Object_var aGEOMObject;
1191 //Get the object itself
1192 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1193 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1195 //Get the a directon of rotation
1196 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1197 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1199 double anAngle = M_PI * theAngle / 180.;
1201 //Perform the rotation
1202 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1203 (aBasicObject, aVector, anAngle, theNbTimes1, theStep, theNbTimes2);
1204 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1206 return GetObject(anObject);
1209 //=============================================================================
1213 //=============================================================================
1214 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
1215 (GEOM::GEOM_Object_ptr theObject,
1216 GEOM::GEOM_Object_ptr theCentPoint,
1217 GEOM::GEOM_Object_ptr thePoint1,
1218 GEOM::GEOM_Object_ptr thePoint2)
1220 //Set a not done flag
1221 GetOperations()->SetNotDone();
1222 GEOM::GEOM_Object_var aGEOMObject;
1224 if (CORBA::is_nil(theObject))
1225 return aGEOMObject._retn();
1227 //check if the object is a sub-shape
1228 if (!theObject->IsMainShape()) {
1229 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
1230 return aGEOMObject._retn();
1233 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1235 //Get the object itself
1236 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1237 if (anObject.IsNull()) return aGEOMObject._retn();
1239 //Get the central point of rotation
1240 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1241 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1243 //Get the first point
1244 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1245 if (aPoint1.IsNull()) return aGEOMObject._retn();
1247 //Get the second point
1248 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1249 if (aPoint2.IsNull()) return aGEOMObject._retn();
1251 //Perform the translation
1252 GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1255 UpdateGUIForObject(theObject);
1257 return aGEOMObject._retn();
1260 //=============================================================================
1262 * RotateThreePointsCopy
1264 //=============================================================================
1265 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1266 (GEOM::GEOM_Object_ptr theObject,
1267 GEOM::GEOM_Object_ptr theCentPoint,
1268 GEOM::GEOM_Object_ptr thePoint1,
1269 GEOM::GEOM_Object_ptr thePoint2)
1271 GEOM::GEOM_Object_var aGEOMObject;
1273 //Set a not done flag
1274 GetOperations()->SetNotDone();
1276 //Get the object itself
1277 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1278 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1280 //Get the central point of rotation
1281 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1282 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1284 //Get the first point
1285 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1286 if (aPoint1.IsNull()) return aGEOMObject._retn();
1288 //Get the second point
1289 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1290 if (aPoint2.IsNull()) return aGEOMObject._retn();
1292 //Perform the rotation
1293 Handle(GEOM_Object) anObject =
1294 GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1295 if (!GetOperations()->IsDone() || anObject.IsNull())
1296 return aGEOMObject._retn();
1298 return GetObject(anObject);
1301 //=============================================================================
1303 * TransformLikeOtherCopy
1305 //=============================================================================
1306 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TransformLikeOtherCopy
1307 (GEOM::GEOM_Object_ptr theObject,
1308 GEOM::GEOM_Object_ptr theSample)
1310 GEOM::GEOM_Object_var aGEOMObject;
1312 //Set a not done flag
1313 GetOperations()->SetNotDone();
1315 //Get the object itself
1316 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1317 if (anObject.IsNull()) return aGEOMObject._retn();
1319 //Get the sample object
1320 Handle(GEOM_Object) aSample = GetObjectImpl(theSample);
1321 if (aSample.IsNull()) return aGEOMObject._retn();
1323 //Perform the transformation
1324 Handle(GEOM_Object) aResObject =
1325 GetOperations()->TransformLikeOtherCopy(anObject, aSample);
1326 if (!GetOperations()->IsDone() || aResObject.IsNull())
1327 return aGEOMObject._retn();
1329 return GetObject(aResObject);
1332 //=============================================================================
1336 //=============================================================================
1337 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RecomputeObject
1338 (GEOM::GEOM_Object_ptr theObject)
1340 //Set a not done flag
1341 GetOperations()->SetNotDone();
1342 GEOM::GEOM_Object_var aGEOMObject;
1344 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
1346 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1348 //Get the object itself
1349 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1350 if (anObject.IsNull()) return aGEOMObject._retn();
1352 //Perform the recomputation
1353 Handle(GEOM_Function) aLastFunction = anObject->GetLastFunction();
1354 if (aLastFunction.IsNull()) return aGEOMObject._retn();
1355 GetOperations()->GetSolver()->ComputeFunction(aLastFunction);
1357 return aGEOMObject._retn();