1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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 subshape
81 if (!theObject->IsMainShape()) {
82 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
83 return aGEOMObject._retn();
86 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
88 //Get the object itself
89 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
90 if (anObject.IsNull()) return aGEOMObject._retn();
92 //Get the first point of translation
93 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
94 if (aPoint1.IsNull()) return aGEOMObject._retn();
96 //Get the second point of translation
97 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
98 if (aPoint2.IsNull()) return aGEOMObject._retn();
100 //Perform the translation
101 GetOperations()->TranslateTwoPoints(anObject, aPoint1, aPoint2);
103 return aGEOMObject._retn();
106 //=============================================================================
108 * TranslateTwoPointsCopy
110 //=============================================================================
111 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy
112 (GEOM::GEOM_Object_ptr theObject,
113 GEOM::GEOM_Object_ptr thePoint1,
114 GEOM::GEOM_Object_ptr thePoint2)
116 GEOM::GEOM_Object_var aGEOMObject;
118 //Set a not done flag
119 GetOperations()->SetNotDone();
121 //Get the object itself
122 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
123 if (aBasicObject.IsNull()) return aGEOMObject._retn();
125 //Get the first point of translation
126 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
127 if (aPoint1.IsNull()) return aGEOMObject._retn();
129 //Get the second point of translation
130 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
131 if (aPoint2.IsNull()) return aGEOMObject._retn();
133 //Create the translated shape
134 Handle(GEOM_Object) anObject =
135 GetOperations()->TranslateTwoPointsCopy(aBasicObject, aPoint1, aPoint2);
136 if (!GetOperations()->IsDone() || anObject.IsNull())
137 return aGEOMObject._retn();
139 return GetObject(anObject);
142 //=============================================================================
146 //=============================================================================
147 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ
148 (GEOM::GEOM_Object_ptr theObject,
149 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
151 //Set a not done flag
152 GetOperations()->SetNotDone();
153 GEOM::GEOM_Object_var aGEOMObject;
155 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
157 //check if the object is a subshape
158 if (!theObject->IsMainShape()) {
159 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
160 return aGEOMObject._retn();
163 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
165 //Get the object itself
166 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
167 if (anObject.IsNull()) return aGEOMObject._retn();
169 //Perform the translation
170 GetOperations()->TranslateDXDYDZ(anObject, theDX, theDY, theDZ);
172 return aGEOMObject._retn();
175 //=============================================================================
177 * TranslateDXDYDZCopy
179 //=============================================================================
180 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy
181 (GEOM::GEOM_Object_ptr theObject,
182 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
184 GEOM::GEOM_Object_var aGEOMObject;
186 //Set a not done flag
187 GetOperations()->SetNotDone();
189 //Get the object itself
190 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
191 if (aBasicObject.IsNull()) return aGEOMObject._retn();
193 //Create the translated shape
194 Handle(GEOM_Object) anObject =
195 GetOperations()->TranslateDXDYDZCopy(aBasicObject, theDX, theDY, theDZ);
196 if (!GetOperations()->IsDone() || anObject.IsNull())
197 return aGEOMObject._retn();
199 return GetObject(anObject);
202 //=============================================================================
206 //=============================================================================
207 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector
208 (GEOM::GEOM_Object_ptr theObject,
209 GEOM::GEOM_Object_ptr theVector)
211 //Set a not done flag
212 GetOperations()->SetNotDone();
213 GEOM::GEOM_Object_var aGEOMObject;
215 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
217 //check if the object is a subshape
218 if (!theObject->IsMainShape()) {
219 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
220 return aGEOMObject._retn();
223 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
225 //Get the object itself
226 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
227 if (anObject.IsNull()) return aGEOMObject._retn();
229 //Get the vector of translation
230 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
231 if (aVector.IsNull()) return aGEOMObject._retn();
233 //Perform the translation
234 GetOperations()->TranslateVector(anObject, aVector);
236 return aGEOMObject._retn();
239 //=============================================================================
241 * TranslateVectorCopy
243 //=============================================================================
244 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy
245 (GEOM::GEOM_Object_ptr theObject,
246 GEOM::GEOM_Object_ptr theVector)
248 GEOM::GEOM_Object_var aGEOMObject;
250 //Set a not done flag
251 GetOperations()->SetNotDone();
253 //Get the object itself
254 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
255 if (aBasicObject.IsNull()) return aGEOMObject._retn();
257 //Get the vector of translation
258 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
259 if (aVector.IsNull()) return aGEOMObject._retn();
261 //Perform the translation
262 Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector);
263 if (!GetOperations()->IsDone() || anObject.IsNull())
264 return aGEOMObject._retn();
266 return GetObject(anObject);
269 //=============================================================================
271 * TranslateVectorDistance
273 //=============================================================================
274 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorDistance
275 (GEOM::GEOM_Object_ptr theObject,
276 GEOM::GEOM_Object_ptr theVector,
277 CORBA::Double theDistance,
278 CORBA::Boolean theCopy)
280 GEOM::GEOM_Object_var aGEOMObject;
281 GetOperations()->SetNotDone(); //Set a not done flag
283 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
285 //check if the object is a subshape
286 if (!theCopy && !theObject->IsMainShape()) {
287 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
288 return aGEOMObject._retn();
292 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
294 //Get the object itself
295 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
296 if (aBasicObject.IsNull()) return aGEOMObject._retn();
298 //Get the vector of translation
299 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
300 if (aVector.IsNull()) return aGEOMObject._retn();
302 //Perform the translation
304 Handle(GEOM_Object) anObject = GetOperations()->
305 TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
306 if (!GetOperations()->IsDone() || anObject.IsNull())
307 return aGEOMObject._retn();
309 return GetObject(anObject);
312 GetOperations()->TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
313 return aGEOMObject._retn();
316 //=============================================================================
320 //=============================================================================
321 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject,
322 GEOM::GEOM_Object_ptr theAxis,
323 CORBA::Double theAngle)
325 //Set a not done flag
326 GetOperations()->SetNotDone();
327 GEOM::GEOM_Object_var aGEOMObject;
329 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
331 //check if the object is a subshape
332 if (!theObject->IsMainShape()) {
333 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
334 return aGEOMObject._retn();
337 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
339 //Get the object itself
340 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
341 if (anObject.IsNull()) return aGEOMObject._retn();
343 //Get the axis of revolution
344 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
345 if (anAxis.IsNull()) return aGEOMObject._retn();
347 //Perform the rotation
348 GetOperations()->Rotate(anObject, anAxis, theAngle);
350 return aGEOMObject._retn();
353 //=============================================================================
357 //=============================================================================
358 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject,
359 GEOM::GEOM_Object_ptr theAxis,
360 CORBA::Double theAngle)
362 GEOM::GEOM_Object_var aGEOMObject;
364 //Set a not done flag
365 GetOperations()->SetNotDone();
367 //Get the object itself
368 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
369 if (aBasicObject.IsNull()) return aGEOMObject._retn();
371 //Get the axis of rotation
372 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
373 if (anAxis.IsNull()) return aGEOMObject._retn();
375 //Perform the rotation
376 Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle);
377 if (!GetOperations()->IsDone() || anObject.IsNull())
378 return aGEOMObject._retn();
380 return GetObject(anObject);
383 //=============================================================================
387 //=============================================================================
388 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
389 (GEOM::GEOM_Object_ptr theObject,
390 GEOM::GEOM_Object_ptr thePlane)
392 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
394 //Set a not done flag
395 GetOperations()->SetNotDone();
397 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
399 //check if the object is a subshape
400 if (!theObject->IsMainShape()) {
401 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
402 return aGEOMObject._retn();
405 //Get the object itself
406 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
407 if (anObject.IsNull()) return aGEOMObject._retn();
410 Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
411 if (aPlane.IsNull()) return aGEOMObject._retn();
414 GetOperations()->MirrorPlane(anObject, aPlane);
416 return aGEOMObject._retn();
419 //=============================================================================
423 //=============================================================================
424 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy
425 (GEOM::GEOM_Object_ptr theObject,
426 GEOM::GEOM_Object_ptr thePlane)
428 GEOM::GEOM_Object_var aGEOMObject;
430 //Set a not done flag
431 GetOperations()->SetNotDone();
433 //Get the object itself
434 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
435 if (aBasicObject.IsNull()) return aGEOMObject._retn();
437 //Get the vector of translation
438 Handle(GEOM_Object) aPlane = GetObjectImpl(thePlane);
439 if (aPlane.IsNull()) return aGEOMObject._retn();
442 Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane);
443 if (!GetOperations()->IsDone() || anObject.IsNull())
444 return aGEOMObject._retn();
446 return GetObject(anObject);
449 //=============================================================================
453 //=============================================================================
454 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis
455 (GEOM::GEOM_Object_ptr theObject,
456 GEOM::GEOM_Object_ptr theAxis)
458 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
460 //Set a not done flag
461 GetOperations()->SetNotDone();
463 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
465 //check if the object is a subshape
466 if (!theObject->IsMainShape()) {
467 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
468 return aGEOMObject._retn();
471 //Get the object itself
472 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
473 if (anObject.IsNull()) return aGEOMObject._retn();
476 Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
477 if (aAxis.IsNull()) return aGEOMObject._retn();
480 GetOperations()->MirrorAxis(anObject, aAxis);
482 return aGEOMObject._retn();
485 //=============================================================================
489 //=============================================================================
490 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy
491 (GEOM::GEOM_Object_ptr theObject,
492 GEOM::GEOM_Object_ptr theAxis)
494 GEOM::GEOM_Object_var aGEOMObject;
496 //Set a not done flag
497 GetOperations()->SetNotDone();
499 //Get the object itself
500 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
501 if (aBasicObject.IsNull()) return aGEOMObject._retn();
503 //Get the vector of translation
504 Handle(GEOM_Object) aAxis = GetObjectImpl(theAxis);
505 if (aAxis.IsNull()) return aGEOMObject._retn();
508 Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis);
509 if (!GetOperations()->IsDone() || anObject.IsNull())
510 return aGEOMObject._retn();
512 return GetObject(anObject);
515 //=============================================================================
519 //=============================================================================
520 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint
521 (GEOM::GEOM_Object_ptr theObject,
522 GEOM::GEOM_Object_ptr thePoint)
524 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
526 //Set a not done flag
527 GetOperations()->SetNotDone();
529 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
531 //check if the object is a subshape
532 if (!theObject->IsMainShape()) {
533 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
534 return aGEOMObject._retn();
537 //Get the object itself
538 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
539 if (anObject.IsNull()) return aGEOMObject._retn();
542 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
543 if (aPoint.IsNull()) return aGEOMObject._retn();
546 GetOperations()->MirrorPoint(anObject, aPoint);
548 return aGEOMObject._retn();
551 //=============================================================================
555 //=============================================================================
556 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy
557 (GEOM::GEOM_Object_ptr theObject,
558 GEOM::GEOM_Object_ptr thePoint)
560 GEOM::GEOM_Object_var aGEOMObject;
562 //Set a not done flag
563 GetOperations()->SetNotDone();
565 //Get the object itself
566 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
567 if (aBasicObject.IsNull()) return aGEOMObject._retn();
569 //Get the vector of translation
570 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
571 if (aPoint.IsNull()) return aGEOMObject._retn();
574 Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint);
575 if (!GetOperations()->IsDone() || anObject.IsNull())
576 return aGEOMObject._retn();
578 return GetObject(anObject);
581 //=============================================================================
585 //=============================================================================
586 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
587 (GEOM::GEOM_Object_ptr theObject,
588 CORBA::Double theOffset)
590 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
592 //Set a not done flag
593 GetOperations()->SetNotDone();
595 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
597 //check if the object is a subshape
598 if (!theObject->IsMainShape()) {
599 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
600 return aGEOMObject._retn();
603 //Get the basic object
604 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
605 if (aBasicObject.IsNull()) return aGEOMObject._retn();
607 //Create the offset shape
608 GetOperations()->OffsetShape(aBasicObject, theOffset);
610 return aGEOMObject._retn();
613 //=============================================================================
617 //=============================================================================
618 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
619 (GEOM::GEOM_Object_ptr theObject,
620 CORBA::Double theOffset)
622 GEOM::GEOM_Object_var aGEOMObject;
624 //Set a not done flag
625 GetOperations()->SetNotDone();
627 //Get the basic object
628 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
629 if (aBasicObject.IsNull()) return aGEOMObject._retn();
631 //Create the offset shape
632 Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset);
633 if (!GetOperations()->IsDone() || anObject.IsNull())
634 return aGEOMObject._retn();
636 return GetObject(anObject);
639 //=============================================================================
643 //=============================================================================
644 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
645 (GEOM::GEOM_Object_ptr theObject,
646 GEOM::GEOM_Object_ptr thePoint,
647 CORBA::Double theFactor)
649 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
651 //Set a not done flag
652 GetOperations()->SetNotDone();
654 if (theObject->_is_nil()) return aGEOMObject._retn();
656 //check if the object is a subshape
657 if (!theObject->IsMainShape()) {
658 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
659 return aGEOMObject._retn();
662 //Get the object itself
663 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
664 if (anObject.IsNull()) return aGEOMObject._retn();
667 Handle(GEOM_Object) aPoint;
668 if (!thePoint->_is_nil()) {
669 aPoint = GetObjectImpl(thePoint);
670 if (aPoint.IsNull()) return aGEOMObject._retn();
674 GetOperations()->ScaleShape(anObject, aPoint, theFactor);
676 return aGEOMObject._retn();
679 //=============================================================================
683 //=============================================================================
684 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
685 (GEOM::GEOM_Object_ptr theObject,
686 GEOM::GEOM_Object_ptr thePoint,
687 CORBA::Double theFactor)
689 GEOM::GEOM_Object_var aGEOMObject;
691 //Set a not done flag
692 GetOperations()->SetNotDone();
694 //Get the basic object
695 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
696 if (aBasicObject.IsNull()) return aGEOMObject._retn();
699 Handle(GEOM_Object) aPoint;
700 if (!thePoint->_is_nil()) {
701 aPoint = GetObjectImpl(thePoint);
702 if (aPoint.IsNull()) return aGEOMObject._retn();
706 Handle(GEOM_Object) anObject =
707 GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
708 if (!GetOperations()->IsDone() || anObject.IsNull())
709 return aGEOMObject._retn();
711 return GetObject(anObject);
714 //=============================================================================
716 * ScaleShapeAlongAxes
718 //=============================================================================
719 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxes
720 (GEOM::GEOM_Object_ptr theObject,
721 GEOM::GEOM_Object_ptr thePoint,
722 CORBA::Double theFactorX,
723 CORBA::Double theFactorY,
724 CORBA::Double theFactorZ)
726 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
728 //Set a not done flag
729 GetOperations()->SetNotDone();
731 if (theObject->_is_nil()) return aGEOMObject._retn();
733 //check if the object is a subshape
734 if (!theObject->IsMainShape()) {
735 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
736 return aGEOMObject._retn();
739 //Get the object itself
740 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
741 if (anObject.IsNull()) return aGEOMObject._retn();
744 Handle(GEOM_Object) aPoint;
745 if (!thePoint->_is_nil()) {
746 aPoint = GetObjectImpl(thePoint);
747 if (aPoint.IsNull()) return aGEOMObject._retn();
751 GetOperations()->ScaleShapeAlongAxes
752 (anObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/false);
754 return aGEOMObject._retn();
757 //=============================================================================
759 * ScaleShapeAlongAxesCopy
761 //=============================================================================
762 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxesCopy
763 (GEOM::GEOM_Object_ptr theObject,
764 GEOM::GEOM_Object_ptr thePoint,
765 CORBA::Double theFactorX,
766 CORBA::Double theFactorY,
767 CORBA::Double theFactorZ)
769 GEOM::GEOM_Object_var aGEOMObject;
771 //Set a not done flag
772 GetOperations()->SetNotDone();
774 //Get the basic object
775 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
776 if (aBasicObject.IsNull()) return aGEOMObject._retn();
779 Handle(GEOM_Object) aPoint;
780 if (!thePoint->_is_nil()) {
781 aPoint = GetObjectImpl(thePoint);
782 if (aPoint.IsNull()) return aGEOMObject._retn();
786 Handle(GEOM_Object) anObject = GetOperations()->ScaleShapeAlongAxes
787 (aBasicObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/true);
788 if (!GetOperations()->IsDone() || anObject.IsNull())
789 return aGEOMObject._retn();
791 return GetObject(anObject);
794 //=============================================================================
798 //=============================================================================
799 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
800 (GEOM::GEOM_Object_ptr theObject,
801 GEOM::GEOM_Object_ptr theStartLCS,
802 GEOM::GEOM_Object_ptr theEndLCS)
804 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
806 //Set a not done flag
807 GetOperations()->SetNotDone();
809 if (CORBA::is_nil(theObject) || CORBA::is_nil(theEndLCS))
810 return aGEOMObject._retn();
812 //check if the object is a subshape
813 if (!theObject->IsMainShape()) {
814 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
815 return aGEOMObject._retn();
818 //Get the basic object
819 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
820 if (anObject.IsNull()) return aGEOMObject._retn();
822 //Get the Start LCS (may be NULL for positioning from global LCS)
823 Handle(GEOM_Object) aStartLCS;
824 if (!CORBA::is_nil(theStartLCS)) {
825 aStartLCS = GetObjectImpl(theStartLCS);
826 if (aStartLCS.IsNull()) return aGEOMObject._retn();
830 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
831 if (aEndLCS.IsNull()) return aGEOMObject._retn();
833 //Perform the Position
834 GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
836 return aGEOMObject._retn();
839 //=============================================================================
843 //=============================================================================
844 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
845 (GEOM::GEOM_Object_ptr theObject,
846 GEOM::GEOM_Object_ptr theStartLCS,
847 GEOM::GEOM_Object_ptr theEndLCS)
849 GEOM::GEOM_Object_var aGEOMObject;
851 //Set a not done flag
852 GetOperations()->SetNotDone();
854 //Get the basic object
855 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
856 if (aBasicObject.IsNull()) return aGEOMObject._retn();
858 //Get the Start LCS (may be NULL for positioning from global LCS)
859 Handle(GEOM_Object) aStartLCS;
860 if (!CORBA::is_nil(theStartLCS)) {
861 aStartLCS = GetObjectImpl(theStartLCS);
862 if (aStartLCS.IsNull()) return aGEOMObject._retn();
866 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
867 if (aEndLCS.IsNull()) return aGEOMObject._retn();
869 //Perform the position
870 Handle(GEOM_Object) anObject =
871 GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
872 if (!GetOperations()->IsDone() || anObject.IsNull())
873 return aGEOMObject._retn();
875 return GetObject(anObject);
878 //=============================================================================
882 //=============================================================================
883 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionAlongPath
884 (GEOM::GEOM_Object_ptr theObject,
885 GEOM::GEOM_Object_ptr thePath,
886 CORBA::Double theDistance,
887 CORBA::Boolean theCopy,
888 CORBA::Boolean theReverse)
890 GEOM::GEOM_Object_var aGEOMObject;
892 //Set a not done flag
893 GetOperations()->SetNotDone();
895 //Get the basic object
896 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
897 if (aBasicObject.IsNull()) return aGEOMObject._retn();
899 //Get the path object
900 Handle(GEOM_Object) aPathObject = GetObjectImpl(thePath);
901 if (aPathObject.IsNull()) return aGEOMObject._retn();
903 //Perform the position
904 Handle(GEOM_Object) anObject =
905 GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy, theReverse);
906 if (!GetOperations()->IsDone() || anObject.IsNull())
907 return aGEOMObject._retn();
909 return GetObject(anObject);
912 //=============================================================================
916 //=============================================================================
917 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
918 (GEOM::GEOM_Object_ptr theObject,
919 GEOM::GEOM_Object_ptr theVector,
920 CORBA::Double theStep, CORBA::Long theNbTimes)
922 //Set a not done flag
923 GetOperations()->SetNotDone();
925 GEOM::GEOM_Object_var aGEOMObject;
927 //Get the object itself
928 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
929 if (aBasicObject.IsNull()) return aGEOMObject._retn();
931 //Get the vector of translation
932 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
933 if (aVector.IsNull()) return aGEOMObject._retn();
935 //Perform the translation
936 Handle(GEOM_Object) anObject =
937 GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
938 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
940 return GetObject(anObject);
943 //=============================================================================
947 //=============================================================================
948 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
949 GEOM::GEOM_Object_ptr theVector1,
950 CORBA::Double theStep1,
951 CORBA::Long theNbTimes1,
952 GEOM::GEOM_Object_ptr theVector2,
953 CORBA::Double theStep2,
954 CORBA::Long theNbTimes2)
956 //Set a not done flag
957 GetOperations()->SetNotDone();
959 GEOM::GEOM_Object_var aGEOMObject;
961 //Get the object itself
962 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
963 if (aBasicObject.IsNull()) return aGEOMObject._retn();
965 //Get the vector1 of translation
966 Handle(GEOM_Object) aVector1 = GetObjectImpl(theVector1);
967 if (aVector1.IsNull()) return aGEOMObject._retn();
969 //Get the vector2 of translation
970 Handle(GEOM_Object) aVector2 = GetObjectImpl(theVector2);
971 if (aVector2.IsNull()) return aGEOMObject._retn();
973 //Perform the translation
974 Handle(GEOM_Object) anObject = GetOperations()->Translate2D
975 (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
976 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
978 return GetObject(anObject);
981 //=============================================================================
985 //=============================================================================
986 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
987 GEOM::GEOM_Object_ptr theVector,
988 CORBA::Long theNbTimes)
990 //Set a not done flag
991 GetOperations()->SetNotDone();
993 GEOM::GEOM_Object_var aGEOMObject;
995 //Get the object itself
996 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
997 if (aBasicObject.IsNull()) return aGEOMObject._retn();
999 //Get the a directon of rotation
1000 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1001 if (aVector.IsNull()) return aGEOMObject._retn();
1003 //Perform the rotation
1004 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
1005 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1007 return GetObject(anObject);
1010 //=============================================================================
1014 //=============================================================================
1015 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
1016 GEOM::GEOM_Object_ptr theVector,
1017 CORBA::Double theAngle,
1018 CORBA::Long theNbTimes1,
1019 CORBA::Double theStep,
1020 CORBA::Long theNbTimes2)
1022 //Set a not done flag
1023 GetOperations()->SetNotDone();
1025 GEOM::GEOM_Object_var aGEOMObject;
1027 //Get the object itself
1028 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1029 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1031 //Get the a directon of rotation
1032 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1033 if (aVector.IsNull()) return aGEOMObject._retn();
1035 //Perform the rotation
1036 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1037 (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
1038 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1040 return GetObject(anObject);
1043 //=============================================================================
1047 //=============================================================================
1048 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
1049 (GEOM::GEOM_Object_ptr theObject,
1050 GEOM::GEOM_Object_ptr theCentPoint,
1051 GEOM::GEOM_Object_ptr thePoint1,
1052 GEOM::GEOM_Object_ptr thePoint2)
1054 //Set a not done flag
1055 GetOperations()->SetNotDone();
1056 GEOM::GEOM_Object_var aGEOMObject;
1058 if (CORBA::is_nil(theObject))
1059 return aGEOMObject._retn();
1061 //check if the object is a subshape
1062 if (!theObject->IsMainShape()) {
1063 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
1064 return aGEOMObject._retn();
1067 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1069 //Get the object itself
1070 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1071 if (anObject.IsNull()) return aGEOMObject._retn();
1073 //Get the central point of rotation
1074 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1075 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1077 //Get the first point
1078 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1079 if (aPoint1.IsNull()) return aGEOMObject._retn();
1081 //Get the second point
1082 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1083 if (aPoint2.IsNull()) return aGEOMObject._retn();
1085 //Perform the translation
1086 GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1088 return aGEOMObject._retn();
1091 //=============================================================================
1093 * RotateThreePointsCopy
1095 //=============================================================================
1096 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1097 (GEOM::GEOM_Object_ptr theObject,
1098 GEOM::GEOM_Object_ptr theCentPoint,
1099 GEOM::GEOM_Object_ptr thePoint1,
1100 GEOM::GEOM_Object_ptr thePoint2)
1102 GEOM::GEOM_Object_var aGEOMObject;
1104 //Set a not done flag
1105 GetOperations()->SetNotDone();
1107 //Get the object itself
1108 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1109 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1111 //Get the central point of rotation
1112 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1113 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1115 //Get the first point
1116 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1117 if (aPoint1.IsNull()) return aGEOMObject._retn();
1119 //Get the second point
1120 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1121 if (aPoint2.IsNull()) return aGEOMObject._retn();
1123 //Perform the rotation
1124 Handle(GEOM_Object) anObject =
1125 GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1126 if (!GetOperations()->IsDone() || anObject.IsNull())
1127 return aGEOMObject._retn();
1129 return GetObject(anObject);
1132 //=============================================================================
1134 * TransformLikeOtherCopy
1136 //=============================================================================
1137 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TransformLikeOtherCopy
1138 (GEOM::GEOM_Object_ptr theObject,
1139 GEOM::GEOM_Object_ptr theSample)
1141 GEOM::GEOM_Object_var aGEOMObject;
1143 //Set a not done flag
1144 GetOperations()->SetNotDone();
1146 //Get the object itself
1147 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1148 if (anObject.IsNull()) return aGEOMObject._retn();
1150 //Get the sample object
1151 Handle(GEOM_Object) aSample = GetObjectImpl(theSample);
1152 if (aSample.IsNull()) return aGEOMObject._retn();
1154 //Perform the transformation
1155 Handle(GEOM_Object) aResObject =
1156 GetOperations()->TransformLikeOtherCopy(anObject, aSample);
1157 if (!GetOperations()->IsDone() || aResObject.IsNull())
1158 return aGEOMObject._retn();
1160 return GetObject(aResObject);
1163 //=============================================================================
1167 //=============================================================================
1168 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RecomputeObject
1169 (GEOM::GEOM_Object_ptr theObject)
1171 //Set a not done flag
1172 GetOperations()->SetNotDone();
1173 GEOM::GEOM_Object_var aGEOMObject;
1175 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
1177 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1179 //Get the object itself
1180 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1181 if (anObject.IsNull()) return aGEOMObject._retn();
1183 //Perform the recomputation
1184 Handle(GEOM_Function) aLastFunction = anObject->GetLastFunction();
1185 if (aLastFunction.IsNull()) return aGEOMObject._retn();
1186 GetOperations()->GetSolver()->ComputeFunction(aLastFunction);
1188 return aGEOMObject._retn();