1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include <GEOMImpl_ITransformOperations.hxx>
26 #include "utilities.h"
28 #include <Utils_ExceptHandlers.hxx>
30 #include <TFunction_DriverTable.hxx>
31 #include <TFunction_Driver.hxx>
32 #include <TFunction_Logbook.hxx>
33 #include <TDF_Tool.hxx>
35 #include <GEOM_Function.hxx>
36 #include <GEOM_PythonDump.hxx>
38 #include <GEOMImpl_TranslateDriver.hxx>
39 #include <GEOMImpl_MirrorDriver.hxx>
40 #include <GEOMImpl_OffsetDriver.hxx>
41 #include <GEOMImpl_ScaleDriver.hxx>
42 #include <GEOMImpl_RotateDriver.hxx>
43 #include <GEOMImpl_PositionDriver.hxx>
45 #include <GEOMImpl_ITranslate.hxx>
46 #include <GEOMImpl_IMirror.hxx>
47 #include <GEOMImpl_IOffset.hxx>
48 #include <GEOMImpl_IScale.hxx>
49 #include <GEOMImpl_IRotate.hxx>
50 #include <GEOMImpl_IPosition.hxx>
52 #include <GEOMImpl_Types.hxx>
54 #include <Standard_Failure.hxx>
55 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
57 //=============================================================================
61 //=============================================================================
63 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
64 : GEOM_IOperations(theEngine, theDocID)
66 MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
69 //=============================================================================
73 //=============================================================================
75 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
77 MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
81 //=============================================================================
85 //=============================================================================
86 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
87 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
91 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
93 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
94 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
96 // Get last functions of the arguments
97 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
98 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
100 //Add a translate function
101 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
103 if (aFunction.IsNull()) return NULL;
105 //Check if the function is set correctly
106 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
108 GEOMImpl_ITranslate aTI (aFunction);
111 aTI.SetOriginal(aLastFunction);
113 //Compute the translation
115 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
118 if (!GetSolver()->ComputeFunction(aFunction)) {
119 SetErrorCode("Translation driver failed");
123 catch (Standard_Failure) {
124 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
125 SetErrorCode(aFail->GetMessageString());
129 //Make a Python command
130 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateTwoPoints("
131 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
137 //=============================================================================
141 //=============================================================================
142 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
143 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
147 if (theObject.IsNull()) return NULL;
149 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
150 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
152 //Add a translate function
153 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
155 if (aFunction.IsNull()) return NULL;
157 //Check if the function is set correctly
158 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
160 GEOMImpl_ITranslate aTI(aFunction);
164 aTI.SetOriginal(aLastFunction);
166 //Compute the translation
168 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
171 if (!GetSolver()->ComputeFunction(aFunction)) {
172 SetErrorCode("Translation driver failed");
176 catch (Standard_Failure) {
177 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
178 SetErrorCode(aFail->GetMessageString());
182 //Make a Python command
183 GEOM::TPythonDump(aFunction) << "geompy.TranslateDXDYDZ("
184 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
191 //=============================================================================
193 * TranslateTwoPointsCopy
195 //=============================================================================
196 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
197 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
201 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
203 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
204 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
206 //Add a new Copy object
207 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
209 //Add a translate function
210 Handle(GEOM_Function) aFunction =
211 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
213 //Check if the function is set correctly
214 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
216 GEOMImpl_ITranslate aTI(aFunction);
217 aTI.SetPoint1(thePoint1->GetLastFunction());
218 aTI.SetPoint2(thePoint2->GetLastFunction());
219 //aTI.SetShape(theObject->GetValue());
220 aTI.SetOriginal(aLastFunction);
222 //Compute the translation
224 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
227 if (!GetSolver()->ComputeFunction(aFunction)) {
228 SetErrorCode("Translation driver failed");
232 catch (Standard_Failure) {
233 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
234 SetErrorCode(aFail->GetMessageString());
238 //Make a Python command
239 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
240 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
246 //=============================================================================
248 * TranslateDXDYDZCopy
250 //=============================================================================
251 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
252 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
256 if (theObject.IsNull()) return NULL;
258 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
259 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
261 //Add a new Copy object
262 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
264 //Add a translate function
265 Handle(GEOM_Function) aFunction =
266 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
268 //Check if the function is set correctly
269 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
271 GEOMImpl_ITranslate aTI(aFunction);
275 aTI.SetOriginal(aLastFunction);
277 //Compute the translation
279 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
282 if (!GetSolver()->ComputeFunction(aFunction)) {
283 SetErrorCode("Translation driver failed");
287 catch (Standard_Failure) {
288 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
289 SetErrorCode(aFail->GetMessageString());
293 //Make a Python command
294 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
295 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
302 //=============================================================================
306 //=============================================================================
307 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
308 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
312 if (theObject.IsNull() || theVector.IsNull()) return NULL;
314 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
315 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
317 // Get last functions of the arguments
318 Handle(GEOM_Function) aVF = theVector->GetLastFunction();
320 //Add a translate function
321 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
323 if (aFunction.IsNull()) return NULL;
325 //Check if the function is set correctly
326 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
328 GEOMImpl_ITranslate aTI (aFunction);
330 aTI.SetOriginal(aLastFunction);
332 //Compute the translation
334 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
337 if (!GetSolver()->ComputeFunction(aFunction)) {
338 SetErrorCode("Translation driver failed");
342 catch (Standard_Failure) {
343 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
344 SetErrorCode(aFail->GetMessageString());
348 //Make a Python command
349 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVector("
350 << theObject << ", " << theVector << ")";
355 //=============================================================================
357 * TranslateVectorCopy
359 //=============================================================================
360 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
361 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
365 if (theObject.IsNull() || theVector.IsNull()) return NULL;
367 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
368 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
370 //Add a new Copy object
371 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
373 //Add a translate function
374 Handle(GEOM_Function) aFunction =
375 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
377 //Check if the function is set correctly
378 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
380 GEOMImpl_ITranslate aTI(aFunction);
381 aTI.SetVector(theVector->GetLastFunction());
382 // aTI.SetShape(theObject->GetValue());
383 aTI.SetOriginal(aLastFunction);
385 //Compute the translation
387 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
390 if (!GetSolver()->ComputeFunction(aFunction)) {
391 SetErrorCode("Translation driver failed");
395 catch (Standard_Failure) {
396 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
397 SetErrorCode(aFail->GetMessageString());
401 //Make a Python command
402 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
403 << theObject << ", " << theVector << ")";
409 //=============================================================================
411 * TranslateVectorDistance
413 //=============================================================================
414 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
415 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy)
419 if (theObject.IsNull() || theVector.IsNull()) return NULL;
421 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
422 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
424 Handle(GEOM_Object) aCopy; //Add a new Copy object
425 Handle(GEOM_Function) aFunction;
427 //Add a translate function
429 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
430 aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
433 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
435 if (aFunction.IsNull()) return NULL;
437 //Check if the function is set correctly
438 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
440 GEOMImpl_ITranslate aTI(aFunction);
441 aTI.SetVector(theVector->GetLastFunction());
442 aTI.SetDistance(theDistance);
443 // aTI.SetShape(theObject->GetValue());
444 aTI.SetOriginal(aLastFunction);
446 //Compute the translation
448 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
451 if (!GetSolver()->ComputeFunction(aFunction)) {
452 SetErrorCode("Translation driver failed");
456 catch (Standard_Failure) {
457 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
458 SetErrorCode(aFail->GetMessageString());
462 //Make a Python command
464 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance("
465 << theObject << ", " << theVector << ", " << theDistance << ")";
470 GEOM::TPythonDump(aFunction) << "geompy.TranslateVectorDistance("
471 << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")";
476 //=============================================================================
480 //=============================================================================
481 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
482 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
483 double theStep, Standard_Integer theNbTimes)
487 if (theObject.IsNull() || theVector.IsNull()) return NULL;
489 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
490 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
492 //Add a new Copy object
493 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
495 //Add a translate function
496 Handle(GEOM_Function) aFunction =
497 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
499 //Check if the function is set correctly
500 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
502 GEOMImpl_ITranslate aTI(aFunction);
503 aTI.SetVector(theVector->GetLastFunction());
504 aTI.SetOriginal(aLastFunction);
505 aTI.SetStep1(theStep);
506 aTI.SetNbIter1(theNbTimes);
508 //Compute the translation
510 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
513 if (!GetSolver()->ComputeFunction(aFunction)) {
514 SetErrorCode("Translation driver failed");
518 catch (Standard_Failure) {
519 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
520 SetErrorCode(aFail->GetMessageString());
524 //Make a Python command
525 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
526 << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
532 //=============================================================================
536 //=============================================================================
537 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
538 Handle(GEOM_Object) theVector,
540 Standard_Integer theNbTimes1,
541 Handle(GEOM_Object) theVector2,
543 Standard_Integer theNbTimes2)
547 if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL;
549 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
550 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
552 //Add a new Copy object
553 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
555 //Add a translate function
556 Handle(GEOM_Function) aFunction =
557 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
559 //Check if the function is set correctly
560 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
562 GEOMImpl_ITranslate aTI(aFunction);
563 aTI.SetVector(theVector->GetLastFunction());
564 aTI.SetVector2(theVector2->GetLastFunction());
565 aTI.SetOriginal(aLastFunction);
566 aTI.SetStep1(theStep1);
567 aTI.SetNbIter1(theNbTimes1);
568 aTI.SetStep2(theStep2);
569 aTI.SetNbIter2(theNbTimes2);
571 //Compute the translation
573 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
576 if (!GetSolver()->ComputeFunction(aFunction)) {
577 SetErrorCode("Translation driver failed");
581 catch (Standard_Failure) {
582 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
583 SetErrorCode(aFail->GetMessageString());
587 //Make a Python command
588 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
589 << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1
590 << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
597 //=============================================================================
601 //=============================================================================
602 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
603 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
607 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
609 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
610 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
612 // Get last functions of the arguments
613 Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
615 //Add a mirror function
616 Handle(GEOM_Function) aFunction =
617 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
618 if (aFunction.IsNull()) return NULL;
620 //Check if the function is set correctly
621 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
623 GEOMImpl_IMirror aTI (aFunction);
625 aTI.SetOriginal(aLastFunction);
629 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
632 if (!GetSolver()->ComputeFunction(aFunction)) {
633 SetErrorCode("Mirror driver failed");
637 catch (Standard_Failure) {
638 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
639 SetErrorCode(aFail->GetMessageString());
643 //Make a Python command
644 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane("
645 << theObject << ", " << thePlane << ")";
651 //=============================================================================
655 //=============================================================================
656 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
657 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
661 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
663 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
664 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
666 //Add a new Copy object
667 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
669 //Add a mirror function
670 Handle(GEOM_Function) aFunction =
671 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
673 //Check if the function is set correctly
674 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
676 GEOMImpl_IMirror aTI (aFunction);
677 aTI.SetPlane(thePlane->GetLastFunction());
678 aTI.SetOriginal(aLastFunction);
682 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
685 if (!GetSolver()->ComputeFunction(aFunction)) {
686 SetErrorCode("Mirror driver failed");
690 catch (Standard_Failure) {
691 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
692 SetErrorCode(aFail->GetMessageString());
696 //Make a Python command
697 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
698 << theObject << ", " << thePlane << ")";
704 //=============================================================================
708 //=============================================================================
709 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
710 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
714 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
716 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
717 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
719 // Get last functions of the arguments
720 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
722 //Add a mirror function
723 Handle(GEOM_Function) aFunction =
724 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
725 if (aFunction.IsNull()) return NULL;
727 //Check if the function is set correctly
728 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
730 GEOMImpl_IMirror aTI (aFunction);
732 aTI.SetOriginal(aLastFunction);
736 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
739 if (!GetSolver()->ComputeFunction(aFunction)) {
740 SetErrorCode("Mirror driver failed");
744 catch (Standard_Failure) {
745 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
746 SetErrorCode(aFail->GetMessageString());
750 //Make a Python command
751 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint("
752 << theObject << ", " << thePoint << ")";
758 //=============================================================================
762 //=============================================================================
763 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
764 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
768 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
770 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
771 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
773 //Add a new Copy object
774 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
776 //Add a mirror function
777 Handle(GEOM_Function) aFunction =
778 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
780 //Check if the function is set correctly
781 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
783 GEOMImpl_IMirror aTI (aFunction);
784 aTI.SetPoint(thePoint->GetLastFunction());
785 aTI.SetOriginal(aLastFunction);
789 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
792 if (!GetSolver()->ComputeFunction(aFunction)) {
793 SetErrorCode("Mirror driver failed");
797 catch (Standard_Failure) {
798 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
799 SetErrorCode(aFail->GetMessageString());
803 //Make a Python command
804 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
805 << theObject << ", " << thePoint << ")";
811 //=============================================================================
815 //=============================================================================
816 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
817 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
821 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
823 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
824 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
826 // Get last functions of the arguments
827 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
829 //Add a mirror function
830 Handle(GEOM_Function) aFunction =
831 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
832 if (aFunction.IsNull()) return NULL;
834 //Check if the function is set correctly
835 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
837 GEOMImpl_IMirror aTI (aFunction);
839 aTI.SetOriginal(aLastFunction);
843 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
846 if (!GetSolver()->ComputeFunction(aFunction)) {
847 SetErrorCode("Mirror driver failed");
851 catch (Standard_Failure) {
852 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
853 SetErrorCode(aFail->GetMessageString());
857 //Make a Python command
858 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis("
859 << theObject << ", " << theAxis << ")";
865 //=============================================================================
869 //=============================================================================
870 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
871 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
875 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
877 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
878 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
880 //Add a new Copy object
881 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
883 //Add a mirror function
884 Handle(GEOM_Function) aFunction =
885 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
887 //Check if the function is set correctly
888 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
890 GEOMImpl_IMirror aTI (aFunction);
891 aTI.SetAxis(theAxis->GetLastFunction());
892 aTI.SetOriginal(aLastFunction);
896 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
899 if (!GetSolver()->ComputeFunction(aFunction)) {
900 SetErrorCode("Mirror driver failed");
904 catch (Standard_Failure) {
905 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
906 SetErrorCode(aFail->GetMessageString());
910 //Make a Python command
911 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
912 << theObject << ", " << theAxis << ")";
919 //=============================================================================
923 //=============================================================================
924 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
925 (Handle(GEOM_Object) theObject, double theOffset)
929 if (theObject.IsNull()) return NULL;
931 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
932 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
934 //Add a new Offset function
935 Handle(GEOM_Function) aFunction =
936 theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
937 if (aFunction.IsNull()) return NULL;
939 //Check if the function is set correctly
940 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
942 GEOMImpl_IOffset aTI (aFunction);
943 aTI.SetShape(anOriginal);
944 aTI.SetValue(theOffset);
948 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
951 if (!GetSolver()->ComputeFunction(aFunction)) {
952 SetErrorCode("Offset driver failed");
956 catch (Standard_Failure) {
957 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
958 SetErrorCode(aFail->GetMessageString());
962 //Make a Python command
963 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape("
964 << theObject << ", " << theOffset << ")";
970 //=============================================================================
974 //=============================================================================
975 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
976 (Handle(GEOM_Object) theObject, double theOffset)
980 if (theObject.IsNull()) return NULL;
982 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
983 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
985 //Add a new Copy object
986 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
988 //Add a new Offset function
989 Handle(GEOM_Function) aFunction =
990 aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
991 if (aFunction.IsNull()) return NULL;
993 //Check if the function is set correctly
994 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
996 GEOMImpl_IOffset aTI (aFunction);
997 aTI.SetShape(anOriginal);
998 aTI.SetValue(theOffset);
1000 //Compute the offset
1002 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1005 if (!GetSolver()->ComputeFunction(aFunction)) {
1006 SetErrorCode("Offset driver failed");
1010 catch (Standard_Failure) {
1011 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1012 SetErrorCode(aFail->GetMessageString());
1016 //Make a Python command
1017 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
1018 << theObject << ", " << theOffset << ")";
1025 //=============================================================================
1029 //=============================================================================
1030 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
1031 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1035 if (theObject.IsNull()) return NULL;
1037 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1038 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1040 //Add a scale function
1041 Handle(GEOM_Function) aFunction =
1042 theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
1043 if (aFunction.IsNull()) return NULL;
1045 //Check if the function is set correctly
1046 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1049 GEOMImpl_IScale aTI (aFunction);
1050 aTI.SetShape(anOriginal);
1051 aTI.SetFactor(theFactor);
1053 // Set point argument
1054 if (!thePoint.IsNull()) {
1055 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1061 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1064 if (!GetSolver()->ComputeFunction(aFunction)) {
1065 SetErrorCode("Scale driver failed");
1069 catch (Standard_Failure) {
1070 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1071 SetErrorCode(aFail->GetMessageString());
1075 //Make a Python command
1076 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape("
1077 << theObject << ", " << thePoint << ", " << theFactor << ")";
1083 //=============================================================================
1087 //=============================================================================
1088 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1089 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1093 if (theObject.IsNull()) return NULL;
1095 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1096 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1098 //Add a new Copy object
1099 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1101 //Add a scale function
1102 Handle(GEOM_Function) aFunction =
1103 aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1104 if (aFunction.IsNull()) return NULL;
1106 //Check if the function is set correctly
1107 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1110 GEOMImpl_IScale aTI (aFunction);
1111 aTI.SetShape(anOriginal);
1112 aTI.SetFactor(theFactor);
1114 // Set point argument
1115 if (!thePoint.IsNull()) {
1116 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1122 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1125 if (!GetSolver()->ComputeFunction(aFunction)) {
1126 SetErrorCode("Scale driver failed");
1130 catch (Standard_Failure) {
1131 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1132 SetErrorCode(aFail->GetMessageString());
1136 //Make a Python command
1137 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1138 << theObject << ", " << thePoint << ", " << theFactor << ")";
1144 //=============================================================================
1146 * ScaleShapeAlongAxes
1148 //=============================================================================
1149 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
1150 Handle(GEOM_Object) thePoint,
1158 if (theObject.IsNull()) return NULL;
1160 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1161 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1163 //Add a scale function
1164 Handle(GEOM_Object) aCopy; //Add a new Copy object
1165 Handle(GEOM_Function) aFunction;
1167 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1168 aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
1171 aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES);
1173 if (aFunction.IsNull()) return NULL;
1175 //Check if the function is set correctly
1176 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1179 GEOMImpl_IScale aTI (aFunction);
1180 aTI.SetShape(anOriginal);
1181 aTI.SetFactorX(theFactorX);
1182 aTI.SetFactorY(theFactorY);
1183 aTI.SetFactorZ(theFactorZ);
1185 // Set point (optional argument)
1186 if (!thePoint.IsNull()) {
1187 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1193 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1196 if (!GetSolver()->ComputeFunction(aFunction)) {
1197 SetErrorCode("Scale driver failed");
1201 catch (Standard_Failure) {
1202 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1203 SetErrorCode(aFail->GetMessageString());
1209 //Make a Python command
1211 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleAlongAxes("
1212 << theObject << ", " << thePoint << ", "
1213 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1217 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShapeAlongAxes("
1218 << theObject << ", " << thePoint << ", "
1219 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1223 //=============================================================================
1227 //=============================================================================
1228 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1229 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1233 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1235 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1236 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1238 //Add a Position function
1239 Standard_Integer aType = POSITION_SHAPE;
1240 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1242 Handle(GEOM_Function) aFunction =
1243 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1244 if (aFunction.IsNull()) return NULL;
1246 //Check if the function is set correctly
1247 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1249 //Set operation arguments
1250 GEOMImpl_IPosition aTI (aFunction);
1251 aTI.SetShape(anOriginal);
1252 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1253 if (!theStartLCS.IsNull())
1254 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1256 //Compute the Position
1258 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1261 if (!GetSolver()->ComputeFunction(aFunction)) {
1262 SetErrorCode("Position driver failed");
1266 catch (Standard_Failure) {
1267 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1268 SetErrorCode(aFail->GetMessageString());
1272 //Make a Python command
1273 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
1274 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1280 //=============================================================================
1284 //=============================================================================
1285 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1286 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1290 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1292 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1293 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1295 //Add a new Copy object
1296 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1298 //Add a position function
1299 Standard_Integer aType = POSITION_SHAPE_COPY;
1300 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1302 Handle(GEOM_Function) aFunction =
1303 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1304 if (aFunction.IsNull()) return NULL;
1306 //Check if the function is set correctly
1307 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1309 GEOMImpl_IPosition aTI (aFunction);
1310 aTI.SetShape(anOriginal);
1311 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1312 if (!theStartLCS.IsNull())
1313 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1315 //Compute the position
1317 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1320 if (!GetSolver()->ComputeFunction(aFunction)) {
1321 SetErrorCode("Position driver failed");
1325 catch (Standard_Failure) {
1326 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1327 SetErrorCode(aFail->GetMessageString());
1331 //Make a Python command
1332 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1333 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1339 //=============================================================================
1343 //=============================================================================
1344 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath
1345 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath,
1346 double theDistance, bool theCopy, bool theReverse)
1350 if (theObject.IsNull() || thePath.IsNull()) return NULL;
1352 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1353 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1355 //Add a position function
1356 Handle(GEOM_Function) aFunction;
1357 Handle(GEOM_Object) aCopy;
1360 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1361 aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1364 aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1366 if (aFunction.IsNull()) return NULL;
1368 //Check if the function is set correctly
1369 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1371 GEOMImpl_IPosition aTI (aFunction);
1372 aTI.SetShape(anOriginal);
1373 aTI.SetPath(thePath->GetLastFunction());
1374 aTI.SetDistance(theDistance);
1375 aTI.SetReverse(theReverse);
1377 //Compute the position
1379 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1382 if (!GetSolver()->ComputeFunction(aFunction)) {
1383 SetErrorCode("Position driver failed");
1387 catch (Standard_Failure) {
1388 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1389 SetErrorCode(aFail->GetMessageString());
1393 //Make a Python command
1395 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.PositionAlongPath("
1396 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1401 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionAlongPath("
1402 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1408 //=============================================================================
1412 //=============================================================================
1413 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1414 Handle(GEOM_Object) theAxis,
1419 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1421 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1422 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1424 // Get last functions of the arguments
1425 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1427 //Add a rotate function
1428 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1430 if (aFunction.IsNull()) return NULL;
1432 //Check if the function is set correctly
1433 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1435 GEOMImpl_IRotate aRI(aFunction);
1437 aRI.SetOriginal(aLastFunction);
1438 aRI.SetAngle(theAngle);
1440 //Compute the translation
1442 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1445 if (!GetSolver()->ComputeFunction(aFunction)) {
1446 SetErrorCode("Rotate driver failed");
1450 catch (Standard_Failure) {
1451 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1452 SetErrorCode(aFail->GetMessageString());
1456 //Make a Python command
1457 GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject
1458 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1464 //=============================================================================
1468 //=============================================================================
1469 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
1473 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1475 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1476 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1478 //Add a new Copy object
1479 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1481 //Add a rotate function
1482 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1483 if (aFunction.IsNull()) return NULL;
1485 //Check if the function is set correctly
1486 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1488 GEOMImpl_IRotate aRI(aFunction);
1489 aRI.SetAxis(theAxis->GetLastFunction());
1490 aRI.SetOriginal(aLastFunction);
1491 aRI.SetAngle(theAngle);
1493 //Compute the translation
1495 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1498 if (!GetSolver()->ComputeFunction(aFunction)) {
1499 SetErrorCode("Rotate driver failed");
1503 catch (Standard_Failure) {
1504 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1505 SetErrorCode(aFail->GetMessageString());
1509 //Make a Python command
1510 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1511 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1517 //=============================================================================
1521 //=============================================================================
1522 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1523 Handle(GEOM_Object) theAxis,
1524 Standard_Integer theNbTimes)
1528 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1530 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1531 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1533 //Add a new Copy object
1534 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1536 //Add a rotate function
1537 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1538 if (aFunction.IsNull()) return NULL;
1540 //Check if the function is set correctly
1541 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1543 GEOMImpl_IRotate aRI(aFunction);
1544 aRI.SetOriginal(aLastFunction);
1545 aRI.SetAxis(theAxis->GetLastFunction());
1546 aRI.SetNbIter1(theNbTimes);
1548 //Compute the translation
1550 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1553 if (!GetSolver()->ComputeFunction(aFunction)) {
1554 SetErrorCode("Rotate driver failed");
1558 catch (Standard_Failure) {
1559 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1560 SetErrorCode(aFail->GetMessageString());
1564 //Make a Python command
1565 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
1566 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1572 //=============================================================================
1576 //=============================================================================
1577 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1578 Handle(GEOM_Object) theAxis,
1580 Standard_Integer theNbTimes1,
1582 Standard_Integer theNbTimes2)
1586 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1588 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1589 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1591 //Add a new Copy object
1592 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1594 //Add a rotate function
1595 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1596 if (aFunction.IsNull()) return NULL;
1598 //Check if the function is set correctly
1599 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1601 GEOMImpl_IRotate aRI(aFunction);
1602 aRI.SetAxis(theAxis->GetLastFunction());
1603 aRI.SetOriginal(aLastFunction);
1604 aRI.SetNbIter1(theNbTimes1);
1605 aRI.SetNbIter2(theNbTimes2);
1606 aRI.SetAngle(theAngle);
1607 aRI.SetStep(theStep);
1609 //Compute the translation
1611 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1614 if (!GetSolver()->ComputeFunction(aFunction)) {
1615 SetErrorCode("Rotate driver failed");
1619 catch (Standard_Failure) {
1620 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1621 SetErrorCode(aFail->GetMessageString());
1625 //Make a Python command
1626 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
1627 << theObject << ", " << theAxis << ", " << theAngle << ", "
1628 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
1634 //=============================================================================
1638 //=============================================================================
1639 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
1640 Handle(GEOM_Object) theCentPoint,
1641 Handle(GEOM_Object) thePoint1,
1642 Handle(GEOM_Object) thePoint2)
1646 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1648 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1649 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1651 // Get last functions of the arguments
1652 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
1653 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
1654 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
1657 //Add a rotate function
1658 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
1660 if (aFunction.IsNull()) return NULL;
1662 //Check if the function is set correctly
1663 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1665 GEOMImpl_IRotate aRI(aFunction);
1666 aRI.SetCentPoint(aCPF);
1667 aRI.SetPoint1(aP1F);
1668 aRI.SetPoint2(aP2F);
1669 aRI.SetOriginal(aLastFunction);
1671 //Compute the translation
1673 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1676 if (!GetSolver()->ComputeFunction(aFunction)) {
1677 SetErrorCode("Rotate driver failed");
1681 catch (Standard_Failure) {
1682 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1683 SetErrorCode(aFail->GetMessageString());
1687 //Make a Python command
1688 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
1689 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1695 //=============================================================================
1697 * RotateThreePointsCopy
1699 //=============================================================================
1700 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
1701 Handle(GEOM_Object) theCentPoint,
1702 Handle(GEOM_Object) thePoint1,
1703 Handle(GEOM_Object) thePoint2)
1707 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1709 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1710 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1712 //Add a new Copy object
1713 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1715 //Add a rotate function
1716 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
1717 if (aFunction.IsNull()) return NULL;
1719 //Check if the function is set correctly
1720 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1722 GEOMImpl_IRotate aRI(aFunction);
1723 aRI.SetCentPoint(theCentPoint->GetLastFunction());
1724 aRI.SetPoint1(thePoint1->GetLastFunction());
1725 aRI.SetPoint2(thePoint2->GetLastFunction());
1726 aRI.SetOriginal(aLastFunction);
1728 //Compute the translation
1730 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1733 if (!GetSolver()->ComputeFunction(aFunction)) {
1734 SetErrorCode("Rotate driver failed");
1738 catch (Standard_Failure) {
1739 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1740 SetErrorCode(aFail->GetMessageString());
1744 //Make a Python command
1745 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
1746 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";