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 <GEOMImpl_ITransformOperations.hxx>
27 #include "utilities.h"
29 #include <Utils_ExceptHandlers.hxx>
31 #include <TFunction_DriverTable.hxx>
32 #include <TFunction_Driver.hxx>
33 #include <TFunction_Logbook.hxx>
34 #include <TDF_Tool.hxx>
36 #include <GEOM_Function.hxx>
37 #include <GEOM_PythonDump.hxx>
39 #include <GEOMImpl_TranslateDriver.hxx>
40 #include <GEOMImpl_MirrorDriver.hxx>
41 #include <GEOMImpl_OffsetDriver.hxx>
42 #include <GEOMImpl_ScaleDriver.hxx>
43 #include <GEOMImpl_RotateDriver.hxx>
44 #include <GEOMImpl_PositionDriver.hxx>
46 #include <GEOMImpl_ITranslate.hxx>
47 #include <GEOMImpl_IMirror.hxx>
48 #include <GEOMImpl_IOffset.hxx>
49 #include <GEOMImpl_IScale.hxx>
50 #include <GEOMImpl_IRotate.hxx>
51 #include <GEOMImpl_IPosition.hxx>
53 #include <GEOMImpl_Types.hxx>
55 #include <Standard_Failure.hxx>
56 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
58 //=============================================================================
62 //=============================================================================
64 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
65 : GEOM_IOperations(theEngine, theDocID)
67 MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
70 //=============================================================================
74 //=============================================================================
76 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
78 MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
82 //=============================================================================
86 //=============================================================================
87 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
88 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
92 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
94 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
95 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
97 // Get last functions of the arguments
98 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
99 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
101 //Add a translate function
102 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
104 if (aFunction.IsNull()) return NULL;
106 //Check if the function is set correctly
107 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
109 GEOMImpl_ITranslate aTI (aFunction);
112 aTI.SetOriginal(aLastFunction);
114 //Compute the translation
116 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
119 if (!GetSolver()->ComputeFunction(aFunction)) {
120 SetErrorCode("Translation driver failed");
124 catch (Standard_Failure) {
125 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
126 SetErrorCode(aFail->GetMessageString());
130 //Make a Python command
131 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateTwoPoints("
132 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
138 //=============================================================================
142 //=============================================================================
143 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
144 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
148 if (theObject.IsNull()) return NULL;
150 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
151 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
153 //Add a translate function
154 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
156 if (aFunction.IsNull()) return NULL;
158 //Check if the function is set correctly
159 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
161 GEOMImpl_ITranslate aTI(aFunction);
165 aTI.SetOriginal(aLastFunction);
167 //Compute the translation
169 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
172 if (!GetSolver()->ComputeFunction(aFunction)) {
173 SetErrorCode("Translation driver failed");
177 catch (Standard_Failure) {
178 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
179 SetErrorCode(aFail->GetMessageString());
183 //Make a Python command
184 GEOM::TPythonDump(aFunction) << "geompy.TranslateDXDYDZ("
185 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
192 //=============================================================================
194 * TranslateTwoPointsCopy
196 //=============================================================================
197 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
198 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
202 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
204 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
205 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
207 //Add a new Copy object
208 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
210 //Add a translate function
211 Handle(GEOM_Function) aFunction =
212 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
214 //Check if the function is set correctly
215 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
217 GEOMImpl_ITranslate aTI(aFunction);
218 aTI.SetPoint1(thePoint1->GetLastFunction());
219 aTI.SetPoint2(thePoint2->GetLastFunction());
220 //aTI.SetShape(theObject->GetValue());
221 aTI.SetOriginal(aLastFunction);
223 //Compute the translation
225 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
228 if (!GetSolver()->ComputeFunction(aFunction)) {
229 SetErrorCode("Translation driver failed");
233 catch (Standard_Failure) {
234 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
235 SetErrorCode(aFail->GetMessageString());
239 //Make a Python command
240 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
241 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
247 //=============================================================================
249 * TranslateDXDYDZCopy
251 //=============================================================================
252 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
253 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
257 if (theObject.IsNull()) return NULL;
259 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
260 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
262 //Add a new Copy object
263 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
265 //Add a translate function
266 Handle(GEOM_Function) aFunction =
267 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
269 //Check if the function is set correctly
270 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
272 GEOMImpl_ITranslate aTI(aFunction);
276 aTI.SetOriginal(aLastFunction);
278 //Compute the translation
280 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
283 if (!GetSolver()->ComputeFunction(aFunction)) {
284 SetErrorCode("Translation driver failed");
288 catch (Standard_Failure) {
289 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
290 SetErrorCode(aFail->GetMessageString());
294 //Make a Python command
295 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
296 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
303 //=============================================================================
307 //=============================================================================
308 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
309 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
313 if (theObject.IsNull() || theVector.IsNull()) return NULL;
315 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
316 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
318 // Get last functions of the arguments
319 Handle(GEOM_Function) aVF = theVector->GetLastFunction();
321 //Add a translate function
322 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
324 if (aFunction.IsNull()) return NULL;
326 //Check if the function is set correctly
327 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
329 GEOMImpl_ITranslate aTI (aFunction);
331 aTI.SetOriginal(aLastFunction);
333 //Compute the translation
335 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
338 if (!GetSolver()->ComputeFunction(aFunction)) {
339 SetErrorCode("Translation driver failed");
343 catch (Standard_Failure) {
344 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
345 SetErrorCode(aFail->GetMessageString());
349 //Make a Python command
350 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVector("
351 << theObject << ", " << theVector << ")";
356 //=============================================================================
358 * TranslateVectorCopy
360 //=============================================================================
361 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
362 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
366 if (theObject.IsNull() || theVector.IsNull()) return NULL;
368 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
369 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
371 //Add a new Copy object
372 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
374 //Add a translate function
375 Handle(GEOM_Function) aFunction =
376 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
378 //Check if the function is set correctly
379 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
381 GEOMImpl_ITranslate aTI(aFunction);
382 aTI.SetVector(theVector->GetLastFunction());
383 // aTI.SetShape(theObject->GetValue());
384 aTI.SetOriginal(aLastFunction);
386 //Compute the translation
388 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
391 if (!GetSolver()->ComputeFunction(aFunction)) {
392 SetErrorCode("Translation driver failed");
396 catch (Standard_Failure) {
397 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
398 SetErrorCode(aFail->GetMessageString());
402 //Make a Python command
403 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
404 << theObject << ", " << theVector << ")";
410 //=============================================================================
412 * TranslateVectorDistance
414 //=============================================================================
415 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
416 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy)
420 if (theObject.IsNull() || theVector.IsNull()) return NULL;
422 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
423 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
425 Handle(GEOM_Object) aCopy; //Add a new Copy object
426 Handle(GEOM_Function) aFunction;
428 //Add a translate function
430 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
431 aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
434 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
436 if (aFunction.IsNull()) return NULL;
438 //Check if the function is set correctly
439 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
441 GEOMImpl_ITranslate aTI(aFunction);
442 aTI.SetVector(theVector->GetLastFunction());
443 aTI.SetDistance(theDistance);
444 // aTI.SetShape(theObject->GetValue());
445 aTI.SetOriginal(aLastFunction);
447 //Compute the translation
449 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
452 if (!GetSolver()->ComputeFunction(aFunction)) {
453 SetErrorCode("Translation driver failed");
457 catch (Standard_Failure) {
458 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
459 SetErrorCode(aFail->GetMessageString());
463 //Make a Python command
465 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance("
466 << theObject << ", " << theVector << ", " << theDistance << ")";
471 GEOM::TPythonDump(aFunction) << "geompy.TranslateVectorDistance("
472 << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")";
477 //=============================================================================
481 //=============================================================================
482 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
483 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
484 double theStep, Standard_Integer theNbTimes)
488 if (theObject.IsNull() || theVector.IsNull()) return NULL;
490 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
491 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
493 //Add a new Copy object
494 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
496 //Add a translate function
497 Handle(GEOM_Function) aFunction =
498 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
500 //Check if the function is set correctly
501 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
503 GEOMImpl_ITranslate aTI(aFunction);
504 aTI.SetVector(theVector->GetLastFunction());
505 aTI.SetOriginal(aLastFunction);
506 aTI.SetStep1(theStep);
507 aTI.SetNbIter1(theNbTimes);
509 //Compute the translation
511 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
514 if (!GetSolver()->ComputeFunction(aFunction)) {
515 SetErrorCode("Translation driver failed");
519 catch (Standard_Failure) {
520 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
521 SetErrorCode(aFail->GetMessageString());
525 //Make a Python command
526 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
527 << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
533 //=============================================================================
537 //=============================================================================
538 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
539 Handle(GEOM_Object) theVector,
541 Standard_Integer theNbTimes1,
542 Handle(GEOM_Object) theVector2,
544 Standard_Integer theNbTimes2)
548 if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL;
550 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
551 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
553 //Add a new Copy object
554 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
556 //Add a translate function
557 Handle(GEOM_Function) aFunction =
558 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
560 //Check if the function is set correctly
561 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
563 GEOMImpl_ITranslate aTI(aFunction);
564 aTI.SetVector(theVector->GetLastFunction());
565 aTI.SetVector2(theVector2->GetLastFunction());
566 aTI.SetOriginal(aLastFunction);
567 aTI.SetStep1(theStep1);
568 aTI.SetNbIter1(theNbTimes1);
569 aTI.SetStep2(theStep2);
570 aTI.SetNbIter2(theNbTimes2);
572 //Compute the translation
574 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
577 if (!GetSolver()->ComputeFunction(aFunction)) {
578 SetErrorCode("Translation driver failed");
582 catch (Standard_Failure) {
583 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
584 SetErrorCode(aFail->GetMessageString());
588 //Make a Python command
589 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
590 << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1
591 << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
598 //=============================================================================
602 //=============================================================================
603 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
604 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
608 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
610 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
611 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
613 // Get last functions of the arguments
614 Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
616 //Add a mirror function
617 Handle(GEOM_Function) aFunction =
618 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
619 if (aFunction.IsNull()) return NULL;
621 //Check if the function is set correctly
622 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
624 GEOMImpl_IMirror aTI (aFunction);
626 aTI.SetOriginal(aLastFunction);
630 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
633 if (!GetSolver()->ComputeFunction(aFunction)) {
634 SetErrorCode("Mirror driver failed");
638 catch (Standard_Failure) {
639 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
640 SetErrorCode(aFail->GetMessageString());
644 //Make a Python command
645 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane("
646 << theObject << ", " << thePlane << ")";
652 //=============================================================================
656 //=============================================================================
657 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
658 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
662 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
664 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
665 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
667 //Add a new Copy object
668 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
670 //Add a mirror function
671 Handle(GEOM_Function) aFunction =
672 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
674 //Check if the function is set correctly
675 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
677 GEOMImpl_IMirror aTI (aFunction);
678 aTI.SetPlane(thePlane->GetLastFunction());
679 aTI.SetOriginal(aLastFunction);
683 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
686 if (!GetSolver()->ComputeFunction(aFunction)) {
687 SetErrorCode("Mirror driver failed");
691 catch (Standard_Failure) {
692 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
693 SetErrorCode(aFail->GetMessageString());
697 //Make a Python command
698 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
699 << theObject << ", " << thePlane << ")";
705 //=============================================================================
709 //=============================================================================
710 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
711 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
715 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
717 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
718 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
720 // Get last functions of the arguments
721 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
723 //Add a mirror function
724 Handle(GEOM_Function) aFunction =
725 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
726 if (aFunction.IsNull()) return NULL;
728 //Check if the function is set correctly
729 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
731 GEOMImpl_IMirror aTI (aFunction);
733 aTI.SetOriginal(aLastFunction);
737 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
740 if (!GetSolver()->ComputeFunction(aFunction)) {
741 SetErrorCode("Mirror driver failed");
745 catch (Standard_Failure) {
746 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
747 SetErrorCode(aFail->GetMessageString());
751 //Make a Python command
752 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint("
753 << theObject << ", " << thePoint << ")";
759 //=============================================================================
763 //=============================================================================
764 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
765 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
769 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
771 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
772 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
774 //Add a new Copy object
775 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
777 //Add a mirror function
778 Handle(GEOM_Function) aFunction =
779 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
781 //Check if the function is set correctly
782 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
784 GEOMImpl_IMirror aTI (aFunction);
785 aTI.SetPoint(thePoint->GetLastFunction());
786 aTI.SetOriginal(aLastFunction);
790 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
793 if (!GetSolver()->ComputeFunction(aFunction)) {
794 SetErrorCode("Mirror driver failed");
798 catch (Standard_Failure) {
799 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
800 SetErrorCode(aFail->GetMessageString());
804 //Make a Python command
805 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
806 << theObject << ", " << thePoint << ")";
812 //=============================================================================
816 //=============================================================================
817 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
818 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
822 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
824 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
825 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
827 // Get last functions of the arguments
828 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
830 //Add a mirror function
831 Handle(GEOM_Function) aFunction =
832 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
833 if (aFunction.IsNull()) return NULL;
835 //Check if the function is set correctly
836 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
838 GEOMImpl_IMirror aTI (aFunction);
840 aTI.SetOriginal(aLastFunction);
844 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
847 if (!GetSolver()->ComputeFunction(aFunction)) {
848 SetErrorCode("Mirror driver failed");
852 catch (Standard_Failure) {
853 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
854 SetErrorCode(aFail->GetMessageString());
858 //Make a Python command
859 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis("
860 << theObject << ", " << theAxis << ")";
866 //=============================================================================
870 //=============================================================================
871 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
872 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
876 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
878 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
879 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
881 //Add a new Copy object
882 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
884 //Add a mirror function
885 Handle(GEOM_Function) aFunction =
886 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
888 //Check if the function is set correctly
889 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
891 GEOMImpl_IMirror aTI (aFunction);
892 aTI.SetAxis(theAxis->GetLastFunction());
893 aTI.SetOriginal(aLastFunction);
897 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
900 if (!GetSolver()->ComputeFunction(aFunction)) {
901 SetErrorCode("Mirror driver failed");
905 catch (Standard_Failure) {
906 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
907 SetErrorCode(aFail->GetMessageString());
911 //Make a Python command
912 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
913 << theObject << ", " << theAxis << ")";
920 //=============================================================================
924 //=============================================================================
925 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
926 (Handle(GEOM_Object) theObject, double theOffset)
930 if (theObject.IsNull()) return NULL;
932 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
933 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
935 //Add a new Offset function
936 Handle(GEOM_Function) aFunction =
937 theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
938 if (aFunction.IsNull()) return NULL;
940 //Check if the function is set correctly
941 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
943 GEOMImpl_IOffset aTI (aFunction);
944 aTI.SetShape(anOriginal);
945 aTI.SetValue(theOffset);
949 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
952 if (!GetSolver()->ComputeFunction(aFunction)) {
953 SetErrorCode("Offset driver failed");
957 catch (Standard_Failure) {
958 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
959 SetErrorCode(aFail->GetMessageString());
963 //Make a Python command
964 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape("
965 << theObject << ", " << theOffset << ")";
971 //=============================================================================
975 //=============================================================================
976 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
977 (Handle(GEOM_Object) theObject, double theOffset)
981 if (theObject.IsNull()) return NULL;
983 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
984 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
986 //Add a new Copy object
987 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
989 //Add a new Offset function
990 Handle(GEOM_Function) aFunction =
991 aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
992 if (aFunction.IsNull()) return NULL;
994 //Check if the function is set correctly
995 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
997 GEOMImpl_IOffset aTI (aFunction);
998 aTI.SetShape(anOriginal);
999 aTI.SetValue(theOffset);
1001 //Compute the offset
1003 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1006 if (!GetSolver()->ComputeFunction(aFunction)) {
1007 SetErrorCode("Offset driver failed");
1011 catch (Standard_Failure) {
1012 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1013 SetErrorCode(aFail->GetMessageString());
1017 //Make a Python command
1018 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
1019 << theObject << ", " << theOffset << ")";
1026 //=============================================================================
1030 //=============================================================================
1031 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
1032 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1036 if (theObject.IsNull()) return NULL;
1038 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1039 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1041 //Add a scale function
1042 Handle(GEOM_Function) aFunction =
1043 theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
1044 if (aFunction.IsNull()) return NULL;
1046 //Check if the function is set correctly
1047 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1050 GEOMImpl_IScale aTI (aFunction);
1051 aTI.SetShape(anOriginal);
1052 aTI.SetFactor(theFactor);
1054 // Set point argument
1055 if (!thePoint.IsNull()) {
1056 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1062 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1065 if (!GetSolver()->ComputeFunction(aFunction)) {
1066 SetErrorCode("Scale driver failed");
1070 catch (Standard_Failure) {
1071 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1072 SetErrorCode(aFail->GetMessageString());
1076 //Make a Python command
1077 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape("
1078 << theObject << ", " << thePoint << ", " << theFactor << ")";
1084 //=============================================================================
1088 //=============================================================================
1089 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1090 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1094 if (theObject.IsNull()) return NULL;
1096 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1097 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1099 //Add a new Copy object
1100 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1102 //Add a scale function
1103 Handle(GEOM_Function) aFunction =
1104 aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1105 if (aFunction.IsNull()) return NULL;
1107 //Check if the function is set correctly
1108 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1111 GEOMImpl_IScale aTI (aFunction);
1112 aTI.SetShape(anOriginal);
1113 aTI.SetFactor(theFactor);
1115 // Set point argument
1116 if (!thePoint.IsNull()) {
1117 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1123 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1126 if (!GetSolver()->ComputeFunction(aFunction)) {
1127 SetErrorCode("Scale driver failed");
1131 catch (Standard_Failure) {
1132 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1133 SetErrorCode(aFail->GetMessageString());
1137 //Make a Python command
1138 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1139 << theObject << ", " << thePoint << ", " << theFactor << ")";
1145 //=============================================================================
1147 * ScaleShapeAlongAxes
1149 //=============================================================================
1150 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
1151 Handle(GEOM_Object) thePoint,
1159 if (theObject.IsNull()) return NULL;
1161 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1162 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1164 //Add a scale function
1165 Handle(GEOM_Object) aCopy; //Add a new Copy object
1166 Handle(GEOM_Function) aFunction;
1168 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1169 aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
1172 aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES);
1174 if (aFunction.IsNull()) return NULL;
1176 //Check if the function is set correctly
1177 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1180 GEOMImpl_IScale aTI (aFunction);
1181 aTI.SetShape(anOriginal);
1182 aTI.SetFactorX(theFactorX);
1183 aTI.SetFactorY(theFactorY);
1184 aTI.SetFactorZ(theFactorZ);
1186 // Set point (optional argument)
1187 if (!thePoint.IsNull()) {
1188 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1194 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1197 if (!GetSolver()->ComputeFunction(aFunction)) {
1198 SetErrorCode("Scale driver failed");
1202 catch (Standard_Failure) {
1203 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1204 SetErrorCode(aFail->GetMessageString());
1210 //Make a Python command
1212 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleAlongAxes("
1213 << theObject << ", " << thePoint << ", "
1214 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1218 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShapeAlongAxes("
1219 << theObject << ", " << thePoint << ", "
1220 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1224 //=============================================================================
1228 //=============================================================================
1229 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1230 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1234 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1236 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1237 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1239 //Add a Position function
1240 Standard_Integer aType = POSITION_SHAPE;
1241 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1243 Handle(GEOM_Function) aFunction =
1244 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1245 if (aFunction.IsNull()) return NULL;
1247 //Check if the function is set correctly
1248 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1250 //Set operation arguments
1251 GEOMImpl_IPosition aTI (aFunction);
1252 aTI.SetShape(anOriginal);
1253 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1254 if (!theStartLCS.IsNull())
1255 aTI.SetStartLCS(theObject == theStartLCS ? anOriginal : theStartLCS->GetLastFunction());
1257 //Compute the Position
1259 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1262 if (!GetSolver()->ComputeFunction(aFunction)) {
1263 SetErrorCode("Position driver failed");
1267 catch (Standard_Failure) {
1268 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1269 SetErrorCode(aFail->GetMessageString());
1273 //Make a Python command
1274 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
1275 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1281 //=============================================================================
1285 //=============================================================================
1286 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1287 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1291 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1293 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1294 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1296 //Add a new Copy object
1297 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1299 //Add a position function
1300 Standard_Integer aType = POSITION_SHAPE_COPY;
1301 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1303 Handle(GEOM_Function) aFunction =
1304 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1305 if (aFunction.IsNull()) return NULL;
1307 //Check if the function is set correctly
1308 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1310 GEOMImpl_IPosition aTI (aFunction);
1311 aTI.SetShape(anOriginal);
1312 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1313 if (!theStartLCS.IsNull())
1314 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1316 //Compute the position
1318 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1321 if (!GetSolver()->ComputeFunction(aFunction)) {
1322 SetErrorCode("Position driver failed");
1326 catch (Standard_Failure) {
1327 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1328 SetErrorCode(aFail->GetMessageString());
1332 //Make a Python command
1333 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1334 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1340 //=============================================================================
1344 //=============================================================================
1345 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath
1346 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath,
1347 double theDistance, bool theCopy, bool theReverse)
1351 if (theObject.IsNull() || thePath.IsNull()) return NULL;
1353 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1354 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1356 //Add a position function
1357 Handle(GEOM_Function) aFunction;
1358 Handle(GEOM_Object) aCopy;
1361 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1362 aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1365 aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1367 if (aFunction.IsNull()) return NULL;
1369 //Check if the function is set correctly
1370 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1372 GEOMImpl_IPosition aTI (aFunction);
1373 aTI.SetShape(anOriginal);
1374 aTI.SetPath(thePath->GetLastFunction());
1375 aTI.SetDistance(theDistance);
1376 aTI.SetReverse(theReverse);
1378 //Compute the position
1380 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1383 if (!GetSolver()->ComputeFunction(aFunction)) {
1384 SetErrorCode("Position driver failed");
1388 catch (Standard_Failure) {
1389 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1390 SetErrorCode(aFail->GetMessageString());
1394 //Make a Python command
1396 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.PositionAlongPath("
1397 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1402 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionAlongPath("
1403 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1409 //=============================================================================
1413 //=============================================================================
1414 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1415 Handle(GEOM_Object) theAxis,
1420 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1422 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1423 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1425 // Get last functions of the arguments
1426 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1428 //Add a rotate function
1429 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1431 if (aFunction.IsNull()) return NULL;
1433 //Check if the function is set correctly
1434 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1436 GEOMImpl_IRotate aRI(aFunction);
1438 aRI.SetOriginal(aLastFunction);
1439 aRI.SetAngle(theAngle);
1441 //Compute the translation
1443 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1446 if (!GetSolver()->ComputeFunction(aFunction)) {
1447 SetErrorCode("Rotate driver failed");
1451 catch (Standard_Failure) {
1452 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1453 SetErrorCode(aFail->GetMessageString());
1457 //Make a Python command
1458 GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject
1459 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1465 //=============================================================================
1469 //=============================================================================
1470 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
1474 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1476 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1477 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1479 //Add a new Copy object
1480 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1482 //Add a rotate function
1483 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1484 if (aFunction.IsNull()) return NULL;
1486 //Check if the function is set correctly
1487 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1489 GEOMImpl_IRotate aRI(aFunction);
1490 aRI.SetAxis(theAxis->GetLastFunction());
1491 aRI.SetOriginal(aLastFunction);
1492 aRI.SetAngle(theAngle);
1494 //Compute the translation
1496 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1499 if (!GetSolver()->ComputeFunction(aFunction)) {
1500 SetErrorCode("Rotate driver failed");
1504 catch (Standard_Failure) {
1505 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1506 SetErrorCode(aFail->GetMessageString());
1510 //Make a Python command
1511 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1512 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1518 //=============================================================================
1522 //=============================================================================
1523 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1524 Handle(GEOM_Object) theAxis,
1525 Standard_Integer theNbTimes)
1529 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1531 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1532 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1534 //Add a new Copy object
1535 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1537 //Add a rotate function
1538 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1539 if (aFunction.IsNull()) return NULL;
1541 //Check if the function is set correctly
1542 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1544 GEOMImpl_IRotate aRI(aFunction);
1545 aRI.SetOriginal(aLastFunction);
1546 aRI.SetAxis(theAxis->GetLastFunction());
1547 aRI.SetNbIter1(theNbTimes);
1549 //Compute the translation
1551 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1554 if (!GetSolver()->ComputeFunction(aFunction)) {
1555 SetErrorCode("Rotate driver failed");
1559 catch (Standard_Failure) {
1560 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1561 SetErrorCode(aFail->GetMessageString());
1565 //Make a Python command
1566 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
1567 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1573 //=============================================================================
1577 //=============================================================================
1578 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1579 Handle(GEOM_Object) theAxis,
1581 Standard_Integer theNbTimes1,
1583 Standard_Integer theNbTimes2)
1587 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1589 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1590 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1592 //Add a new Copy object
1593 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1595 //Add a rotate function
1596 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1597 if (aFunction.IsNull()) return NULL;
1599 //Check if the function is set correctly
1600 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1602 GEOMImpl_IRotate aRI(aFunction);
1603 aRI.SetAxis(theAxis->GetLastFunction());
1604 aRI.SetOriginal(aLastFunction);
1605 aRI.SetNbIter1(theNbTimes1);
1606 aRI.SetNbIter2(theNbTimes2);
1607 aRI.SetAngle(theAngle);
1608 aRI.SetStep(theStep);
1610 //Compute the translation
1612 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1615 if (!GetSolver()->ComputeFunction(aFunction)) {
1616 SetErrorCode("Rotate driver failed");
1620 catch (Standard_Failure) {
1621 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1622 SetErrorCode(aFail->GetMessageString());
1626 //Make a Python command
1627 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
1628 << theObject << ", " << theAxis << ", " << theAngle << ", "
1629 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
1635 //=============================================================================
1639 //=============================================================================
1640 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
1641 Handle(GEOM_Object) theCentPoint,
1642 Handle(GEOM_Object) thePoint1,
1643 Handle(GEOM_Object) thePoint2)
1647 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1649 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1650 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1652 // Get last functions of the arguments
1653 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
1654 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
1655 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
1658 //Add a rotate function
1659 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
1661 if (aFunction.IsNull()) return NULL;
1663 //Check if the function is set correctly
1664 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1666 GEOMImpl_IRotate aRI(aFunction);
1667 aRI.SetCentPoint(aCPF);
1668 aRI.SetPoint1(aP1F);
1669 aRI.SetPoint2(aP2F);
1670 aRI.SetOriginal(aLastFunction);
1672 //Compute the translation
1674 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1677 if (!GetSolver()->ComputeFunction(aFunction)) {
1678 SetErrorCode("Rotate driver failed");
1682 catch (Standard_Failure) {
1683 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1684 SetErrorCode(aFail->GetMessageString());
1688 //Make a Python command
1689 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
1690 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1696 //=============================================================================
1698 * RotateThreePointsCopy
1700 //=============================================================================
1701 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
1702 Handle(GEOM_Object) theCentPoint,
1703 Handle(GEOM_Object) thePoint1,
1704 Handle(GEOM_Object) thePoint2)
1708 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1710 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1711 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1713 //Add a new Copy object
1714 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1716 //Add a rotate function
1717 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
1718 if (aFunction.IsNull()) return NULL;
1720 //Check if the function is set correctly
1721 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1723 GEOMImpl_IRotate aRI(aFunction);
1724 aRI.SetCentPoint(theCentPoint->GetLastFunction());
1725 aRI.SetPoint1(thePoint1->GetLastFunction());
1726 aRI.SetPoint2(thePoint2->GetLastFunction());
1727 aRI.SetOriginal(aLastFunction);
1729 //Compute the translation
1731 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1734 if (!GetSolver()->ComputeFunction(aFunction)) {
1735 SetErrorCode("Rotate driver failed");
1739 catch (Standard_Failure) {
1740 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1741 SetErrorCode(aFail->GetMessageString());
1745 //Make a Python command
1746 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
1747 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";