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.TrsfOp.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.TrsfOp.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) << "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::Rotate (Handle(GEOM_Object) theObject,
1345 Handle(GEOM_Object) theAxis,
1350 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1352 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1353 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1355 // Get last functions of the arguments
1356 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1358 //Add a rotate function
1359 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1361 if (aFunction.IsNull()) return NULL;
1363 //Check if the function is set correctly
1364 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1366 GEOMImpl_IRotate aRI(aFunction);
1368 aRI.SetOriginal(aLastFunction);
1369 aRI.SetAngle(theAngle);
1371 //Compute the translation
1373 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1376 if (!GetSolver()->ComputeFunction(aFunction)) {
1377 SetErrorCode("Rotate driver failed");
1381 catch (Standard_Failure) {
1382 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1383 SetErrorCode(aFail->GetMessageString());
1387 //Make a Python command
1388 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.Rotate(" << theObject
1389 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1395 //=============================================================================
1399 //=============================================================================
1400 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
1404 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1406 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1407 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1409 //Add a new Copy object
1410 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1412 //Add a rotate function
1413 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1414 if (aFunction.IsNull()) return NULL;
1416 //Check if the function is set correctly
1417 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1419 GEOMImpl_IRotate aRI(aFunction);
1420 aRI.SetAxis(theAxis->GetLastFunction());
1421 aRI.SetOriginal(aLastFunction);
1422 aRI.SetAngle(theAngle);
1424 //Compute the translation
1426 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1429 if (!GetSolver()->ComputeFunction(aFunction)) {
1430 SetErrorCode("Rotate driver failed");
1434 catch (Standard_Failure) {
1435 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1436 SetErrorCode(aFail->GetMessageString());
1440 //Make a Python command
1441 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1442 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1448 //=============================================================================
1452 //=============================================================================
1453 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1454 Handle(GEOM_Object) theAxis,
1455 Standard_Integer theNbTimes)
1459 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1461 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1462 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1464 //Add a new Copy object
1465 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1467 //Add a rotate function
1468 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1469 if (aFunction.IsNull()) return NULL;
1471 //Check if the function is set correctly
1472 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1474 GEOMImpl_IRotate aRI(aFunction);
1475 aRI.SetOriginal(aLastFunction);
1476 aRI.SetAxis(theAxis->GetLastFunction());
1477 aRI.SetNbIter1(theNbTimes);
1479 //Compute the translation
1481 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1484 if (!GetSolver()->ComputeFunction(aFunction)) {
1485 SetErrorCode("Rotate driver failed");
1489 catch (Standard_Failure) {
1490 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1491 SetErrorCode(aFail->GetMessageString());
1495 //Make a Python command
1496 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
1497 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1503 //=============================================================================
1507 //=============================================================================
1508 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1509 Handle(GEOM_Object) theAxis,
1511 Standard_Integer theNbTimes1,
1513 Standard_Integer theNbTimes2)
1517 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1519 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1520 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1522 //Add a new Copy object
1523 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1525 //Add a rotate function
1526 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1527 if (aFunction.IsNull()) return NULL;
1529 //Check if the function is set correctly
1530 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1532 GEOMImpl_IRotate aRI(aFunction);
1533 aRI.SetAxis(theAxis->GetLastFunction());
1534 aRI.SetOriginal(aLastFunction);
1535 aRI.SetNbIter1(theNbTimes1);
1536 aRI.SetNbIter2(theNbTimes2);
1537 aRI.SetAngle(theAngle);
1538 aRI.SetStep(theStep);
1540 //Compute the translation
1542 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1545 if (!GetSolver()->ComputeFunction(aFunction)) {
1546 SetErrorCode("Rotate driver failed");
1550 catch (Standard_Failure) {
1551 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1552 SetErrorCode(aFail->GetMessageString());
1556 //Make a Python command
1557 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
1558 << theObject << ", " << theAxis << ", " << theAngle << ", "
1559 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
1565 //=============================================================================
1569 //=============================================================================
1570 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
1571 Handle(GEOM_Object) theCentPoint,
1572 Handle(GEOM_Object) thePoint1,
1573 Handle(GEOM_Object) thePoint2)
1577 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1579 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1580 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1582 // Get last functions of the arguments
1583 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
1584 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
1585 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
1588 //Add a rotate function
1589 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
1591 if (aFunction.IsNull()) return NULL;
1593 //Check if the function is set correctly
1594 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1596 GEOMImpl_IRotate aRI(aFunction);
1597 aRI.SetCentPoint(aCPF);
1598 aRI.SetPoint1(aP1F);
1599 aRI.SetPoint2(aP2F);
1600 aRI.SetOriginal(aLastFunction);
1602 //Compute the translation
1604 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1607 if (!GetSolver()->ComputeFunction(aFunction)) {
1608 SetErrorCode("Rotate driver failed");
1612 catch (Standard_Failure) {
1613 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1614 SetErrorCode(aFail->GetMessageString());
1618 //Make a Python command
1619 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
1620 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1626 //=============================================================================
1628 * RotateThreePointsCopy
1630 //=============================================================================
1631 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
1632 Handle(GEOM_Object) theCentPoint,
1633 Handle(GEOM_Object) thePoint1,
1634 Handle(GEOM_Object) thePoint2)
1638 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1640 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1641 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1643 //Add a new Copy object
1644 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1646 //Add a rotate function
1647 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
1648 if (aFunction.IsNull()) return NULL;
1650 //Check if the function is set correctly
1651 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1653 GEOMImpl_IRotate aRI(aFunction);
1654 aRI.SetCentPoint(theCentPoint->GetLastFunction());
1655 aRI.SetPoint1(thePoint1->GetLastFunction());
1656 aRI.SetPoint2(thePoint2->GetLastFunction());
1657 aRI.SetOriginal(aLastFunction);
1659 //Compute the translation
1661 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1664 if (!GetSolver()->ComputeFunction(aFunction)) {
1665 SetErrorCode("Rotate driver failed");
1669 catch (Standard_Failure) {
1670 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1671 SetErrorCode(aFail->GetMessageString());
1675 //Make a Python command
1676 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
1677 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";