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
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);
104 return aGEOMObject._retn();
107 //=============================================================================
109 * TranslateTwoPointsCopy
111 //=============================================================================
112 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy
113 (GEOM::GEOM_Object_ptr theObject,
114 GEOM::GEOM_Object_ptr thePoint1,
115 GEOM::GEOM_Object_ptr thePoint2)
117 GEOM::GEOM_Object_var aGEOMObject;
119 //Set a not done flag
120 GetOperations()->SetNotDone();
122 //Get the object itself
123 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
124 if (aBasicObject.IsNull()) return aGEOMObject._retn();
126 //Get the first point of translation
127 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
128 if (aPoint1.IsNull()) return aGEOMObject._retn();
130 //Get the second point of translation
131 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
132 if (aPoint2.IsNull()) return aGEOMObject._retn();
134 //Create the translated shape
135 Handle(GEOM_Object) anObject =
136 GetOperations()->TranslateTwoPointsCopy(aBasicObject, aPoint1, aPoint2);
137 if (!GetOperations()->IsDone() || anObject.IsNull())
138 return aGEOMObject._retn();
140 return GetObject(anObject);
143 //=============================================================================
147 //=============================================================================
148 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ
149 (GEOM::GEOM_Object_ptr theObject,
150 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
152 //Set a not done flag
153 GetOperations()->SetNotDone();
154 GEOM::GEOM_Object_var aGEOMObject;
156 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
158 //check if the object is a sub-shape
159 if (!theObject->IsMainShape()) {
160 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
161 return aGEOMObject._retn();
164 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
166 //Get the object itself
167 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
168 if (anObject.IsNull()) return aGEOMObject._retn();
170 //Perform the translation
171 GetOperations()->TranslateDXDYDZ(anObject, theDX, theDY, theDZ);
173 return aGEOMObject._retn();
176 //=============================================================================
178 * TranslateDXDYDZCopy
180 //=============================================================================
181 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy
182 (GEOM::GEOM_Object_ptr theObject,
183 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
185 GEOM::GEOM_Object_var aGEOMObject;
187 //Set a not done flag
188 GetOperations()->SetNotDone();
190 //Get the object itself
191 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
192 if (aBasicObject.IsNull()) return aGEOMObject._retn();
194 //Create the translated shape
195 Handle(GEOM_Object) anObject =
196 GetOperations()->TranslateDXDYDZCopy(aBasicObject, theDX, theDY, theDZ);
197 if (!GetOperations()->IsDone() || anObject.IsNull())
198 return aGEOMObject._retn();
200 return GetObject(anObject);
203 //=============================================================================
207 //=============================================================================
208 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector
209 (GEOM::GEOM_Object_ptr theObject,
210 GEOM::GEOM_Object_ptr theVector)
212 //Set a not done flag
213 GetOperations()->SetNotDone();
214 GEOM::GEOM_Object_var aGEOMObject;
216 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
218 //check if the object is a sub-shape
219 if (!theObject->IsMainShape()) {
220 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
221 return aGEOMObject._retn();
224 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
226 //Get the object itself
227 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
228 if (anObject.IsNull()) return aGEOMObject._retn();
230 //Get the vector of translation
231 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
232 if (aVector.IsNull()) return aGEOMObject._retn();
234 //Perform the translation
235 GetOperations()->TranslateVector(anObject, aVector);
237 return aGEOMObject._retn();
240 //=============================================================================
242 * TranslateVectorCopy
244 //=============================================================================
245 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy
246 (GEOM::GEOM_Object_ptr theObject,
247 GEOM::GEOM_Object_ptr theVector)
249 GEOM::GEOM_Object_var aGEOMObject;
251 //Set a not done flag
252 GetOperations()->SetNotDone();
254 //Get the object itself
255 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
256 if (aBasicObject.IsNull()) return aGEOMObject._retn();
258 //Get the vector of translation
259 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
260 if (aVector.IsNull()) return aGEOMObject._retn();
262 //Perform the translation
263 Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector);
264 if (!GetOperations()->IsDone() || anObject.IsNull())
265 return aGEOMObject._retn();
267 return GetObject(anObject);
270 //=============================================================================
272 * TranslateVectorDistance
274 //=============================================================================
275 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorDistance
276 (GEOM::GEOM_Object_ptr theObject,
277 GEOM::GEOM_Object_ptr theVector,
278 CORBA::Double theDistance,
279 CORBA::Boolean theCopy)
281 GEOM::GEOM_Object_var aGEOMObject;
282 GetOperations()->SetNotDone(); //Set a not done flag
284 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
286 //check if the object is a sub-shape
287 if (!theCopy && !theObject->IsMainShape()) {
288 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
289 return aGEOMObject._retn();
293 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
295 //Get the object itself
296 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
297 if (aBasicObject.IsNull()) return aGEOMObject._retn();
299 //Get the vector of translation
300 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
301 if (aVector.IsNull()) return aGEOMObject._retn();
303 //Perform the translation
305 Handle(GEOM_Object) anObject = GetOperations()->
306 TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
307 if (!GetOperations()->IsDone() || anObject.IsNull())
308 return aGEOMObject._retn();
310 return GetObject(anObject);
313 GetOperations()->TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
314 return aGEOMObject._retn();
317 //=============================================================================
321 //=============================================================================
322 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject,
323 GEOM::GEOM_Object_ptr theAxis,
324 CORBA::Double theAngle)
326 //Set a not done flag
327 GetOperations()->SetNotDone();
328 GEOM::GEOM_Object_var aGEOMObject;
330 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
332 //check if the object is a sub-shape
333 if (!theObject->IsMainShape()) {
334 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
335 return aGEOMObject._retn();
338 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
340 //Get the object itself
341 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
342 if (anObject.IsNull()) return aGEOMObject._retn();
344 //Get the axis of revolution
345 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
346 if (anAxis.IsNull()) return aGEOMObject._retn();
348 //Perform the rotation
349 GetOperations()->Rotate(anObject, anAxis, theAngle);
351 return aGEOMObject._retn();
354 //=============================================================================
358 //=============================================================================
359 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject,
360 GEOM::GEOM_Object_ptr theAxis,
361 CORBA::Double theAngle)
363 GEOM::GEOM_Object_var aGEOMObject;
365 //Set a not done flag
366 GetOperations()->SetNotDone();
368 //Get the object itself
369 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
370 if (aBasicObject.IsNull()) return aGEOMObject._retn();
372 //Get the axis of rotation
373 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
374 if (anAxis.IsNull()) return aGEOMObject._retn();
376 //Perform the rotation
377 Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle);
378 if (!GetOperations()->IsDone() || anObject.IsNull())
379 return aGEOMObject._retn();
381 return GetObject(anObject);
384 //=============================================================================
388 //=============================================================================
389 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
390 (GEOM::GEOM_Object_ptr theObject,
391 GEOM::GEOM_Object_ptr thePlane)
393 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
395 //Set a not done flag
396 GetOperations()->SetNotDone();
398 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
400 //check if the object is a sub-shape
401 if (!theObject->IsMainShape()) {
402 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
403 return aGEOMObject._retn();
406 //Get the object itself
407 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
408 if (anObject.IsNull()) return aGEOMObject._retn();
411 Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
412 if (aPlane.IsNull()) return aGEOMObject._retn();
415 GetOperations()->MirrorPlane(anObject, aPlane);
417 return aGEOMObject._retn();
420 //=============================================================================
424 //=============================================================================
425 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy
426 (GEOM::GEOM_Object_ptr theObject,
427 GEOM::GEOM_Object_ptr thePlane)
429 GEOM::GEOM_Object_var aGEOMObject;
431 //Set a not done flag
432 GetOperations()->SetNotDone();
434 //Get the object itself
435 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
436 if (aBasicObject.IsNull()) return aGEOMObject._retn();
438 //Get the vector of translation
439 Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
440 if (aPlane.IsNull()) return aGEOMObject._retn();
443 Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane);
444 if (!GetOperations()->IsDone() || anObject.IsNull())
445 return aGEOMObject._retn();
447 return GetObject(anObject);
450 //=============================================================================
454 //=============================================================================
455 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis
456 (GEOM::GEOM_Object_ptr theObject,
457 GEOM::GEOM_Object_ptr theAxis)
459 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
461 //Set a not done flag
462 GetOperations()->SetNotDone();
464 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
466 //check if the object is a sub-shape
467 if (!theObject->IsMainShape()) {
468 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
469 return aGEOMObject._retn();
472 //Get the object itself
473 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
474 if (anObject.IsNull()) return aGEOMObject._retn();
477 Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
478 if (aAxis.IsNull()) return aGEOMObject._retn();
481 GetOperations()->MirrorAxis(anObject, aAxis);
483 return aGEOMObject._retn();
486 //=============================================================================
490 //=============================================================================
491 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy
492 (GEOM::GEOM_Object_ptr theObject,
493 GEOM::GEOM_Object_ptr theAxis)
495 GEOM::GEOM_Object_var aGEOMObject;
497 //Set a not done flag
498 GetOperations()->SetNotDone();
500 //Get the object itself
501 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
502 if (aBasicObject.IsNull()) return aGEOMObject._retn();
504 //Get the vector of translation
505 Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
506 if (aAxis.IsNull()) return aGEOMObject._retn();
509 Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis);
510 if (!GetOperations()->IsDone() || anObject.IsNull())
511 return aGEOMObject._retn();
513 return GetObject(anObject);
516 //=============================================================================
520 //=============================================================================
521 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint
522 (GEOM::GEOM_Object_ptr theObject,
523 GEOM::GEOM_Object_ptr thePoint)
525 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
527 //Set a not done flag
528 GetOperations()->SetNotDone();
530 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
532 //check if the object is a sub-shape
533 if (!theObject->IsMainShape()) {
534 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
535 return aGEOMObject._retn();
538 //Get the object itself
539 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
540 if (anObject.IsNull()) return aGEOMObject._retn();
543 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
544 if (aPoint.IsNull()) return aGEOMObject._retn();
547 GetOperations()->MirrorPoint(anObject, aPoint);
549 return aGEOMObject._retn();
552 //=============================================================================
556 //=============================================================================
557 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy
558 (GEOM::GEOM_Object_ptr theObject,
559 GEOM::GEOM_Object_ptr thePoint)
561 GEOM::GEOM_Object_var aGEOMObject;
563 //Set a not done flag
564 GetOperations()->SetNotDone();
566 //Get the object itself
567 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
568 if (aBasicObject.IsNull()) return aGEOMObject._retn();
570 //Get the vector of translation
571 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
572 if (aPoint.IsNull()) return aGEOMObject._retn();
575 Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint);
576 if (!GetOperations()->IsDone() || anObject.IsNull())
577 return aGEOMObject._retn();
579 return GetObject(anObject);
582 //=============================================================================
586 //=============================================================================
587 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
588 (GEOM::GEOM_Object_ptr theObject,
589 CORBA::Double theOffset)
591 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
593 //Set a not done flag
594 GetOperations()->SetNotDone();
596 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
598 //check if the object is a sub-shape
599 if (!theObject->IsMainShape()) {
600 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
601 return aGEOMObject._retn();
604 //Get the basic object
605 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
606 if (aBasicObject.IsNull()) return aGEOMObject._retn();
608 //Create the offset shape
609 GetOperations()->OffsetShape(aBasicObject, theOffset);
611 return aGEOMObject._retn();
614 //=============================================================================
618 //=============================================================================
619 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
620 (GEOM::GEOM_Object_ptr theObject,
621 CORBA::Double theOffset)
623 GEOM::GEOM_Object_var aGEOMObject;
625 //Set a not done flag
626 GetOperations()->SetNotDone();
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 Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset);
634 if (!GetOperations()->IsDone() || anObject.IsNull())
635 return aGEOMObject._retn();
637 return GetObject(anObject);
640 //=============================================================================
644 //=============================================================================
645 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ProjectShapeCopy
646 (GEOM::GEOM_Object_ptr theSource,
647 GEOM::GEOM_Object_ptr theTarget)
649 GEOM::GEOM_Object_var aGEOMObject;
651 //Set a not done flag
652 GetOperations()->SetNotDone();
654 //Get the input objects
655 Handle(GEOM_Object) aSource = GetObjectImpl(theSource);
656 Handle(GEOM_Object) aTarget = GetObjectImpl(theTarget);
657 if (aSource.IsNull() || aTarget.IsNull()) return aGEOMObject._retn();
659 //Create the projection
660 Handle(GEOM_Object) anObject = GetOperations()->ProjectShapeCopy(aSource, aTarget);
661 if (!GetOperations()->IsDone() || anObject.IsNull())
662 return aGEOMObject._retn();
664 return GetObject(anObject);
667 //=============================================================================
671 //=============================================================================
672 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
673 (GEOM::GEOM_Object_ptr theObject,
674 GEOM::GEOM_Object_ptr thePoint,
675 CORBA::Double theFactor)
677 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
679 //Set a not done flag
680 GetOperations()->SetNotDone();
682 if (theObject->_is_nil()) return aGEOMObject._retn();
684 //check if the object is a sub-shape
685 if (!theObject->IsMainShape()) {
686 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
687 return aGEOMObject._retn();
690 //Get the object itself
691 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
692 if (anObject.IsNull()) return aGEOMObject._retn();
695 Handle(GEOM_Object) aPoint;
696 if (!thePoint->_is_nil()) {
697 aPoint = GetObjectImpl(thePoint);
698 if (aPoint.IsNull()) return aGEOMObject._retn();
702 GetOperations()->ScaleShape(anObject, aPoint, theFactor);
704 return aGEOMObject._retn();
707 //=============================================================================
711 //=============================================================================
712 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
713 (GEOM::GEOM_Object_ptr theObject,
714 GEOM::GEOM_Object_ptr thePoint,
715 CORBA::Double theFactor)
717 GEOM::GEOM_Object_var aGEOMObject;
719 //Set a not done flag
720 GetOperations()->SetNotDone();
722 //Get the basic object
723 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
724 if (aBasicObject.IsNull()) return aGEOMObject._retn();
727 Handle(GEOM_Object) aPoint;
728 if (!thePoint->_is_nil()) {
729 aPoint = GetObjectImpl(thePoint);
730 if (aPoint.IsNull()) return aGEOMObject._retn();
734 Handle(GEOM_Object) anObject =
735 GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
736 if (!GetOperations()->IsDone() || anObject.IsNull())
737 return aGEOMObject._retn();
739 return GetObject(anObject);
742 //=============================================================================
744 * ScaleShapeAlongAxes
746 //=============================================================================
747 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxes
748 (GEOM::GEOM_Object_ptr theObject,
749 GEOM::GEOM_Object_ptr thePoint,
750 CORBA::Double theFactorX,
751 CORBA::Double theFactorY,
752 CORBA::Double theFactorZ)
754 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
756 //Set a not done flag
757 GetOperations()->SetNotDone();
759 if (theObject->_is_nil()) return aGEOMObject._retn();
761 //check if the object is a sub-shape
762 if (!theObject->IsMainShape()) {
763 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
764 return aGEOMObject._retn();
767 //Get the object itself
768 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
769 if (anObject.IsNull()) return aGEOMObject._retn();
772 Handle(GEOM_Object) aPoint;
773 if (!thePoint->_is_nil()) {
774 aPoint = GetObjectImpl(thePoint);
775 if (aPoint.IsNull()) return aGEOMObject._retn();
779 GetOperations()->ScaleShapeAlongAxes
780 (anObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/false);
782 return aGEOMObject._retn();
785 //=============================================================================
787 * ScaleShapeAlongAxesCopy
789 //=============================================================================
790 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxesCopy
791 (GEOM::GEOM_Object_ptr theObject,
792 GEOM::GEOM_Object_ptr thePoint,
793 CORBA::Double theFactorX,
794 CORBA::Double theFactorY,
795 CORBA::Double theFactorZ)
797 GEOM::GEOM_Object_var aGEOMObject;
799 //Set a not done flag
800 GetOperations()->SetNotDone();
802 //Get the basic object
803 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
804 if (aBasicObject.IsNull()) return aGEOMObject._retn();
807 Handle(GEOM_Object) aPoint;
808 if (!thePoint->_is_nil()) {
809 aPoint = GetObjectImpl(thePoint);
810 if (aPoint.IsNull()) return aGEOMObject._retn();
814 Handle(GEOM_Object) anObject = GetOperations()->ScaleShapeAlongAxes
815 (aBasicObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/true);
816 if (!GetOperations()->IsDone() || anObject.IsNull())
817 return aGEOMObject._retn();
819 return GetObject(anObject);
822 //=============================================================================
826 //=============================================================================
827 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
828 (GEOM::GEOM_Object_ptr theObject,
829 GEOM::GEOM_Object_ptr theStartLCS,
830 GEOM::GEOM_Object_ptr theEndLCS)
832 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
834 //Set a not done flag
835 GetOperations()->SetNotDone();
837 if (CORBA::is_nil(theObject) || CORBA::is_nil(theEndLCS))
838 return aGEOMObject._retn();
840 //check if the object is a sub-shape
841 if (!theObject->IsMainShape()) {
842 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
843 return aGEOMObject._retn();
846 //Get the basic object
847 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
848 if (anObject.IsNull()) return aGEOMObject._retn();
850 //Get the Start LCS (may be NULL for positioning from global LCS)
851 Handle(GEOM_Object) aStartLCS;
852 if (!CORBA::is_nil(theStartLCS)) {
853 aStartLCS = GetObjectImpl(theStartLCS);
854 if (aStartLCS.IsNull()) return aGEOMObject._retn();
858 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
859 if (aEndLCS.IsNull()) return aGEOMObject._retn();
861 //Perform the Position
862 GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
864 return aGEOMObject._retn();
867 //=============================================================================
871 //=============================================================================
872 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
873 (GEOM::GEOM_Object_ptr theObject,
874 GEOM::GEOM_Object_ptr theStartLCS,
875 GEOM::GEOM_Object_ptr theEndLCS)
877 GEOM::GEOM_Object_var aGEOMObject;
879 //Set a not done flag
880 GetOperations()->SetNotDone();
882 //Get the basic object
883 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
884 if (aBasicObject.IsNull()) return aGEOMObject._retn();
886 //Get the Start LCS (may be NULL for positioning from global LCS)
887 Handle(GEOM_Object) aStartLCS;
888 if (!CORBA::is_nil(theStartLCS)) {
889 aStartLCS = GetObjectImpl(theStartLCS);
890 if (aStartLCS.IsNull()) return aGEOMObject._retn();
894 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
895 if (aEndLCS.IsNull()) return aGEOMObject._retn();
897 //Perform the position
898 Handle(GEOM_Object) anObject =
899 GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
900 if (!GetOperations()->IsDone() || anObject.IsNull())
901 return aGEOMObject._retn();
903 return GetObject(anObject);
906 //=============================================================================
910 //=============================================================================
911 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionAlongPath
912 (GEOM::GEOM_Object_ptr theObject,
913 GEOM::GEOM_Object_ptr thePath,
914 CORBA::Double theDistance,
915 CORBA::Boolean theCopy,
916 CORBA::Boolean theReverse)
918 GEOM::GEOM_Object_var aGEOMObject;
920 //Set a not done flag
921 GetOperations()->SetNotDone();
923 //Get the basic object
924 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
925 if (aBasicObject.IsNull()) return aGEOMObject._retn();
927 //Get the path object
928 Handle(GEOM_Object) aPathObject = GetObjectImpl(thePath);
929 if (aPathObject.IsNull()) return aGEOMObject._retn();
931 //Perform the position
932 Handle(GEOM_Object) anObject =
933 GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy, theReverse);
934 if (!GetOperations()->IsDone() || anObject.IsNull())
935 return aGEOMObject._retn();
937 return GetObject(anObject);
940 //=============================================================================
944 //=============================================================================
945 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
946 (GEOM::GEOM_Object_ptr theObject,
947 GEOM::GEOM_Object_ptr theVector,
948 CORBA::Double theStep, CORBA::Long theNbTimes)
950 //Set a not done flag
951 GetOperations()->SetNotDone();
953 GEOM::GEOM_Object_var aGEOMObject;
955 //Get the object itself
956 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
957 if (aBasicObject.IsNull()) return aGEOMObject._retn();
959 //Get the vector of translation
960 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
961 if (aVector.IsNull()) return aGEOMObject._retn();
963 //Perform the translation
964 Handle(GEOM_Object) anObject =
965 GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
966 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
968 return GetObject(anObject);
971 //=============================================================================
975 //=============================================================================
976 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
977 GEOM::GEOM_Object_ptr theVector1,
978 CORBA::Double theStep1,
979 CORBA::Long theNbTimes1,
980 GEOM::GEOM_Object_ptr theVector2,
981 CORBA::Double theStep2,
982 CORBA::Long theNbTimes2)
984 //Set a not done flag
985 GetOperations()->SetNotDone();
987 GEOM::GEOM_Object_var aGEOMObject;
989 //Get the object itself
990 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
991 if (aBasicObject.IsNull()) return aGEOMObject._retn();
993 //Get the vector1 of translation
994 Handle(GEOM_Object) aVector1 = GetObjectImpl(theVector1);
995 if (aVector1.IsNull()) return aGEOMObject._retn();
997 //Get the vector2 of translation
998 Handle(GEOM_Object) aVector2 = GetObjectImpl(theVector2);
999 if (aVector2.IsNull()) return aGEOMObject._retn();
1001 //Perform the translation
1002 Handle(GEOM_Object) anObject = GetOperations()->Translate2D
1003 (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
1004 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1006 return GetObject(anObject);
1009 //=============================================================================
1013 //=============================================================================
1014 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
1015 GEOM::GEOM_Object_ptr theVector,
1016 CORBA::Long theNbTimes)
1018 //Set a not done flag
1019 GetOperations()->SetNotDone();
1021 GEOM::GEOM_Object_var aGEOMObject;
1023 //Get the object itself
1024 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1025 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1027 //Get the a directon of rotation
1028 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1029 if (aVector.IsNull()) return aGEOMObject._retn();
1031 //Perform the rotation
1032 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
1033 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1035 return GetObject(anObject);
1038 //=============================================================================
1042 //=============================================================================
1043 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
1044 GEOM::GEOM_Object_ptr theVector,
1045 CORBA::Double theAngle,
1046 CORBA::Long theNbTimes1,
1047 CORBA::Double theStep,
1048 CORBA::Long theNbTimes2)
1050 //Set a not done flag
1051 GetOperations()->SetNotDone();
1053 GEOM::GEOM_Object_var aGEOMObject;
1055 //Get the object itself
1056 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1057 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1059 //Get the a directon of rotation
1060 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1061 if (aVector.IsNull()) return aGEOMObject._retn();
1063 //Perform the rotation
1064 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1065 (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
1066 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1068 return GetObject(anObject);
1071 //=============================================================================
1075 //=============================================================================
1076 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
1077 (GEOM::GEOM_Object_ptr theObject,
1078 GEOM::GEOM_Object_ptr theCentPoint,
1079 GEOM::GEOM_Object_ptr thePoint1,
1080 GEOM::GEOM_Object_ptr thePoint2)
1082 //Set a not done flag
1083 GetOperations()->SetNotDone();
1084 GEOM::GEOM_Object_var aGEOMObject;
1086 if (CORBA::is_nil(theObject))
1087 return aGEOMObject._retn();
1089 //check if the object is a sub-shape
1090 if (!theObject->IsMainShape()) {
1091 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
1092 return aGEOMObject._retn();
1095 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1097 //Get the object itself
1098 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1099 if (anObject.IsNull()) return aGEOMObject._retn();
1101 //Get the central point of rotation
1102 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1103 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1105 //Get the first point
1106 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1107 if (aPoint1.IsNull()) return aGEOMObject._retn();
1109 //Get the second point
1110 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1111 if (aPoint2.IsNull()) return aGEOMObject._retn();
1113 //Perform the translation
1114 GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1116 return aGEOMObject._retn();
1119 //=============================================================================
1121 * RotateThreePointsCopy
1123 //=============================================================================
1124 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1125 (GEOM::GEOM_Object_ptr theObject,
1126 GEOM::GEOM_Object_ptr theCentPoint,
1127 GEOM::GEOM_Object_ptr thePoint1,
1128 GEOM::GEOM_Object_ptr thePoint2)
1130 GEOM::GEOM_Object_var aGEOMObject;
1132 //Set a not done flag
1133 GetOperations()->SetNotDone();
1135 //Get the object itself
1136 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1137 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1139 //Get the central point of rotation
1140 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1141 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1143 //Get the first point
1144 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1145 if (aPoint1.IsNull()) return aGEOMObject._retn();
1147 //Get the second point
1148 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1149 if (aPoint2.IsNull()) return aGEOMObject._retn();
1151 //Perform the rotation
1152 Handle(GEOM_Object) anObject =
1153 GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1154 if (!GetOperations()->IsDone() || anObject.IsNull())
1155 return aGEOMObject._retn();
1157 return GetObject(anObject);
1160 //=============================================================================
1162 * TransformLikeOtherCopy
1164 //=============================================================================
1165 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TransformLikeOtherCopy
1166 (GEOM::GEOM_Object_ptr theObject,
1167 GEOM::GEOM_Object_ptr theSample)
1169 GEOM::GEOM_Object_var aGEOMObject;
1171 //Set a not done flag
1172 GetOperations()->SetNotDone();
1174 //Get the object itself
1175 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1176 if (anObject.IsNull()) return aGEOMObject._retn();
1178 //Get the sample object
1179 Handle(GEOM_Object) aSample = GetObjectImpl(theSample);
1180 if (aSample.IsNull()) return aGEOMObject._retn();
1182 //Perform the transformation
1183 Handle(GEOM_Object) aResObject =
1184 GetOperations()->TransformLikeOtherCopy(anObject, aSample);
1185 if (!GetOperations()->IsDone() || aResObject.IsNull())
1186 return aGEOMObject._retn();
1188 return GetObject(aResObject);
1191 //=============================================================================
1195 //=============================================================================
1196 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RecomputeObject
1197 (GEOM::GEOM_Object_ptr theObject)
1199 //Set a not done flag
1200 GetOperations()->SetNotDone();
1201 GEOM::GEOM_Object_var aGEOMObject;
1203 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
1205 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1207 //Get the object itself
1208 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1209 if (anObject.IsNull()) return aGEOMObject._retn();
1211 //Perform the recomputation
1212 Handle(GEOM_Function) aLastFunction = anObject->GetLastFunction();
1213 if (aLastFunction.IsNull()) return aGEOMObject._retn();
1214 GetOperations()->GetSolver()->ComputeFunction(aLastFunction);
1216 return aGEOMObject._retn();