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() || thePoint.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 // Get last functions of the arguments
1039 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1041 //Add a scale function
1042 Handle(GEOM_Function) aFunction =
1043 theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
1044 if (aFunction.IsNull()) return NULL;
1046 //Check if the function is set correctly
1047 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1049 GEOMImpl_IScale aTI (aFunction);
1050 aTI.SetShape(anOriginal);
1052 aTI.SetFactor(theFactor);
1056 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1059 if (!GetSolver()->ComputeFunction(aFunction)) {
1060 SetErrorCode("Scale driver failed");
1064 catch (Standard_Failure) {
1065 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1066 SetErrorCode(aFail->GetMessageString());
1070 //Make a Python command
1071 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape("
1072 << theObject << ", " << thePoint << ", " << theFactor << ")";
1078 //=============================================================================
1082 //=============================================================================
1083 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1084 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1088 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
1090 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1091 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1093 //Add a new Copy object
1094 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1096 //Add a scale function
1097 Handle(GEOM_Function) aFunction =
1098 aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1099 if (aFunction.IsNull()) return NULL;
1101 //Check if the function is set correctly
1102 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1104 GEOMImpl_IScale aTI (aFunction);
1105 aTI.SetShape(anOriginal);
1106 aTI.SetPoint(thePoint->GetLastFunction());
1107 aTI.SetFactor(theFactor);
1111 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1114 if (!GetSolver()->ComputeFunction(aFunction)) {
1115 SetErrorCode("Scale driver failed");
1119 catch (Standard_Failure) {
1120 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1121 SetErrorCode(aFail->GetMessageString());
1125 //Make a Python command
1126 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1127 << theObject << ", " << thePoint << ", " << theFactor << ")";
1133 //=============================================================================
1137 //=============================================================================
1138 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1139 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1143 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1145 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1146 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1148 //Add a Position function
1149 Standard_Integer aType = POSITION_SHAPE;
1150 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1152 Handle(GEOM_Function) aFunction =
1153 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1154 if (aFunction.IsNull()) return NULL;
1156 //Check if the function is set correctly
1157 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1159 //Set operation arguments
1160 GEOMImpl_IPosition aTI (aFunction);
1161 aTI.SetShape(anOriginal);
1162 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1163 if (!theStartLCS.IsNull())
1164 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1166 //Compute the Position
1168 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1171 if (!GetSolver()->ComputeFunction(aFunction)) {
1172 SetErrorCode("Position driver failed");
1176 catch (Standard_Failure) {
1177 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1178 SetErrorCode(aFail->GetMessageString());
1182 //Make a Python command
1183 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
1184 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1190 //=============================================================================
1194 //=============================================================================
1195 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1196 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1200 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1202 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1203 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1205 //Add a new Copy object
1206 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1208 //Add a position function
1209 Standard_Integer aType = POSITION_SHAPE_COPY;
1210 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1212 Handle(GEOM_Function) aFunction =
1213 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1214 if (aFunction.IsNull()) return NULL;
1216 //Check if the function is set correctly
1217 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1219 GEOMImpl_IPosition aTI (aFunction);
1220 aTI.SetShape(anOriginal);
1221 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1222 if (!theStartLCS.IsNull())
1223 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1225 //Compute the position
1227 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1230 if (!GetSolver()->ComputeFunction(aFunction)) {
1231 SetErrorCode("Position driver failed");
1235 catch (Standard_Failure) {
1236 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1237 SetErrorCode(aFail->GetMessageString());
1241 //Make a Python command
1242 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1243 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1249 //=============================================================================
1253 //=============================================================================
1254 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1255 Handle(GEOM_Object) theAxis,
1260 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1262 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1263 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1265 // Get last functions of the arguments
1266 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1268 //Add a rotate function
1269 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1271 if (aFunction.IsNull()) return NULL;
1273 //Check if the function is set correctly
1274 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1276 GEOMImpl_IRotate aRI(aFunction);
1278 aRI.SetOriginal(aLastFunction);
1279 aRI.SetAngle(theAngle);
1281 //Compute the translation
1283 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1286 if (!GetSolver()->ComputeFunction(aFunction)) {
1287 SetErrorCode("Rotate driver failed");
1291 catch (Standard_Failure) {
1292 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1293 SetErrorCode(aFail->GetMessageString());
1297 //Make a Python command
1298 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.Rotate(" << theObject
1299 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1305 //=============================================================================
1309 //=============================================================================
1310 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
1314 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1316 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1317 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1319 //Add a new Copy object
1320 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1322 //Add a rotate function
1323 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1324 if (aFunction.IsNull()) return NULL;
1326 //Check if the function is set correctly
1327 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1329 GEOMImpl_IRotate aRI(aFunction);
1330 aRI.SetAxis(theAxis->GetLastFunction());
1331 aRI.SetOriginal(aLastFunction);
1332 aRI.SetAngle(theAngle);
1334 //Compute the translation
1336 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1339 if (!GetSolver()->ComputeFunction(aFunction)) {
1340 SetErrorCode("Rotate driver failed");
1344 catch (Standard_Failure) {
1345 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1346 SetErrorCode(aFail->GetMessageString());
1350 //Make a Python command
1351 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1352 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1358 //=============================================================================
1362 //=============================================================================
1363 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1364 Handle(GEOM_Object) theAxis,
1365 Standard_Integer theNbTimes)
1369 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1371 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1372 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1374 //Add a new Copy object
1375 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1377 //Add a rotate function
1378 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1379 if (aFunction.IsNull()) return NULL;
1381 //Check if the function is set correctly
1382 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1384 GEOMImpl_IRotate aRI(aFunction);
1385 aRI.SetOriginal(aLastFunction);
1386 aRI.SetAxis(theAxis->GetLastFunction());
1387 aRI.SetNbIter1(theNbTimes);
1389 //Compute the translation
1391 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1394 if (!GetSolver()->ComputeFunction(aFunction)) {
1395 SetErrorCode("Rotate driver failed");
1399 catch (Standard_Failure) {
1400 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1401 SetErrorCode(aFail->GetMessageString());
1405 //Make a Python command
1406 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
1407 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1413 //=============================================================================
1417 //=============================================================================
1418 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1419 Handle(GEOM_Object) theAxis,
1421 Standard_Integer theNbTimes1,
1423 Standard_Integer theNbTimes2)
1427 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1429 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1430 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1432 //Add a new Copy object
1433 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1435 //Add a rotate function
1436 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1437 if (aFunction.IsNull()) return NULL;
1439 //Check if the function is set correctly
1440 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1442 GEOMImpl_IRotate aRI(aFunction);
1443 aRI.SetAxis(theAxis->GetLastFunction());
1444 aRI.SetOriginal(aLastFunction);
1445 aRI.SetNbIter1(theNbTimes1);
1446 aRI.SetNbIter2(theNbTimes2);
1447 aRI.SetAngle(theAngle);
1448 aRI.SetStep(theStep);
1450 //Compute the translation
1452 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1455 if (!GetSolver()->ComputeFunction(aFunction)) {
1456 SetErrorCode("Rotate driver failed");
1460 catch (Standard_Failure) {
1461 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1462 SetErrorCode(aFail->GetMessageString());
1466 //Make a Python command
1467 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
1468 << theObject << ", " << theAxis << ", " << theAngle << ", "
1469 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
1475 //=============================================================================
1479 //=============================================================================
1480 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
1481 Handle(GEOM_Object) theCentPoint,
1482 Handle(GEOM_Object) thePoint1,
1483 Handle(GEOM_Object) thePoint2)
1487 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1489 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1490 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1492 // Get last functions of the arguments
1493 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
1494 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
1495 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
1498 //Add a rotate function
1499 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
1501 if (aFunction.IsNull()) return NULL;
1503 //Check if the function is set correctly
1504 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1506 GEOMImpl_IRotate aRI(aFunction);
1507 aRI.SetCentPoint(aCPF);
1508 aRI.SetPoint1(aP1F);
1509 aRI.SetPoint2(aP2F);
1510 aRI.SetOriginal(aLastFunction);
1512 //Compute the translation
1514 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1517 if (!GetSolver()->ComputeFunction(aFunction)) {
1518 SetErrorCode("Rotate driver failed");
1522 catch (Standard_Failure) {
1523 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1524 SetErrorCode(aFail->GetMessageString());
1528 //Make a Python command
1529 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
1530 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1536 //=============================================================================
1538 * RotateThreePointsCopy
1540 //=============================================================================
1541 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
1542 Handle(GEOM_Object) theCentPoint,
1543 Handle(GEOM_Object) thePoint1,
1544 Handle(GEOM_Object) thePoint2)
1548 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1550 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1551 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1553 //Add a new Copy object
1554 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1556 //Add a rotate function
1557 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
1558 if (aFunction.IsNull()) return NULL;
1560 //Check if the function is set correctly
1561 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1563 GEOMImpl_IRotate aRI(aFunction);
1564 aRI.SetCentPoint(theCentPoint->GetLastFunction());
1565 aRI.SetPoint1(thePoint1->GetLastFunction());
1566 aRI.SetPoint2(thePoint2->GetLastFunction());
1567 aRI.SetOriginal(aLastFunction);
1569 //Compute the translation
1571 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1574 if (!GetSolver()->ComputeFunction(aFunction)) {
1575 SetErrorCode("Rotate driver failed");
1579 catch (Standard_Failure) {
1580 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1581 SetErrorCode(aFail->GetMessageString());
1585 //Make a Python command
1586 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
1587 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";