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
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 subshape
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 subshape
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 subshape
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 subshape
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 subshape
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 subshape
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 subshape
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 subshape
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 subshape
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::ScaleShape
646 (GEOM::GEOM_Object_ptr theObject,
647 GEOM::GEOM_Object_ptr thePoint,
648 CORBA::Double theFactor)
650 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
652 //Set a not done flag
653 GetOperations()->SetNotDone();
655 if (theObject->_is_nil()) return aGEOMObject._retn();
657 //check if the object is a subshape
658 if (!theObject->IsMainShape()) {
659 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
660 return aGEOMObject._retn();
663 //Get the object itself
664 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
665 if (anObject.IsNull()) return aGEOMObject._retn();
668 Handle(GEOM_Object) aPoint;
669 if (!thePoint->_is_nil()) {
670 aPoint = GetObjectImpl(thePoint);
671 if (aPoint.IsNull()) return aGEOMObject._retn();
675 GetOperations()->ScaleShape(anObject, aPoint, theFactor);
677 return aGEOMObject._retn();
680 //=============================================================================
684 //=============================================================================
685 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
686 (GEOM::GEOM_Object_ptr theObject,
687 GEOM::GEOM_Object_ptr thePoint,
688 CORBA::Double theFactor)
690 GEOM::GEOM_Object_var aGEOMObject;
692 //Set a not done flag
693 GetOperations()->SetNotDone();
695 //Get the basic object
696 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
697 if (aBasicObject.IsNull()) return aGEOMObject._retn();
700 Handle(GEOM_Object) aPoint;
701 if (!thePoint->_is_nil()) {
702 aPoint = GetObjectImpl(thePoint);
703 if (aPoint.IsNull()) return aGEOMObject._retn();
707 Handle(GEOM_Object) anObject =
708 GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
709 if (!GetOperations()->IsDone() || anObject.IsNull())
710 return aGEOMObject._retn();
712 return GetObject(anObject);
715 //=============================================================================
717 * ScaleShapeAlongAxes
719 //=============================================================================
720 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxes
721 (GEOM::GEOM_Object_ptr theObject,
722 GEOM::GEOM_Object_ptr thePoint,
723 CORBA::Double theFactorX,
724 CORBA::Double theFactorY,
725 CORBA::Double theFactorZ)
727 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
729 //Set a not done flag
730 GetOperations()->SetNotDone();
732 if (theObject->_is_nil()) return aGEOMObject._retn();
734 //check if the object is a subshape
735 if (!theObject->IsMainShape()) {
736 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
737 return aGEOMObject._retn();
740 //Get the object itself
741 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
742 if (anObject.IsNull()) return aGEOMObject._retn();
745 Handle(GEOM_Object) aPoint;
746 if (!thePoint->_is_nil()) {
747 aPoint = GetObjectImpl(thePoint);
748 if (aPoint.IsNull()) return aGEOMObject._retn();
752 GetOperations()->ScaleShapeAlongAxes
753 (anObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/false);
755 return aGEOMObject._retn();
758 //=============================================================================
760 * ScaleShapeAlongAxesCopy
762 //=============================================================================
763 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxesCopy
764 (GEOM::GEOM_Object_ptr theObject,
765 GEOM::GEOM_Object_ptr thePoint,
766 CORBA::Double theFactorX,
767 CORBA::Double theFactorY,
768 CORBA::Double theFactorZ)
770 GEOM::GEOM_Object_var aGEOMObject;
772 //Set a not done flag
773 GetOperations()->SetNotDone();
775 //Get the basic object
776 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
777 if (aBasicObject.IsNull()) return aGEOMObject._retn();
780 Handle(GEOM_Object) aPoint;
781 if (!thePoint->_is_nil()) {
782 aPoint = GetObjectImpl(thePoint);
783 if (aPoint.IsNull()) return aGEOMObject._retn();
787 Handle(GEOM_Object) anObject = GetOperations()->ScaleShapeAlongAxes
788 (aBasicObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/true);
789 if (!GetOperations()->IsDone() || anObject.IsNull())
790 return aGEOMObject._retn();
792 return GetObject(anObject);
795 //=============================================================================
799 //=============================================================================
800 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
801 (GEOM::GEOM_Object_ptr theObject,
802 GEOM::GEOM_Object_ptr theStartLCS,
803 GEOM::GEOM_Object_ptr theEndLCS)
805 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
807 //Set a not done flag
808 GetOperations()->SetNotDone();
810 if (CORBA::is_nil(theObject) || CORBA::is_nil(theEndLCS))
811 return aGEOMObject._retn();
813 //check if the object is a subshape
814 if (!theObject->IsMainShape()) {
815 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
816 return aGEOMObject._retn();
819 //Get the basic object
820 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
821 if (anObject.IsNull()) return aGEOMObject._retn();
823 //Get the Start LCS (may be NULL for positioning from global LCS)
824 Handle(GEOM_Object) aStartLCS;
825 if (!CORBA::is_nil(theStartLCS)) {
826 aStartLCS = GetObjectImpl(theStartLCS);
827 if (aStartLCS.IsNull()) return aGEOMObject._retn();
831 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
832 if (aEndLCS.IsNull()) return aGEOMObject._retn();
834 //Perform the Position
835 GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
837 return aGEOMObject._retn();
840 //=============================================================================
844 //=============================================================================
845 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
846 (GEOM::GEOM_Object_ptr theObject,
847 GEOM::GEOM_Object_ptr theStartLCS,
848 GEOM::GEOM_Object_ptr theEndLCS)
850 GEOM::GEOM_Object_var aGEOMObject;
852 //Set a not done flag
853 GetOperations()->SetNotDone();
855 //Get the basic object
856 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
857 if (aBasicObject.IsNull()) return aGEOMObject._retn();
859 //Get the Start LCS (may be NULL for positioning from global LCS)
860 Handle(GEOM_Object) aStartLCS;
861 if (!CORBA::is_nil(theStartLCS)) {
862 aStartLCS = GetObjectImpl(theStartLCS);
863 if (aStartLCS.IsNull()) return aGEOMObject._retn();
867 Handle(GEOM_Object) aEndLCS = GetObjectImpl(theEndLCS);
868 if (aEndLCS.IsNull()) return aGEOMObject._retn();
870 //Perform the position
871 Handle(GEOM_Object) anObject =
872 GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
873 if (!GetOperations()->IsDone() || anObject.IsNull())
874 return aGEOMObject._retn();
876 return GetObject(anObject);
879 //=============================================================================
883 //=============================================================================
884 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionAlongPath
885 (GEOM::GEOM_Object_ptr theObject,
886 GEOM::GEOM_Object_ptr thePath,
887 CORBA::Double theDistance,
888 CORBA::Boolean theCopy,
889 CORBA::Boolean theReverse)
891 GEOM::GEOM_Object_var aGEOMObject;
893 //Set a not done flag
894 GetOperations()->SetNotDone();
896 //Get the basic object
897 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
898 if (aBasicObject.IsNull()) return aGEOMObject._retn();
900 //Get the path object
901 Handle(GEOM_Object) aPathObject = GetObjectImpl(thePath);
902 if (aPathObject.IsNull()) return aGEOMObject._retn();
904 //Perform the position
905 Handle(GEOM_Object) anObject =
906 GetOperations()->PositionAlongPath(aBasicObject, aPathObject, theDistance, theCopy, theReverse);
907 if (!GetOperations()->IsDone() || anObject.IsNull())
908 return aGEOMObject._retn();
910 return GetObject(anObject);
913 //=============================================================================
917 //=============================================================================
918 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
919 (GEOM::GEOM_Object_ptr theObject,
920 GEOM::GEOM_Object_ptr theVector,
921 CORBA::Double theStep, CORBA::Long theNbTimes)
923 //Set a not done flag
924 GetOperations()->SetNotDone();
926 GEOM::GEOM_Object_var aGEOMObject;
928 //Get the object itself
929 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
930 if (aBasicObject.IsNull()) return aGEOMObject._retn();
932 //Get the vector of translation
933 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
934 if (aVector.IsNull()) return aGEOMObject._retn();
936 //Perform the translation
937 Handle(GEOM_Object) anObject =
938 GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
939 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
941 return GetObject(anObject);
944 //=============================================================================
948 //=============================================================================
949 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
950 GEOM::GEOM_Object_ptr theVector1,
951 CORBA::Double theStep1,
952 CORBA::Long theNbTimes1,
953 GEOM::GEOM_Object_ptr theVector2,
954 CORBA::Double theStep2,
955 CORBA::Long theNbTimes2)
957 //Set a not done flag
958 GetOperations()->SetNotDone();
960 GEOM::GEOM_Object_var aGEOMObject;
962 //Get the object itself
963 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
964 if (aBasicObject.IsNull()) return aGEOMObject._retn();
966 //Get the vector1 of translation
967 Handle(GEOM_Object) aVector1 = GetObjectImpl(theVector1);
968 if (aVector1.IsNull()) return aGEOMObject._retn();
970 //Get the vector2 of translation
971 Handle(GEOM_Object) aVector2 = GetObjectImpl(theVector2);
972 if (aVector2.IsNull()) return aGEOMObject._retn();
974 //Perform the translation
975 Handle(GEOM_Object) anObject = GetOperations()->Translate2D
976 (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
977 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
979 return GetObject(anObject);
982 //=============================================================================
986 //=============================================================================
987 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
988 GEOM::GEOM_Object_ptr theVector,
989 CORBA::Long theNbTimes)
991 //Set a not done flag
992 GetOperations()->SetNotDone();
994 GEOM::GEOM_Object_var aGEOMObject;
996 //Get the object itself
997 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
998 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1000 //Get the a directon of rotation
1001 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1002 if (aVector.IsNull()) return aGEOMObject._retn();
1004 //Perform the rotation
1005 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
1006 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1008 return GetObject(anObject);
1011 //=============================================================================
1015 //=============================================================================
1016 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
1017 GEOM::GEOM_Object_ptr theVector,
1018 CORBA::Double theAngle,
1019 CORBA::Long theNbTimes1,
1020 CORBA::Double theStep,
1021 CORBA::Long theNbTimes2)
1023 //Set a not done flag
1024 GetOperations()->SetNotDone();
1026 GEOM::GEOM_Object_var aGEOMObject;
1028 //Get the object itself
1029 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1030 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1032 //Get the a directon of rotation
1033 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
1034 if (aVector.IsNull()) return aGEOMObject._retn();
1036 //Perform the rotation
1037 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
1038 (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
1039 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1041 return GetObject(anObject);
1044 //=============================================================================
1048 //=============================================================================
1049 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
1050 (GEOM::GEOM_Object_ptr theObject,
1051 GEOM::GEOM_Object_ptr theCentPoint,
1052 GEOM::GEOM_Object_ptr thePoint1,
1053 GEOM::GEOM_Object_ptr thePoint2)
1055 //Set a not done flag
1056 GetOperations()->SetNotDone();
1057 GEOM::GEOM_Object_var aGEOMObject;
1059 if (CORBA::is_nil(theObject))
1060 return aGEOMObject._retn();
1062 //check if the object is a subshape
1063 if (!theObject->IsMainShape()) {
1064 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
1065 return aGEOMObject._retn();
1068 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1070 //Get the object itself
1071 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1072 if (anObject.IsNull()) return aGEOMObject._retn();
1074 //Get the central point of rotation
1075 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1076 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1078 //Get the first point
1079 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1080 if (aPoint1.IsNull()) return aGEOMObject._retn();
1082 //Get the second point
1083 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1084 if (aPoint2.IsNull()) return aGEOMObject._retn();
1086 //Perform the translation
1087 GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1089 return aGEOMObject._retn();
1092 //=============================================================================
1094 * RotateThreePointsCopy
1096 //=============================================================================
1097 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1098 (GEOM::GEOM_Object_ptr theObject,
1099 GEOM::GEOM_Object_ptr theCentPoint,
1100 GEOM::GEOM_Object_ptr thePoint1,
1101 GEOM::GEOM_Object_ptr thePoint2)
1103 GEOM::GEOM_Object_var aGEOMObject;
1105 //Set a not done flag
1106 GetOperations()->SetNotDone();
1108 //Get the object itself
1109 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject);
1110 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1112 //Get the central point of rotation
1113 Handle(GEOM_Object) aCentPoint = GetObjectImpl(theCentPoint);
1114 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1116 //Get the first point
1117 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
1118 if (aPoint1.IsNull()) return aGEOMObject._retn();
1120 //Get the second point
1121 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
1122 if (aPoint2.IsNull()) return aGEOMObject._retn();
1124 //Perform the rotation
1125 Handle(GEOM_Object) anObject =
1126 GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1127 if (!GetOperations()->IsDone() || anObject.IsNull())
1128 return aGEOMObject._retn();
1130 return GetObject(anObject);
1133 //=============================================================================
1137 //=============================================================================
1138 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RecomputeObject
1139 (GEOM::GEOM_Object_ptr theObject)
1141 //Set a not done flag
1142 GetOperations()->SetNotDone();
1143 GEOM::GEOM_Object_var aGEOMObject;
1145 if (CORBA::is_nil(theObject)) return aGEOMObject._retn();
1147 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1149 //Get the object itself
1150 Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
1151 if (anObject.IsNull()) return aGEOMObject._retn();
1153 //Perform the recomputation
1154 Handle(GEOM_Function) aLastFunction = anObject->GetLastFunction();
1155 if (aLastFunction.IsNull()) return aGEOMObject._retn();
1156 GetOperations()->GetSolver()->ComputeFunction(aLastFunction);
1158 return aGEOMObject._retn();