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 Handle(GEOM_Function) aSrcF;
1240 if (!theStartLCS.IsNull()) aSrcF = theStartLCS->GetLastFunction();
1242 //Add a Position function
1243 Standard_Integer aType = POSITION_SHAPE;
1244 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1246 Handle(GEOM_Function) aFunction =
1247 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1248 if (aFunction.IsNull()) return NULL;
1250 //Check if the function is set correctly
1251 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1253 //Set operation arguments
1254 GEOMImpl_IPosition aTI (aFunction);
1255 aTI.SetShape(anOriginal);
1256 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1257 if (!theStartLCS.IsNull())
1258 aTI.SetStartLCS(aSrcF);
1260 //Compute the Position
1262 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1265 if (!GetSolver()->ComputeFunction(aFunction)) {
1266 SetErrorCode("Position driver failed");
1270 catch (Standard_Failure) {
1271 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1272 SetErrorCode(aFail->GetMessageString());
1276 //Make a Python command
1277 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
1278 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1284 //=============================================================================
1288 //=============================================================================
1289 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1290 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1294 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1296 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1297 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1299 //Add a new Copy object
1300 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1302 //Add a position function
1303 Standard_Integer aType = POSITION_SHAPE_COPY;
1304 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1306 Handle(GEOM_Function) aFunction =
1307 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1308 if (aFunction.IsNull()) return NULL;
1310 //Check if the function is set correctly
1311 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1313 GEOMImpl_IPosition aTI (aFunction);
1314 aTI.SetShape(anOriginal);
1315 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1316 if (!theStartLCS.IsNull())
1317 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1319 //Compute the position
1321 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1324 if (!GetSolver()->ComputeFunction(aFunction)) {
1325 SetErrorCode("Position driver failed");
1329 catch (Standard_Failure) {
1330 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1331 SetErrorCode(aFail->GetMessageString());
1335 //Make a Python command
1336 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1337 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1343 //=============================================================================
1347 //=============================================================================
1348 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath
1349 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath,
1350 double theDistance, bool theCopy, bool theReverse)
1354 if (theObject.IsNull() || thePath.IsNull()) return NULL;
1356 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1357 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1359 //Add a position function
1360 Handle(GEOM_Function) aFunction;
1361 Handle(GEOM_Object) aCopy;
1364 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1365 aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1368 aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1370 if (aFunction.IsNull()) return NULL;
1372 //Check if the function is set correctly
1373 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1375 GEOMImpl_IPosition aTI (aFunction);
1376 aTI.SetShape(anOriginal);
1377 aTI.SetPath(thePath->GetLastFunction());
1378 aTI.SetDistance(theDistance);
1379 aTI.SetReverse(theReverse);
1381 //Compute the position
1383 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1386 if (!GetSolver()->ComputeFunction(aFunction)) {
1387 SetErrorCode("Position driver failed");
1391 catch (Standard_Failure) {
1392 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1393 SetErrorCode(aFail->GetMessageString());
1397 //Make a Python command
1399 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.PositionAlongPath("
1400 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1405 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionAlongPath("
1406 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1412 //=============================================================================
1416 //=============================================================================
1417 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1418 Handle(GEOM_Object) theAxis,
1423 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1425 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1426 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1428 // Get last functions of the arguments
1429 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1431 //Add a rotate function
1432 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1434 if (aFunction.IsNull()) return NULL;
1436 //Check if the function is set correctly
1437 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1439 GEOMImpl_IRotate aRI(aFunction);
1441 aRI.SetOriginal(aLastFunction);
1442 aRI.SetAngle(theAngle);
1444 //Compute the translation
1446 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1449 if (!GetSolver()->ComputeFunction(aFunction)) {
1450 SetErrorCode("Rotate driver failed");
1454 catch (Standard_Failure) {
1455 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1456 SetErrorCode(aFail->GetMessageString());
1460 //Make a Python command
1461 GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject
1462 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1468 //=============================================================================
1472 //=============================================================================
1473 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
1477 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1479 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1480 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1482 //Add a new Copy object
1483 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1485 //Add a rotate function
1486 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1487 if (aFunction.IsNull()) return NULL;
1489 //Check if the function is set correctly
1490 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1492 GEOMImpl_IRotate aRI(aFunction);
1493 aRI.SetAxis(theAxis->GetLastFunction());
1494 aRI.SetOriginal(aLastFunction);
1495 aRI.SetAngle(theAngle);
1497 //Compute the translation
1499 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1502 if (!GetSolver()->ComputeFunction(aFunction)) {
1503 SetErrorCode("Rotate driver failed");
1507 catch (Standard_Failure) {
1508 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1509 SetErrorCode(aFail->GetMessageString());
1513 //Make a Python command
1514 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1515 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1521 //=============================================================================
1525 //=============================================================================
1526 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1527 Handle(GEOM_Object) theAxis,
1528 Standard_Integer theNbTimes)
1532 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1534 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1535 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1537 //Add a new Copy object
1538 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1540 //Add a rotate function
1541 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1542 if (aFunction.IsNull()) return NULL;
1544 //Check if the function is set correctly
1545 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1547 GEOMImpl_IRotate aRI(aFunction);
1548 aRI.SetOriginal(aLastFunction);
1549 aRI.SetAxis(theAxis->GetLastFunction());
1550 aRI.SetNbIter1(theNbTimes);
1552 //Compute the translation
1554 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1557 if (!GetSolver()->ComputeFunction(aFunction)) {
1558 SetErrorCode("Rotate driver failed");
1562 catch (Standard_Failure) {
1563 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1564 SetErrorCode(aFail->GetMessageString());
1568 //Make a Python command
1569 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
1570 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1576 //=============================================================================
1580 //=============================================================================
1581 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1582 Handle(GEOM_Object) theAxis,
1584 Standard_Integer theNbTimes1,
1586 Standard_Integer theNbTimes2)
1590 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1592 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1593 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1595 //Add a new Copy object
1596 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1598 //Add a rotate function
1599 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1600 if (aFunction.IsNull()) return NULL;
1602 //Check if the function is set correctly
1603 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1605 GEOMImpl_IRotate aRI(aFunction);
1606 aRI.SetAxis(theAxis->GetLastFunction());
1607 aRI.SetOriginal(aLastFunction);
1608 aRI.SetNbIter1(theNbTimes1);
1609 aRI.SetNbIter2(theNbTimes2);
1610 aRI.SetAngle(theAngle);
1611 aRI.SetStep(theStep);
1613 //Compute the translation
1615 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1618 if (!GetSolver()->ComputeFunction(aFunction)) {
1619 SetErrorCode("Rotate driver failed");
1623 catch (Standard_Failure) {
1624 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1625 SetErrorCode(aFail->GetMessageString());
1629 //Make a Python command
1630 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
1631 << theObject << ", " << theAxis << ", " << theAngle << ", "
1632 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
1638 //=============================================================================
1642 //=============================================================================
1643 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
1644 Handle(GEOM_Object) theCentPoint,
1645 Handle(GEOM_Object) thePoint1,
1646 Handle(GEOM_Object) thePoint2)
1650 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1652 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1653 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1655 // Get last functions of the arguments
1656 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
1657 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
1658 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
1661 //Add a rotate function
1662 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
1664 if (aFunction.IsNull()) return NULL;
1666 //Check if the function is set correctly
1667 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1669 GEOMImpl_IRotate aRI(aFunction);
1670 aRI.SetCentPoint(aCPF);
1671 aRI.SetPoint1(aP1F);
1672 aRI.SetPoint2(aP2F);
1673 aRI.SetOriginal(aLastFunction);
1675 //Compute the translation
1677 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1680 if (!GetSolver()->ComputeFunction(aFunction)) {
1681 SetErrorCode("Rotate driver failed");
1685 catch (Standard_Failure) {
1686 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1687 SetErrorCode(aFail->GetMessageString());
1691 //Make a Python command
1692 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
1693 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1699 //=============================================================================
1701 * RotateThreePointsCopy
1703 //=============================================================================
1704 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
1705 Handle(GEOM_Object) theCentPoint,
1706 Handle(GEOM_Object) thePoint1,
1707 Handle(GEOM_Object) thePoint2)
1711 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1713 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1714 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1716 //Add a new Copy object
1717 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1719 //Add a rotate function
1720 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
1721 if (aFunction.IsNull()) return NULL;
1723 //Check if the function is set correctly
1724 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1726 GEOMImpl_IRotate aRI(aFunction);
1727 aRI.SetCentPoint(theCentPoint->GetLastFunction());
1728 aRI.SetPoint1(thePoint1->GetLastFunction());
1729 aRI.SetPoint2(thePoint2->GetLastFunction());
1730 aRI.SetOriginal(aLastFunction);
1732 //Compute the translation
1734 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1737 if (!GetSolver()->ComputeFunction(aFunction)) {
1738 SetErrorCode("Rotate driver failed");
1742 catch (Standard_Failure) {
1743 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1744 SetErrorCode(aFail->GetMessageString());
1748 //Make a Python command
1749 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
1750 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";