1 // Copyright (C) 2007-2013 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_ITransformOperations_i.hh"
27 #include "utilities.h"
29 #include "Utils_ExceptHandlers.hxx"
31 #include <TDF_Label.hxx>
32 #include <TDF_Tool.hxx>
33 #include <TCollection_AsciiString.hxx>
34 #include "GEOM_Engine.hxx"
35 #include "GEOM_Object.hxx"
37 #define SUBSHAPE_ERROR "Sub shape cannot be transformed"
39 //=============================================================================
43 //=============================================================================
45 GEOM_ITransformOperations_i::GEOM_ITransformOperations_i (PortableServer::POA_ptr thePOA,
46 GEOM::GEOM_Gen_ptr theEngine,
47 ::GEOMImpl_ITransformOperations* theImpl)
48 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
50 MESSAGE("GEOM_ITransformOperations_i::GEOM_ITransformOperations_i");
53 //=============================================================================
57 //=============================================================================
59 GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i()
61 MESSAGE("GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i");
65 //=============================================================================
69 //=============================================================================
70 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPoints
71 (GEOM::GEOM_Object_ptr theObject,
72 GEOM::GEOM_Object_ptr thePoint1,
73 GEOM::GEOM_Object_ptr thePoint2)
76 GetOperations()->SetNotDone();
77 GEOM::GEOM_Object_var aGEOMObject;
79 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
81 //check if the object is a sub-shape
82 if (!theObject->IsMainShape()) {
83 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
84 return aGEOMObject._retn();
87 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
89 //Get the object itself
90 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
91 if (anObject.IsNull()) return aGEOMObject._retn();
93 //Get the first point of translation
94 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
95 if (aPoint1.IsNull()) return aGEOMObject._retn();
97 //Get the second point of translation
98 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
99 if (aPoint2.IsNull()) return aGEOMObject._retn();
101 //Perform the translation
102 GetOperations()->TranslateTwoPoints(anObject, aPoint1, aPoint2);
105 UpdateGUIForObject(theObject);
107 return aGEOMObject._retn();
110 //=============================================================================
112 * TranslateTwoPointsCopy
114 //=============================================================================
115 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy
116 (GEOM::GEOM_Object_ptr theObject,
117 GEOM::GEOM_Object_ptr thePoint1,
118 GEOM::GEOM_Object_ptr thePoint2)
120 GEOM::GEOM_Object_var aGEOMObject;
122 //Set a not done flag
123 GetOperations()->SetNotDone();
125 //Get the object itself
126 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
127 if (aBasicObject.IsNull()) return aGEOMObject._retn();
129 //Get the first point of translation
130 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
131 if (aPoint1.IsNull()) return aGEOMObject._retn();
133 //Get the second point of translation
134 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
135 if (aPoint2.IsNull()) return aGEOMObject._retn();
137 //Create the translated shape
138 Handle(GEOM_Object) anObject =
139 GetOperations()->TranslateTwoPointsCopy(aBasicObject, aPoint1, aPoint2);
140 if (!GetOperations()->IsDone() || anObject.IsNull())
141 return aGEOMObject._retn();
143 return GetObject(anObject);
146 //=============================================================================
150 //=============================================================================
151 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ
152 (GEOM::GEOM_Object_ptr theObject,
153 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
155 //Set a not done flag
156 GetOperations()->SetNotDone();
157 GEOM::GEOM_Object_var aGEOMObject;
159 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
161 //check if the object is a sub-shape
162 if (!theObject->IsMainShape()) {
163 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
164 return aGEOMObject._retn();
167 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
169 //Get the object itself
170 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
171 if (anObject.IsNull()) return aGEOMObject._retn();
173 //Perform the translation
174 GetOperations()->TranslateDXDYDZ(anObject, theDX, theDY, theDZ);
177 UpdateGUIForObject(theObject);
179 return aGEOMObject._retn();
182 //=============================================================================
184 * TranslateDXDYDZCopy
186 //=============================================================================
187 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy
188 (GEOM::GEOM_Object_ptr theObject,
189 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
191 GEOM::GEOM_Object_var aGEOMObject;
193 //Set a not done flag
194 GetOperations()->SetNotDone();
196 //Get the object itself
197 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
198 if (aBasicObject.IsNull()) return aGEOMObject._retn();
200 //Create the translated shape
201 Handle(GEOM_Object) anObject =
202 GetOperations()->TranslateDXDYDZCopy(aBasicObject, theDX, theDY, theDZ);
203 if (!GetOperations()->IsDone() || anObject.IsNull())
204 return aGEOMObject._retn();
206 return GetObject(anObject);
209 //=============================================================================
213 //=============================================================================
214 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector
215 (GEOM::GEOM_Object_ptr theObject,
216 GEOM::GEOM_Object_ptr theVector)
218 //Set a not done flag
219 GetOperations()->SetNotDone();
220 GEOM::GEOM_Object_var aGEOMObject;
222 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
224 //check if the object is a sub-shape
225 if (!theObject->IsMainShape()) {
226 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
227 return aGEOMObject._retn();
230 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
232 //Get the object itself
233 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
234 if (anObject.IsNull()) return aGEOMObject._retn();
236 //Get the vector of translation
237 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
238 if (aVector.IsNull()) return aGEOMObject._retn();
240 //Perform the translation
241 GetOperations()->TranslateVector(anObject, aVector);
244 UpdateGUIForObject(theObject);
246 return aGEOMObject._retn();
249 //=============================================================================
251 * TranslateVectorCopy
253 //=============================================================================
254 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy
255 (GEOM::GEOM_Object_ptr theObject,
256 GEOM::GEOM_Object_ptr theVector)
258 GEOM::GEOM_Object_var aGEOMObject;
260 //Set a not done flag
261 GetOperations()->SetNotDone();
263 //Get the object itself
264 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
265 if (aBasicObject.IsNull()) return aGEOMObject._retn();
267 //Get the vector of translation
268 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
269 if (aVector.IsNull()) return aGEOMObject._retn();
271 //Perform the translation
272 Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector);
273 if (!GetOperations()->IsDone() || anObject.IsNull())
274 return aGEOMObject._retn();
276 return GetObject(anObject);
279 //=============================================================================
281 * TranslateVectorDistance
283 //=============================================================================
284 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorDistance
285 (GEOM::GEOM_Object_ptr theObject,
286 GEOM::GEOM_Object_ptr theVector,
287 CORBA::Double theDistance,
288 CORBA::Boolean theCopy)
290 GEOM::GEOM_Object_var aGEOMObject;
291 GetOperations()->SetNotDone(); //Set a not done flag
293 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
295 //check if the object is a sub-shape
296 if (!theCopy && !theObject->IsMainShape()) {
297 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
298 return aGEOMObject._retn();
302 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
304 //Get the object itself
305 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
306 if (aBasicObject.IsNull()) return aGEOMObject._retn();
308 //Get the vector of translation
309 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
310 if (aVector.IsNull()) return aGEOMObject._retn();
312 //Perform the translation
314 Handle(GEOM_Object) anObject = GetOperations()->
315 TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
316 if (!GetOperations()->IsDone() || anObject.IsNull())
317 return aGEOMObject._retn();
319 return GetObject(anObject);
322 GetOperations()->TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
325 UpdateGUIForObject(theObject);
327 return aGEOMObject._retn();
330 //=============================================================================
334 //=============================================================================
335 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject,
336 GEOM::GEOM_Object_ptr theAxis,
337 CORBA::Double theAngle)
339 //Set a not done flag
340 GetOperations()->SetNotDone();
341 GEOM::GEOM_Object_var aGEOMObject;
343 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
345 //check if the object is a sub-shape
346 if (!theObject->IsMainShape()) {
347 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
348 return aGEOMObject._retn();
351 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
353 //Get the object itself
354 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
355 if (anObject.IsNull()) return aGEOMObject._retn();
357 //Get the axis of revolution
358 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
359 if (anAxis.IsNull()) return aGEOMObject._retn();
361 //Perform the rotation
362 GetOperations()->Rotate(anObject, anAxis, theAngle);
365 UpdateGUIForObject(theObject);
367 return aGEOMObject._retn();
370 //=============================================================================
374 //=============================================================================
375 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject,
376 GEOM::GEOM_Object_ptr theAxis,
377 CORBA::Double theAngle)
379 GEOM::GEOM_Object_var aGEOMObject;
381 //Set a not done flag
382 GetOperations()->SetNotDone();
384 //Get the object itself
385 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
386 if (aBasicObject.IsNull()) return aGEOMObject._retn();
388 //Get the axis of rotation
389 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
390 if (anAxis.IsNull()) return aGEOMObject._retn();
392 //Perform the rotation
393 Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle);
394 if (!GetOperations()->IsDone() || anObject.IsNull())
395 return aGEOMObject._retn();
397 return GetObject(anObject);
400 //=============================================================================
404 //=============================================================================
405 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
406 (GEOM::GEOM_Object_ptr theObject,
407 GEOM::GEOM_Object_ptr thePlane)
409 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
411 //Set a not done flag
412 GetOperations()->SetNotDone();
414 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
416 //check if the object is a sub-shape
417 if (!theObject->IsMainShape()) {
418 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
419 return aGEOMObject._retn();
422 //Get the object itself
423 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
424 if (anObject.IsNull()) return aGEOMObject._retn();
427 Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
428 if (aPlane.IsNull()) return aGEOMObject._retn();
431 GetOperations()->MirrorPlane(anObject, aPlane);
434 UpdateGUIForObject(theObject);
436 return aGEOMObject._retn();
439 //=============================================================================
443 //=============================================================================
444 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy
445 (GEOM::GEOM_Object_ptr theObject,
446 GEOM::GEOM_Object_ptr thePlane)
448 GEOM::GEOM_Object_var aGEOMObject;
450 //Set a not done flag
451 GetOperations()->SetNotDone();
453 //Get the object itself
454 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
455 if (aBasicObject.IsNull()) return aGEOMObject._retn();
457 //Get the vector of translation
458 Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
459 if (aPlane.IsNull()) return aGEOMObject._retn();
462 Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane);
463 if (!GetOperations()->IsDone() || anObject.IsNull())
464 return aGEOMObject._retn();
466 return GetObject(anObject);
469 //=============================================================================
473 //=============================================================================
474 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis
475 (GEOM::GEOM_Object_ptr theObject,
476 GEOM::GEOM_Object_ptr theAxis)
478 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
480 //Set a not done flag
481 GetOperations()->SetNotDone();
483 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
485 //check if the object is a sub-shape
486 if (!theObject->IsMainShape()) {
487 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
488 return aGEOMObject._retn();
491 //Get the object itself
492 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
493 if (anObject.IsNull()) return aGEOMObject._retn();
496 Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
497 if (aAxis.IsNull()) return aGEOMObject._retn();
500 GetOperations()->MirrorAxis(anObject, aAxis);
503 UpdateGUIForObject(theObject);
505 return aGEOMObject._retn();
508 //=============================================================================
512 //=============================================================================
513 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy
514 (GEOM::GEOM_Object_ptr theObject,
515 GEOM::GEOM_Object_ptr theAxis)
517 GEOM::GEOM_Object_var aGEOMObject;
519 //Set a not done flag
520 GetOperations()->SetNotDone();
522 //Get the object itself
523 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
524 if (aBasicObject.IsNull()) return aGEOMObject._retn();
526 //Get the vector of translation
527 Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
528 if (aAxis.IsNull()) return aGEOMObject._retn();
531 Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis);
532 if (!GetOperations()->IsDone() || anObject.IsNull())
533 return aGEOMObject._retn();
535 return GetObject(anObject);
538 //=============================================================================
542 //=============================================================================
543 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint
544 (GEOM::GEOM_Object_ptr theObject,
545 GEOM::GEOM_Object_ptr thePoint)
547 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
549 //Set a not done flag
550 GetOperations()->SetNotDone();
552 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
554 //check if the object is a sub-shape
555 if (!theObject->IsMainShape()) {
556 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
557 return aGEOMObject._retn();
560 //Get the object itself
561 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
562 if (anObject.IsNull()) return aGEOMObject._retn();
565 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
566 if (aPoint.IsNull()) return aGEOMObject._retn();
569 GetOperations()->MirrorPoint(anObject, aPoint);
572 UpdateGUIForObject(theObject);
574 return aGEOMObject._retn();
577 //=============================================================================
581 //=============================================================================
582 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy
583 (GEOM::GEOM_Object_ptr theObject,
584 GEOM::GEOM_Object_ptr thePoint)
586 GEOM::GEOM_Object_var aGEOMObject;
588 //Set a not done flag
589 GetOperations()->SetNotDone();
591 //Get the object itself
592 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
593 if (aBasicObject.IsNull()) return aGEOMObject._retn();
595 //Get the vector of translation
596 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
597 if (aPoint.IsNull()) return aGEOMObject._retn();
600 Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint);
601 if (!GetOperations()->IsDone() || anObject.IsNull())
602 return aGEOMObject._retn();
604 return GetObject(anObject);
607 //=============================================================================
611 //=============================================================================
612 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
613 (GEOM::GEOM_Object_ptr theObject,
614 CORBA::Double theOffset)
616 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
618 //Set a not done flag
619 GetOperations()->SetNotDone();
621 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
623 //check if the object is a sub-shape
624 if (!theObject->IsMainShape()) {
625 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
626 return aGEOMObject._retn();
629 //Get the basic object
630 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
631 if (aBasicObject.IsNull()) return aGEOMObject._retn();
633 //Create the offset shape
634 GetOperations()->OffsetShape(aBasicObject, theOffset);
637 UpdateGUIForObject(theObject);
639 return aGEOMObject._retn();
642 //=============================================================================
646 //=============================================================================
647 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
648 (GEOM::GEOM_Object_ptr theObject,
649 CORBA::Double theOffset)
651 GEOM::GEOM_Object_var aGEOMObject;
653 //Set a not done flag
654 GetOperations()->SetNotDone();
656 //Get the basic object
657 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
658 if (aBasicObject.IsNull()) return aGEOMObject._retn();
660 //Create the offset shape
661 Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset);
662 if (!GetOperations()->IsDone() || anObject.IsNull())
663 return aGEOMObject._retn();
665 return GetObject(anObject);
668 //=============================================================================
672 //=============================================================================
673 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ProjectShapeCopy
674 (GEOM::GEOM_Object_ptr theSource,
675 GEOM::GEOM_Object_ptr theTarget)
677 GEOM::GEOM_Object_var aGEOMObject;
679 //Set a not done flag
680 GetOperations()->SetNotDone();
682 //Get the input objects
683 Handle(GEOM_Object) aSource = GetObjectImpl(theSource);
684 Handle(GEOM_Object) aTarget = GetObjectImpl(theTarget);
685 if (aSource.IsNull() || aTarget.IsNull()) return aGEOMObject._retn();
687 //Create the projection
688 Handle(GEOM_Object) anObject = GetOperations()->ProjectShapeCopy(aSource, aTarget);
689 if (!GetOperations()->IsDone() || anObject.IsNull())
690 return aGEOMObject._retn();
692 return GetObject(anObject);
695 //=============================================================================
699 //=============================================================================
700 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
701 (GEOM::GEOM_Object_ptr theObject,
702 GEOM::GEOM_Object_ptr thePoint,
703 CORBA::Double theFactor)
705 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
707 //Set a not done flag
708 GetOperations()->SetNotDone();
710 if (theObject->_is_nil()) return aGEOMObject._retn();
712 //check if the object is a sub-shape
713 if (!theObject->IsMainShape()) {
714 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
715 return aGEOMObject._retn();
718 //Get the object itself
719 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
720 if (anObject.IsNull()) return aGEOMObject._retn();
723 Handle(GEOM_Object) aPoint;
724 if (!thePoint->_is_nil()) {
725 aPoint = GetObjectImpl(thePoint);
726 if (aPoint.IsNull()) return aGEOMObject._retn();
730 GetOperations()->ScaleShape(anObject, aPoint, theFactor);
733 UpdateGUIForObject(theObject);
735 return aGEOMObject._retn();
738 //=============================================================================
742 //=============================================================================
743 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
744 (GEOM::GEOM_Object_ptr theObject,
745 GEOM::GEOM_Object_ptr thePoint,
746 CORBA::Double theFactor)
748 GEOM::GEOM_Object_var aGEOMObject;
750 //Set a not done flag
751 GetOperations()->SetNotDone();
753 //Get the basic object
754 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
755 if (aBasicObject.IsNull()) return aGEOMObject._retn();
758 Handle(GEOM_Object) aPoint;
759 if (!thePoint->_is_nil()) {
760 aPoint = GetObjectImpl(thePoint);
761 if (aPoint.IsNull()) return aGEOMObject._retn();
765 Handle(GEOM_Object) anObject =
766 GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
767 if (!GetOperations()->IsDone() || anObject.IsNull())
768 return aGEOMObject._retn();
770 return GetObject(anObject);
773 //=============================================================================
775 * ScaleShapeAlongAxes
777 //=============================================================================
778 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxes
779 (GEOM::GEOM_Object_ptr theObject,
780 GEOM::GEOM_Object_ptr thePoint,
781 CORBA::Double theFactorX,
782 CORBA::Double theFactorY,
783 CORBA::Double theFactorZ)
785 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
787 //Set a not done flag
788 GetOperations()->SetNotDone();
790 if (theObject->_is_nil()) return aGEOMObject._retn();
792 //check if the object is a sub-shape
793 if (!theObject->IsMainShape()) {
794 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
795 return aGEOMObject._retn();
798 //Get the object itself
799 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
800 if (anObject.IsNull()) return aGEOMObject._retn();
803 Handle(GEOM_Object) aPoint;
804 if (!thePoint->_is_nil()) {
805 aPoint = GetObjectImpl(thePoint);
806 if (aPoint.IsNull()) return aGEOMObject._retn();
810 GetOperations()->ScaleShapeAlongAxes
811 (anObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/false);
814 UpdateGUIForObject(theObject);
816 return aGEOMObject._retn();
819 //=============================================================================
821 * ScaleShapeAlongAxesCopy
823 //=============================================================================
824 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxesCopy
825 (GEOM::GEOM_Object_ptr theObject,
826 GEOM::GEOM_Object_ptr thePoint,
827 CORBA::Double theFactorX,
828 CORBA::Double theFactorY,
829 CORBA::Double theFactorZ)
831 GEOM::GEOM_Object_var aGEOMObject;
833 //Set a not done flag
834 GetOperations()->SetNotDone();
836 //Get the basic object
837 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
838 if (aBasicObject.IsNull()) return aGEOMObject._retn();
841 Handle(GEOM_Object) aPoint;
842 if (!thePoint->_is_nil()) {
843 aPoint = GetObjectImpl(thePoint);
844 if (aPoint.IsNull()) return aGEOMObject._retn();
848 Handle(GEOM_Object) anObject = GetOperations()->ScaleShapeAlongAxes
849 (aBasicObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/true);
850 if (!GetOperations()->IsDone() || anObject.IsNull())
851 return aGEOMObject._retn();
853 return GetObject(anObject);
856 //=============================================================================
860 //=============================================================================
861 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
862 (GEOM::GEOM_Object_ptr theObject,
863 GEOM::GEOM_Object_ptr theStartLCS,
864 GEOM::GEOM_Object_ptr theEndLCS)
866 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
868 //Set a not done flag
869 GetOperations()->SetNotDone();
871 if (CORBA::is_nil(theObject) || CORBA::is_nil(theEndLCS))
872 return aGEOMObject._retn();
874 //check if the object is a sub-shape
875 if (!theObject->IsMainShape()) {
876 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
877 return aGEOMObject._retn();
880 //Get the basic object
881 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
882 if (anObject.IsNull()) return aGEOMObject._retn();
884 //Get the Start LCS (may be NULL for positioning from global LCS)
885 Handle(GEOM_Object) aStartLCS;
886 if (!CORBA::is_nil(theStartLCS)) {
887 aStartLCS = GetObjectImpl(theStartLCS);
888 if (aStartLCS.IsNull()) return aGEOMObject._retn();
892 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
893 if (aEndLCS.IsNull()) return aGEOMObject._retn();
895 //Perform the Position
896 GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
899 UpdateGUIForObject(theObject);
901 return aGEOMObject._retn();
904 //=============================================================================
908 //=============================================================================
909 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
910 (GEOM::GEOM_Object_ptr theObject,
911 GEOM::GEOM_Object_ptr theStartLCS,
912 GEOM::GEOM_Object_ptr theEndLCS)
914 GEOM::GEOM_Object_var aGEOMObject;
916 //Set a not done flag
917 GetOperations()->SetNotDone();
919 //Get the basic object
920 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
921 if (aBasicObject.IsNull()) return aGEOMObject._retn();
923 //Get the Start LCS (may be NULL for positioning from global LCS)
924 Handle(GEOM_Object) aStartLCS;
925 if (!CORBA::is_nil(theStartLCS)) {
926 aStartLCS = GetObjectImpl(theStartLCS);
927 if (aStartLCS.IsNull()) return aGEOMObject._retn();
931 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
932 if (aEndLCS.IsNull()) return aGEOMObject._retn();
934 //Perform the position
935 Handle(GEOM_Object) anObject =
936 GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
937 if (!GetOperations()->IsDone() || anObject.IsNull())
938 return aGEOMObject._retn();
940 return GetObject(anObject);
943 //=============================================================================
947 //=============================================================================
948 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionAlongPath
949 (GEOM::GEOM_Object_ptr theObject,
950 GEOM::GEOM_Object_ptr thePath,
951 CORBA::Double theDistance,
952 CORBA::Boolean theCopy,
953 CORBA::Boolean theReverse)
955 GEOM::GEOM_Object_var aGEOMObject;
957 //Set a not done flag
958 GetOperations()->SetNotDone();
960 //Get the basic object
961 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
962 if (aBasicObject.IsNull()) return aGEOMObject._retn();
964 //Get the path object
965 Handle(GEOM_Object) aPathObject = GetObjectImpl(thePath);
966 if (aPathObject.IsNull()) return aGEOMObject._retn();
968 //Perform the position
969 Handle(GEOM_Object) anObject =
970 GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy, theReverse);
971 if (!GetOperations()->IsDone() || anObject.IsNull())
972 return aGEOMObject._retn();
976 UpdateGUIForObject(theObject);
979 return GetObject(anObject);
982 //=============================================================================
986 //=============================================================================
987 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
988 (GEOM::GEOM_Object_ptr theObject,
989 GEOM::GEOM_Object_ptr theVector,
990 CORBA::Double theStep, CORBA::Long theNbTimes)
992 //Set a not done flag
993 GetOperations()->SetNotDone();
995 GEOM::GEOM_Object_var aGEOMObject;
997 //Get the object itself
998 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
999 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1001 //Get the vector of translation
1002 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1003 //if (aVector.IsNull()) return aGEOMObject._retn(); // DX by default
1005 //Perform the translation
1006 Handle(GEOM_Object) anObject =
1007 GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
1008 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1010 return GetObject(anObject);
1013 //=============================================================================
1017 //=============================================================================
1018 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
1019 GEOM::GEOM_Object_ptr theVector1,
1020 CORBA::Double theStep1,
1021 CORBA::Long theNbTimes1,
1022 GEOM::GEOM_Object_ptr theVector2,
1023 CORBA::Double theStep2,
1024 CORBA::Long theNbTimes2)
1026 //Set a not done flag
1027 GetOperations()->SetNotDone();
1029 GEOM::GEOM_Object_var aGEOMObject;
1031 //Get the object itself
1032 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1033 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1035 //Get the vector1 of translation
1036 Handle(GEOM_Object) aVector1 = GetObjectImpl(theVector1);
1037 //if (aVector1.IsNull()) return aGEOMObject._retn(); // DX by default
1039 //Get the vector2 of translation
1040 Handle(GEOM_Object) aVector2 = GetObjectImpl(theVector2);
1041 //if (aVector2.IsNull()) return aGEOMObject._retn(); // DY by default
1043 //Perform the translation
1044 Handle(GEOM_Object) anObject = GetOperations()->Translate2D
1045 (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
1046 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1048 return GetObject(anObject);
1051 //=============================================================================
1055 //=============================================================================
1056 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
1057 GEOM::GEOM_Object_ptr theVector,
1058 CORBA::Long theNbTimes)
1060 //Set a not done flag
1061 GetOperations()->SetNotDone();
1063 GEOM::GEOM_Object_var aGEOMObject;
1065 //Get the object itself
1066 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1067 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1069 //Get the a directon of rotation
1070 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1071 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1073 //Perform the rotation
1074 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
1075 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1077 return GetObject(anObject);
1080 //=============================================================================
1082 * MultiRotate1DByStep
1084 //=============================================================================
1085 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1DByStep (GEOM::GEOM_Object_ptr theObject,
1086 GEOM::GEOM_Object_ptr theVector,
1087 CORBA::Double theAngleStep,
1088 CORBA::Long theNbSteps)
1090 //Set a not done flag
1091 GetOperations()->SetNotDone();
1093 GEOM::GEOM_Object_var aGEOMObject;
1095 //Get the object itself
1096 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1097 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1099 //Get the a directon of rotation
1100 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1101 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1103 //Perform the rotation
1104 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theAngleStep, theNbSteps);
1105 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1107 return GetObject(anObject);
1110 //=============================================================================
1112 * MultiRotate2DNbTimes
1114 //=============================================================================
1115 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2DNbTimes (GEOM::GEOM_Object_ptr theObject,
1116 GEOM::GEOM_Object_ptr theVector,
1117 CORBA::Long theNbObjects,
1118 CORBA::Double theRadialStep,
1119 CORBA::Long theNbSteps)
1121 //Set a not done flag
1122 GetOperations()->SetNotDone();
1124 GEOM::GEOM_Object_var aGEOMObject;
1126 //Get the object itself
1127 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1128 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1130 //Get the a directon of rotation
1131 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1132 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1134 //Perform the rotation
1135 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1136 (aBasicObject, aVector, theNbObjects, theRadialStep, theNbSteps);
1137 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1139 return GetObject(anObject);
1142 //=============================================================================
1144 * MultiRotate2DByStep
1146 //=============================================================================
1147 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2DByStep (GEOM::GEOM_Object_ptr theObject,
1148 GEOM::GEOM_Object_ptr theVector,
1149 CORBA::Double theAngle,
1150 CORBA::Long theNbTimes1,
1151 CORBA::Double theStep,
1152 CORBA::Long theNbTimes2)
1154 //Set a not done flag
1155 GetOperations()->SetNotDone();
1157 GEOM::GEOM_Object_var aGEOMObject;
1159 //Get the object itself
1160 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1161 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1163 //Get the a directon of rotation
1164 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1165 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1167 //Perform the rotation
1168 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1169 (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
1170 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1172 return GetObject(anObject);
1175 //=============================================================================
1179 //=============================================================================
1180 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
1181 GEOM::GEOM_Object_ptr theVector,
1182 CORBA::Double theAngle,
1183 CORBA::Long theNbTimes1,
1184 CORBA::Double theStep,
1185 CORBA::Long theNbTimes2)
1187 //Set a not done flag
1188 GetOperations()->SetNotDone();
1190 GEOM::GEOM_Object_var aGEOMObject;
1192 //Get the object itself
1193 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1194 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1196 //Get the a directon of rotation
1197 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1198 //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default
1200 double anAngle = M_PI * theAngle / 180.;
1202 //Perform the rotation
1203 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1204 (aBasicObject, aVector, anAngle, theNbTimes1, theStep, theNbTimes2);
1205 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1207 return GetObject(anObject);
1210 //=============================================================================
1214 //=============================================================================
1215 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
1216 (GEOM::GEOM_Object_ptr theObject,
1217 GEOM::GEOM_Object_ptr theCentPoint,
1218 GEOM::GEOM_Object_ptr thePoint1,
1219 GEOM::GEOM_Object_ptr thePoint2)
1221 //Set a not done flag
1222 GetOperations()->SetNotDone();
1223 GEOM::GEOM_Object_var aGEOMObject;
1225 if (CORBA::is_nil(theObject))
1226 return aGEOMObject._retn();
1228 //check if the object is a sub-shape
1229 if (!theObject->IsMainShape()) {
1230 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
1231 return aGEOMObject._retn();
1234 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1236 //Get the object itself
1237 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1238 if (anObject.IsNull()) return aGEOMObject._retn();
1240 //Get the central point of rotation
1241 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1242 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1244 //Get the first point
1245 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1246 if (aPoint1.IsNull()) return aGEOMObject._retn();
1248 //Get the second point
1249 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1250 if (aPoint2.IsNull()) return aGEOMObject._retn();
1252 //Perform the translation
1253 GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1256 UpdateGUIForObject(theObject);
1258 return aGEOMObject._retn();
1261 //=============================================================================
1263 * RotateThreePointsCopy
1265 //=============================================================================
1266 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1267 (GEOM::GEOM_Object_ptr theObject,
1268 GEOM::GEOM_Object_ptr theCentPoint,
1269 GEOM::GEOM_Object_ptr thePoint1,
1270 GEOM::GEOM_Object_ptr thePoint2)
1272 GEOM::GEOM_Object_var aGEOMObject;
1274 //Set a not done flag
1275 GetOperations()->SetNotDone();
1277 //Get the object itself
1278 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1279 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1281 //Get the central point of rotation
1282 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1283 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1285 //Get the first point
1286 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1287 if (aPoint1.IsNull()) return aGEOMObject._retn();
1289 //Get the second point
1290 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1291 if (aPoint2.IsNull()) return aGEOMObject._retn();
1293 //Perform the rotation
1294 Handle(GEOM_Object) anObject =
1295 GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1296 if (!GetOperations()->IsDone() || anObject.IsNull())
1297 return aGEOMObject._retn();
1299 return GetObject(anObject);
1302 //=============================================================================
1304 * TransformLikeOtherCopy
1306 //=============================================================================
1307 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TransformLikeOtherCopy
1308 (GEOM::GEOM_Object_ptr theObject,
1309 GEOM::GEOM_Object_ptr theSample)
1311 GEOM::GEOM_Object_var aGEOMObject;
1313 //Set a not done flag
1314 GetOperations()->SetNotDone();
1316 //Get the object itself
1317 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1318 if (anObject.IsNull()) return aGEOMObject._retn();
1320 //Get the sample object
1321 Handle(GEOM_Object) aSample = GetObjectImpl(theSample);
1322 if (aSample.IsNull()) return aGEOMObject._retn();
1324 //Perform the transformation
1325 Handle(GEOM_Object) aResObject =
1326 GetOperations()->TransformLikeOtherCopy(anObject, aSample);
1327 if (!GetOperations()->IsDone() || aResObject.IsNull())
1328 return aGEOMObject._retn();
1330 return GetObject(aResObject);
1333 //=============================================================================
1337 //=============================================================================
1338 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RecomputeObject
1339 (GEOM::GEOM_Object_ptr theObject)
1341 //Set a not done flag
1342 GetOperations()->SetNotDone();
1343 GEOM::GEOM_Object_var aGEOMObject;
1345 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
1347 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1349 //Get the object itself
1350 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1351 if (anObject.IsNull()) return aGEOMObject._retn();
1353 //Perform the recomputation
1354 Handle(GEOM_Function) aLastFunction = anObject->GetLastFunction();
1355 if (aLastFunction.IsNull()) return aGEOMObject._retn();
1356 GetOperations()->GetSolver()->ComputeFunction(aLastFunction);
1358 return aGEOMObject._retn();