1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Standard_Stream.hxx>
22 #include <GEOMImpl_ITransformOperations.hxx>
24 #include "utilities.h"
26 #include <Utils_ExceptHandlers.hxx>
28 #include <TFunction_DriverTable.hxx>
29 #include <TFunction_Driver.hxx>
30 #include <TFunction_Logbook.hxx>
31 #include <TDF_Tool.hxx>
33 #include <GEOM_Function.hxx>
34 #include <GEOM_PythonDump.hxx>
36 #include <GEOMImpl_TranslateDriver.hxx>
37 #include <GEOMImpl_MirrorDriver.hxx>
38 #include <GEOMImpl_OffsetDriver.hxx>
39 #include <GEOMImpl_ScaleDriver.hxx>
40 #include <GEOMImpl_RotateDriver.hxx>
41 #include <GEOMImpl_PositionDriver.hxx>
43 #include <GEOMImpl_ITranslate.hxx>
44 #include <GEOMImpl_IMirror.hxx>
45 #include <GEOMImpl_IOffset.hxx>
46 #include <GEOMImpl_IScale.hxx>
47 #include <GEOMImpl_IRotate.hxx>
48 #include <GEOMImpl_IPosition.hxx>
50 #include <GEOMImpl_Types.hxx>
52 #include <Standard_Failure.hxx>
53 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
55 //=============================================================================
59 //=============================================================================
61 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
62 : GEOM_IOperations(theEngine, theDocID)
64 MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
67 //=============================================================================
71 //=============================================================================
73 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
75 MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
79 //=============================================================================
83 //=============================================================================
84 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
85 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
89 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
91 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
92 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
94 // Get last functions of the arguments
95 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
96 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
98 //Add a translate function
99 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
101 if (aFunction.IsNull()) return NULL;
103 //Check if the function is set correctly
104 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
106 GEOMImpl_ITranslate aTI (aFunction);
109 aTI.SetOriginal(aLastFunction);
111 //Compute the translation
113 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
116 if (!GetSolver()->ComputeFunction(aFunction)) {
117 SetErrorCode("Translation driver failed");
121 catch (Standard_Failure) {
122 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
123 SetErrorCode(aFail->GetMessageString());
127 //Make a Python command
128 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateTwoPoints("
129 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
135 //=============================================================================
139 //=============================================================================
140 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
141 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
145 if (theObject.IsNull()) return NULL;
147 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
148 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
150 //Add a translate function
151 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
153 if (aFunction.IsNull()) return NULL;
155 //Check if the function is set correctly
156 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
158 GEOMImpl_ITranslate aTI(aFunction);
162 aTI.SetOriginal(aLastFunction);
164 //Compute the translation
166 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
169 if (!GetSolver()->ComputeFunction(aFunction)) {
170 SetErrorCode("Translation driver failed");
174 catch (Standard_Failure) {
175 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
176 SetErrorCode(aFail->GetMessageString());
180 //Make a Python command
181 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateDXDYDZ("
182 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
189 //=============================================================================
191 * TranslateTwoPointsCopy
193 //=============================================================================
194 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
195 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
199 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
201 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
202 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
204 //Add a new Copy object
205 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
207 //Add a translate function
208 Handle(GEOM_Function) aFunction =
209 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
211 //Check if the function is set correctly
212 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
214 GEOMImpl_ITranslate aTI(aFunction);
215 aTI.SetPoint1(thePoint1->GetLastFunction());
216 aTI.SetPoint2(thePoint2->GetLastFunction());
217 //aTI.SetShape(theObject->GetValue());
218 aTI.SetOriginal(aLastFunction);
220 //Compute the translation
222 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
225 if (!GetSolver()->ComputeFunction(aFunction)) {
226 SetErrorCode("Translation driver failed");
230 catch (Standard_Failure) {
231 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
232 SetErrorCode(aFail->GetMessageString());
236 //Make a Python command
237 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
238 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
244 //=============================================================================
246 * TranslateDXDYDZCopy
248 //=============================================================================
249 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
250 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
254 if (theObject.IsNull()) return NULL;
256 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
257 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
259 //Add a new Copy object
260 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
262 //Add a translate function
263 Handle(GEOM_Function) aFunction =
264 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
266 //Check if the function is set correctly
267 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
269 GEOMImpl_ITranslate aTI(aFunction);
273 aTI.SetOriginal(aLastFunction);
275 //Compute the translation
277 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
280 if (!GetSolver()->ComputeFunction(aFunction)) {
281 SetErrorCode("Translation driver failed");
285 catch (Standard_Failure) {
286 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
287 SetErrorCode(aFail->GetMessageString());
291 //Make a Python command
292 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
293 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
300 //=============================================================================
304 //=============================================================================
305 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
306 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
310 if (theObject.IsNull() || theVector.IsNull()) return NULL;
312 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
313 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
315 // Get last functions of the arguments
316 Handle(GEOM_Function) aVF = theVector->GetLastFunction();
318 //Add a translate function
319 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
321 if (aFunction.IsNull()) return NULL;
323 //Check if the function is set correctly
324 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
326 GEOMImpl_ITranslate aTI (aFunction);
328 aTI.SetOriginal(aLastFunction);
330 //Compute the translation
332 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
335 if (!GetSolver()->ComputeFunction(aFunction)) {
336 SetErrorCode("Translation driver failed");
340 catch (Standard_Failure) {
341 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
342 SetErrorCode(aFail->GetMessageString());
346 //Make a Python command
347 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVector("
348 << theObject << ", " << theVector << ")";
353 //=============================================================================
355 * TranslateVectorCopy
357 //=============================================================================
358 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
359 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
363 if (theObject.IsNull() || theVector.IsNull()) return NULL;
365 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
366 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
368 //Add a new Copy object
369 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
371 //Add a translate function
372 Handle(GEOM_Function) aFunction =
373 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
375 //Check if the function is set correctly
376 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
378 GEOMImpl_ITranslate aTI(aFunction);
379 aTI.SetVector(theVector->GetLastFunction());
380 // aTI.SetShape(theObject->GetValue());
381 aTI.SetOriginal(aLastFunction);
383 //Compute the translation
385 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
388 if (!GetSolver()->ComputeFunction(aFunction)) {
389 SetErrorCode("Translation driver failed");
393 catch (Standard_Failure) {
394 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
395 SetErrorCode(aFail->GetMessageString());
399 //Make a Python command
400 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
401 << theObject << ", " << theVector << ")";
407 //=============================================================================
409 * TranslateVectorDistance
411 //=============================================================================
412 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
413 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy)
417 if (theObject.IsNull() || theVector.IsNull()) return NULL;
419 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
420 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
422 Handle(GEOM_Object) aCopy; //Add a new Copy object
423 Handle(GEOM_Function) aFunction;
425 //Add a translate function
427 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
428 aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
431 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
433 if (aFunction.IsNull()) return NULL;
435 //Check if the function is set correctly
436 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
438 GEOMImpl_ITranslate aTI(aFunction);
439 aTI.SetVector(theVector->GetLastFunction());
440 aTI.SetDistance(theDistance);
441 // aTI.SetShape(theObject->GetValue());
442 aTI.SetOriginal(aLastFunction);
444 //Compute the translation
446 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
449 if (!GetSolver()->ComputeFunction(aFunction)) {
450 SetErrorCode("Translation driver failed");
454 catch (Standard_Failure) {
455 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
456 SetErrorCode(aFail->GetMessageString());
460 //Make a Python command
462 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance("
463 << theObject << ", " << theVector << ", " << theDistance << ")";
468 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVectorDistance("
469 << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")";
474 //=============================================================================
478 //=============================================================================
479 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
480 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
481 double theStep, Standard_Integer theNbTimes)
485 if (theObject.IsNull() || theVector.IsNull()) return NULL;
487 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
488 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
490 //Add a new Copy object
491 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
493 //Add a translate function
494 Handle(GEOM_Function) aFunction =
495 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
497 //Check if the function is set correctly
498 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
500 GEOMImpl_ITranslate aTI(aFunction);
501 aTI.SetVector(theVector->GetLastFunction());
502 aTI.SetOriginal(aLastFunction);
503 aTI.SetStep1(theStep);
504 aTI.SetNbIter1(theNbTimes);
506 //Compute the translation
508 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
511 if (!GetSolver()->ComputeFunction(aFunction)) {
512 SetErrorCode("Translation driver failed");
516 catch (Standard_Failure) {
517 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
518 SetErrorCode(aFail->GetMessageString());
522 //Make a Python command
523 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
524 << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
530 //=============================================================================
534 //=============================================================================
535 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
536 Handle(GEOM_Object) theVector,
538 Standard_Integer theNbTimes1,
539 Handle(GEOM_Object) theVector2,
541 Standard_Integer theNbTimes2)
545 if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL;
547 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
548 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
550 //Add a new Copy object
551 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
553 //Add a translate function
554 Handle(GEOM_Function) aFunction =
555 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
557 //Check if the function is set correctly
558 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
560 GEOMImpl_ITranslate aTI(aFunction);
561 aTI.SetVector(theVector->GetLastFunction());
562 aTI.SetVector2(theVector2->GetLastFunction());
563 aTI.SetOriginal(aLastFunction);
564 aTI.SetStep1(theStep1);
565 aTI.SetNbIter1(theNbTimes1);
566 aTI.SetStep2(theStep2);
567 aTI.SetNbIter2(theNbTimes2);
569 //Compute the translation
571 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
574 if (!GetSolver()->ComputeFunction(aFunction)) {
575 SetErrorCode("Translation driver failed");
579 catch (Standard_Failure) {
580 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
581 SetErrorCode(aFail->GetMessageString());
585 //Make a Python command
586 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
587 << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1
588 << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
595 //=============================================================================
599 //=============================================================================
600 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
601 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
605 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
607 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
608 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
610 // Get last functions of the arguments
611 Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
613 //Add a mirror function
614 Handle(GEOM_Function) aFunction =
615 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
616 if (aFunction.IsNull()) return NULL;
618 //Check if the function is set correctly
619 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
621 GEOMImpl_IMirror aTI (aFunction);
623 aTI.SetOriginal(aLastFunction);
627 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
630 if (!GetSolver()->ComputeFunction(aFunction)) {
631 SetErrorCode("Mirror driver failed");
635 catch (Standard_Failure) {
636 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
637 SetErrorCode(aFail->GetMessageString());
641 //Make a Python command
642 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane("
643 << theObject << ", " << thePlane << ")";
649 //=============================================================================
653 //=============================================================================
654 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
655 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
659 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
661 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
662 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
664 //Add a new Copy object
665 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
667 //Add a mirror function
668 Handle(GEOM_Function) aFunction =
669 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
671 //Check if the function is set correctly
672 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
674 GEOMImpl_IMirror aTI (aFunction);
675 aTI.SetPlane(thePlane->GetLastFunction());
676 aTI.SetOriginal(aLastFunction);
680 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
683 if (!GetSolver()->ComputeFunction(aFunction)) {
684 SetErrorCode("Mirror driver failed");
688 catch (Standard_Failure) {
689 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
690 SetErrorCode(aFail->GetMessageString());
694 //Make a Python command
695 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
696 << theObject << ", " << thePlane << ")";
702 //=============================================================================
706 //=============================================================================
707 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
708 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
712 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
714 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
715 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
717 // Get last functions of the arguments
718 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
720 //Add a mirror function
721 Handle(GEOM_Function) aFunction =
722 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
723 if (aFunction.IsNull()) return NULL;
725 //Check if the function is set correctly
726 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
728 GEOMImpl_IMirror aTI (aFunction);
730 aTI.SetOriginal(aLastFunction);
734 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
737 if (!GetSolver()->ComputeFunction(aFunction)) {
738 SetErrorCode("Mirror driver failed");
742 catch (Standard_Failure) {
743 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
744 SetErrorCode(aFail->GetMessageString());
748 //Make a Python command
749 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint("
750 << theObject << ", " << thePoint << ")";
756 //=============================================================================
760 //=============================================================================
761 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
762 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
766 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
768 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
769 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
771 //Add a new Copy object
772 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
774 //Add a mirror function
775 Handle(GEOM_Function) aFunction =
776 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
778 //Check if the function is set correctly
779 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
781 GEOMImpl_IMirror aTI (aFunction);
782 aTI.SetPoint(thePoint->GetLastFunction());
783 aTI.SetOriginal(aLastFunction);
787 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
790 if (!GetSolver()->ComputeFunction(aFunction)) {
791 SetErrorCode("Mirror driver failed");
795 catch (Standard_Failure) {
796 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
797 SetErrorCode(aFail->GetMessageString());
801 //Make a Python command
802 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
803 << theObject << ", " << thePoint << ")";
809 //=============================================================================
813 //=============================================================================
814 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
815 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
819 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
821 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
822 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
824 // Get last functions of the arguments
825 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
827 //Add a mirror function
828 Handle(GEOM_Function) aFunction =
829 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
830 if (aFunction.IsNull()) return NULL;
832 //Check if the function is set correctly
833 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
835 GEOMImpl_IMirror aTI (aFunction);
837 aTI.SetOriginal(aLastFunction);
841 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
844 if (!GetSolver()->ComputeFunction(aFunction)) {
845 SetErrorCode("Mirror driver failed");
849 catch (Standard_Failure) {
850 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
851 SetErrorCode(aFail->GetMessageString());
855 //Make a Python command
856 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis("
857 << theObject << ", " << theAxis << ")";
863 //=============================================================================
867 //=============================================================================
868 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
869 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
873 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
875 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
876 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
878 //Add a new Copy object
879 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
881 //Add a mirror function
882 Handle(GEOM_Function) aFunction =
883 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
885 //Check if the function is set correctly
886 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
888 GEOMImpl_IMirror aTI (aFunction);
889 aTI.SetAxis(theAxis->GetLastFunction());
890 aTI.SetOriginal(aLastFunction);
894 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
897 if (!GetSolver()->ComputeFunction(aFunction)) {
898 SetErrorCode("Mirror driver failed");
902 catch (Standard_Failure) {
903 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
904 SetErrorCode(aFail->GetMessageString());
908 //Make a Python command
909 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
910 << theObject << ", " << theAxis << ")";
917 //=============================================================================
921 //=============================================================================
922 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
923 (Handle(GEOM_Object) theObject, double theOffset)
927 if (theObject.IsNull()) return NULL;
929 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
930 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
932 //Add a new Offset function
933 Handle(GEOM_Function) aFunction =
934 theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
935 if (aFunction.IsNull()) return NULL;
937 //Check if the function is set correctly
938 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
940 GEOMImpl_IOffset aTI (aFunction);
941 aTI.SetShape(anOriginal);
942 aTI.SetValue(theOffset);
946 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
949 if (!GetSolver()->ComputeFunction(aFunction)) {
950 SetErrorCode("Offset driver failed");
954 catch (Standard_Failure) {
955 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
956 SetErrorCode(aFail->GetMessageString());
960 //Make a Python command
961 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape("
962 << theObject << ", " << theOffset << ")";
968 //=============================================================================
972 //=============================================================================
973 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
974 (Handle(GEOM_Object) theObject, double theOffset)
978 if (theObject.IsNull()) return NULL;
980 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
981 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
983 //Add a new Copy object
984 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
986 //Add a new Offset function
987 Handle(GEOM_Function) aFunction =
988 aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
989 if (aFunction.IsNull()) return NULL;
991 //Check if the function is set correctly
992 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
994 GEOMImpl_IOffset aTI (aFunction);
995 aTI.SetShape(anOriginal);
996 aTI.SetValue(theOffset);
1000 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1003 if (!GetSolver()->ComputeFunction(aFunction)) {
1004 SetErrorCode("Offset driver failed");
1008 catch (Standard_Failure) {
1009 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1010 SetErrorCode(aFail->GetMessageString());
1014 //Make a Python command
1015 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
1016 << theObject << ", " << theOffset << ")";
1023 //=============================================================================
1027 //=============================================================================
1028 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
1029 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1033 if (theObject.IsNull()) return NULL;
1035 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1036 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1038 //Add a scale function
1039 Handle(GEOM_Function) aFunction =
1040 theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
1041 if (aFunction.IsNull()) return NULL;
1043 //Check if the function is set correctly
1044 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1047 GEOMImpl_IScale aTI (aFunction);
1048 aTI.SetShape(anOriginal);
1049 aTI.SetFactor(theFactor);
1051 // Set point argument
1052 if (!thePoint.IsNull()) {
1053 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1059 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1062 if (!GetSolver()->ComputeFunction(aFunction)) {
1063 SetErrorCode("Scale driver failed");
1067 catch (Standard_Failure) {
1068 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1069 SetErrorCode(aFail->GetMessageString());
1073 //Make a Python command
1074 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape("
1075 << theObject << ", " << thePoint << ", " << theFactor << ")";
1081 //=============================================================================
1085 //=============================================================================
1086 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1087 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1091 if (theObject.IsNull()) return NULL;
1093 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1094 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1096 //Add a new Copy object
1097 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1099 //Add a scale function
1100 Handle(GEOM_Function) aFunction =
1101 aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1102 if (aFunction.IsNull()) return NULL;
1104 //Check if the function is set correctly
1105 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1108 GEOMImpl_IScale aTI (aFunction);
1109 aTI.SetShape(anOriginal);
1110 aTI.SetFactor(theFactor);
1112 // Set point argument
1113 if (!thePoint.IsNull()) {
1114 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1120 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1123 if (!GetSolver()->ComputeFunction(aFunction)) {
1124 SetErrorCode("Scale driver failed");
1128 catch (Standard_Failure) {
1129 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1130 SetErrorCode(aFail->GetMessageString());
1134 //Make a Python command
1135 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1136 << theObject << ", " << thePoint << ", " << theFactor << ")";
1142 //=============================================================================
1144 * ScaleShapeAlongAxes
1146 //=============================================================================
1147 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
1148 Handle(GEOM_Object) thePoint,
1156 if (theObject.IsNull()) return NULL;
1158 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1159 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1161 //Add a scale function
1162 Handle(GEOM_Object) aCopy; //Add a new Copy object
1163 Handle(GEOM_Function) aFunction;
1165 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1166 aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
1169 aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES);
1171 if (aFunction.IsNull()) return NULL;
1173 //Check if the function is set correctly
1174 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1177 GEOMImpl_IScale aTI (aFunction);
1178 aTI.SetShape(anOriginal);
1179 aTI.SetFactorX(theFactorX);
1180 aTI.SetFactorY(theFactorY);
1181 aTI.SetFactorZ(theFactorZ);
1183 // Set point (optional argument)
1184 if (!thePoint.IsNull()) {
1185 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1191 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1194 if (!GetSolver()->ComputeFunction(aFunction)) {
1195 SetErrorCode("Scale driver failed");
1199 catch (Standard_Failure) {
1200 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1201 SetErrorCode(aFail->GetMessageString());
1207 //Make a Python command
1209 GEOM::TPythonDump(aFunction) << "geompy.MakeScaleAlongAxes("
1210 << theObject << ", " << thePoint << ", "
1211 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1215 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShapeAlongAxes("
1216 << theObject << ", " << thePoint << ", "
1217 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1221 //=============================================================================
1225 //=============================================================================
1226 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1227 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1231 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1233 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1234 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1236 //Add a Position function
1237 Standard_Integer aType = POSITION_SHAPE;
1238 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1240 Handle(GEOM_Function) aFunction =
1241 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1242 if (aFunction.IsNull()) return NULL;
1244 //Check if the function is set correctly
1245 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1247 //Set operation arguments
1248 GEOMImpl_IPosition aTI (aFunction);
1249 aTI.SetShape(anOriginal);
1250 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1251 if (!theStartLCS.IsNull())
1252 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1254 //Compute the Position
1256 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1259 if (!GetSolver()->ComputeFunction(aFunction)) {
1260 SetErrorCode("Position driver failed");
1264 catch (Standard_Failure) {
1265 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1266 SetErrorCode(aFail->GetMessageString());
1270 //Make a Python command
1271 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
1272 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1278 //=============================================================================
1282 //=============================================================================
1283 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1284 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1288 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1290 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1291 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1293 //Add a new Copy object
1294 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1296 //Add a position function
1297 Standard_Integer aType = POSITION_SHAPE_COPY;
1298 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1300 Handle(GEOM_Function) aFunction =
1301 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1302 if (aFunction.IsNull()) return NULL;
1304 //Check if the function is set correctly
1305 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1307 GEOMImpl_IPosition aTI (aFunction);
1308 aTI.SetShape(anOriginal);
1309 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1310 if (!theStartLCS.IsNull())
1311 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1313 //Compute the position
1315 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1318 if (!GetSolver()->ComputeFunction(aFunction)) {
1319 SetErrorCode("Position driver failed");
1323 catch (Standard_Failure) {
1324 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1325 SetErrorCode(aFail->GetMessageString());
1329 //Make a Python command
1330 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1331 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1337 //=============================================================================
1341 //=============================================================================
1342 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1343 Handle(GEOM_Object) theAxis,
1348 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1350 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1351 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1353 // Get last functions of the arguments
1354 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1356 //Add a rotate function
1357 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1359 if (aFunction.IsNull()) return NULL;
1361 //Check if the function is set correctly
1362 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1364 GEOMImpl_IRotate aRI(aFunction);
1366 aRI.SetOriginal(aLastFunction);
1367 aRI.SetAngle(theAngle);
1369 //Compute the translation
1371 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1374 if (!GetSolver()->ComputeFunction(aFunction)) {
1375 SetErrorCode("Rotate driver failed");
1379 catch (Standard_Failure) {
1380 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1381 SetErrorCode(aFail->GetMessageString());
1385 //Make a Python command
1386 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.Rotate(" << theObject
1387 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1393 //=============================================================================
1397 //=============================================================================
1398 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
1402 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1404 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1405 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1407 //Add a new Copy object
1408 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1410 //Add a rotate function
1411 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1412 if (aFunction.IsNull()) return NULL;
1414 //Check if the function is set correctly
1415 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1417 GEOMImpl_IRotate aRI(aFunction);
1418 aRI.SetAxis(theAxis->GetLastFunction());
1419 aRI.SetOriginal(aLastFunction);
1420 aRI.SetAngle(theAngle);
1422 //Compute the translation
1424 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1427 if (!GetSolver()->ComputeFunction(aFunction)) {
1428 SetErrorCode("Rotate driver failed");
1432 catch (Standard_Failure) {
1433 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1434 SetErrorCode(aFail->GetMessageString());
1438 //Make a Python command
1439 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1440 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1446 //=============================================================================
1450 //=============================================================================
1451 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1452 Handle(GEOM_Object) theAxis,
1453 Standard_Integer theNbTimes)
1457 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1459 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1460 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1462 //Add a new Copy object
1463 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1465 //Add a rotate function
1466 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1467 if (aFunction.IsNull()) return NULL;
1469 //Check if the function is set correctly
1470 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1472 GEOMImpl_IRotate aRI(aFunction);
1473 aRI.SetOriginal(aLastFunction);
1474 aRI.SetAxis(theAxis->GetLastFunction());
1475 aRI.SetNbIter1(theNbTimes);
1477 //Compute the translation
1479 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1482 if (!GetSolver()->ComputeFunction(aFunction)) {
1483 SetErrorCode("Rotate driver failed");
1487 catch (Standard_Failure) {
1488 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1489 SetErrorCode(aFail->GetMessageString());
1493 //Make a Python command
1494 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
1495 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1501 //=============================================================================
1505 //=============================================================================
1506 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1507 Handle(GEOM_Object) theAxis,
1509 Standard_Integer theNbTimes1,
1511 Standard_Integer theNbTimes2)
1515 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1517 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1518 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1520 //Add a new Copy object
1521 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1523 //Add a rotate function
1524 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1525 if (aFunction.IsNull()) return NULL;
1527 //Check if the function is set correctly
1528 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1530 GEOMImpl_IRotate aRI(aFunction);
1531 aRI.SetAxis(theAxis->GetLastFunction());
1532 aRI.SetOriginal(aLastFunction);
1533 aRI.SetNbIter1(theNbTimes1);
1534 aRI.SetNbIter2(theNbTimes2);
1535 aRI.SetAngle(theAngle);
1536 aRI.SetStep(theStep);
1538 //Compute the translation
1540 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1543 if (!GetSolver()->ComputeFunction(aFunction)) {
1544 SetErrorCode("Rotate driver failed");
1548 catch (Standard_Failure) {
1549 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1550 SetErrorCode(aFail->GetMessageString());
1554 //Make a Python command
1555 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
1556 << theObject << ", " << theAxis << ", " << theAngle << ", "
1557 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
1563 //=============================================================================
1567 //=============================================================================
1568 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
1569 Handle(GEOM_Object) theCentPoint,
1570 Handle(GEOM_Object) thePoint1,
1571 Handle(GEOM_Object) thePoint2)
1575 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1577 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1578 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1580 // Get last functions of the arguments
1581 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
1582 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
1583 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
1586 //Add a rotate function
1587 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
1589 if (aFunction.IsNull()) return NULL;
1591 //Check if the function is set correctly
1592 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1594 GEOMImpl_IRotate aRI(aFunction);
1595 aRI.SetCentPoint(aCPF);
1596 aRI.SetPoint1(aP1F);
1597 aRI.SetPoint2(aP2F);
1598 aRI.SetOriginal(aLastFunction);
1600 //Compute the translation
1602 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1605 if (!GetSolver()->ComputeFunction(aFunction)) {
1606 SetErrorCode("Rotate driver failed");
1610 catch (Standard_Failure) {
1611 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1612 SetErrorCode(aFail->GetMessageString());
1616 //Make a Python command
1617 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
1618 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1624 //=============================================================================
1626 * RotateThreePointsCopy
1628 //=============================================================================
1629 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
1630 Handle(GEOM_Object) theCentPoint,
1631 Handle(GEOM_Object) thePoint1,
1632 Handle(GEOM_Object) thePoint2)
1636 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1638 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1639 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1641 //Add a new Copy object
1642 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1644 //Add a rotate function
1645 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
1646 if (aFunction.IsNull()) return NULL;
1648 //Check if the function is set correctly
1649 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1651 GEOMImpl_IRotate aRI(aFunction);
1652 aRI.SetCentPoint(theCentPoint->GetLastFunction());
1653 aRI.SetPoint1(thePoint1->GetLastFunction());
1654 aRI.SetPoint2(thePoint2->GetLastFunction());
1655 aRI.SetOriginal(aLastFunction);
1657 //Compute the translation
1659 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1662 if (!GetSolver()->ComputeFunction(aFunction)) {
1663 SetErrorCode("Rotate driver failed");
1667 catch (Standard_Failure) {
1668 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1669 SetErrorCode(aFail->GetMessageString());
1673 //Make a Python command
1674 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
1675 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";