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 << ")";
354 //=============================================================================
356 * TranslateVectorCopy
358 //=============================================================================
359 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
360 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
364 if (theObject.IsNull() || theVector.IsNull()) return NULL;
366 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
367 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
369 //Add a new Copy object
370 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
372 //Add a translate function
373 Handle(GEOM_Function) aFunction =
374 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
376 //Check if the function is set correctly
377 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
379 GEOMImpl_ITranslate aTI(aFunction);
380 aTI.SetVector(theVector->GetLastFunction());
381 // aTI.SetShape(theObject->GetValue());
382 aTI.SetOriginal(aLastFunction);
384 //Compute the translation
386 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
389 if (!GetSolver()->ComputeFunction(aFunction)) {
390 SetErrorCode("Translation driver failed");
394 catch (Standard_Failure) {
395 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
396 SetErrorCode(aFail->GetMessageString());
400 //Make a Python command
401 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
402 << theObject << ", " << theVector << ")";
408 //=============================================================================
412 //=============================================================================
413 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
414 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
415 double theStep, Standard_Integer theNbTimes)
419 if (theObject.IsNull() || theVector.IsNull()) return NULL;
421 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
422 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
424 //Add a new Copy object
425 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
427 //Add a translate function
428 Handle(GEOM_Function) aFunction =
429 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
431 //Check if the function is set correctly
432 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
434 GEOMImpl_ITranslate aTI(aFunction);
435 aTI.SetVector(theVector->GetLastFunction());
436 aTI.SetOriginal(aLastFunction);
437 aTI.SetStep1(theStep);
438 aTI.SetNbIter1(theNbTimes);
440 //Compute the translation
442 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
445 if (!GetSolver()->ComputeFunction(aFunction)) {
446 SetErrorCode("Translation driver failed");
450 catch (Standard_Failure) {
451 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
452 SetErrorCode(aFail->GetMessageString());
456 //Make a Python command
457 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
458 << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
464 //=============================================================================
468 //=============================================================================
469 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
470 Handle(GEOM_Object) theVector,
472 Standard_Integer theNbTimes1,
473 Handle(GEOM_Object) theVector2,
475 Standard_Integer theNbTimes2)
479 if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL;
481 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
482 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
484 //Add a new Copy object
485 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
487 //Add a translate function
488 Handle(GEOM_Function) aFunction =
489 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
491 //Check if the function is set correctly
492 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
494 GEOMImpl_ITranslate aTI(aFunction);
495 aTI.SetVector(theVector->GetLastFunction());
496 aTI.SetVector2(theVector2->GetLastFunction());
497 aTI.SetOriginal(aLastFunction);
498 aTI.SetStep1(theStep1);
499 aTI.SetNbIter1(theNbTimes1);
500 aTI.SetStep2(theStep2);
501 aTI.SetNbIter2(theNbTimes2);
503 //Compute the translation
505 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
508 if (!GetSolver()->ComputeFunction(aFunction)) {
509 SetErrorCode("Translation driver failed");
513 catch (Standard_Failure) {
514 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
515 SetErrorCode(aFail->GetMessageString());
519 //Make a Python command
520 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
521 << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1
522 << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
529 //=============================================================================
533 //=============================================================================
534 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
535 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
539 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
541 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
542 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
544 // Get last functions of the arguments
545 Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
547 //Add a mirror function
548 Handle(GEOM_Function) aFunction =
549 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
550 if (aFunction.IsNull()) return NULL;
552 //Check if the function is set correctly
553 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
555 GEOMImpl_IMirror aTI (aFunction);
557 aTI.SetOriginal(aLastFunction);
561 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
564 if (!GetSolver()->ComputeFunction(aFunction)) {
565 SetErrorCode("Mirror driver failed");
569 catch (Standard_Failure) {
570 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
571 SetErrorCode(aFail->GetMessageString());
575 //Make a Python command
576 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane("
577 << theObject << ", " << thePlane << ")";
583 //=============================================================================
587 //=============================================================================
588 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
589 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
593 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
595 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
596 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
598 //Add a new Copy object
599 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
601 //Add a mirror function
602 Handle(GEOM_Function) aFunction =
603 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
605 //Check if the function is set correctly
606 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
608 GEOMImpl_IMirror aTI (aFunction);
609 aTI.SetPlane(thePlane->GetLastFunction());
610 aTI.SetOriginal(aLastFunction);
614 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
617 if (!GetSolver()->ComputeFunction(aFunction)) {
618 SetErrorCode("Mirror driver failed");
622 catch (Standard_Failure) {
623 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
624 SetErrorCode(aFail->GetMessageString());
628 //Make a Python command
629 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
630 << theObject << ", " << thePlane << ")";
636 //=============================================================================
640 //=============================================================================
641 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
642 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
646 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
648 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
649 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
651 // Get last functions of the arguments
652 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
654 //Add a mirror function
655 Handle(GEOM_Function) aFunction =
656 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
657 if (aFunction.IsNull()) return NULL;
659 //Check if the function is set correctly
660 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
662 GEOMImpl_IMirror aTI (aFunction);
664 aTI.SetOriginal(aLastFunction);
668 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
671 if (!GetSolver()->ComputeFunction(aFunction)) {
672 SetErrorCode("Mirror driver failed");
676 catch (Standard_Failure) {
677 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
678 SetErrorCode(aFail->GetMessageString());
682 //Make a Python command
683 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint("
684 << theObject << ", " << thePoint << ")";
690 //=============================================================================
694 //=============================================================================
695 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
696 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
700 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
702 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
703 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
705 //Add a new Copy object
706 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
708 //Add a mirror function
709 Handle(GEOM_Function) aFunction =
710 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
712 //Check if the function is set correctly
713 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
715 GEOMImpl_IMirror aTI (aFunction);
716 aTI.SetPoint(thePoint->GetLastFunction());
717 aTI.SetOriginal(aLastFunction);
721 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
724 if (!GetSolver()->ComputeFunction(aFunction)) {
725 SetErrorCode("Mirror driver failed");
729 catch (Standard_Failure) {
730 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
731 SetErrorCode(aFail->GetMessageString());
735 //Make a Python command
736 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
737 << theObject << ", " << thePoint << ")";
743 //=============================================================================
747 //=============================================================================
748 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
749 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
753 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
755 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
756 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
758 // Get last functions of the arguments
759 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
761 //Add a mirror function
762 Handle(GEOM_Function) aFunction =
763 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
764 if (aFunction.IsNull()) return NULL;
766 //Check if the function is set correctly
767 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
769 GEOMImpl_IMirror aTI (aFunction);
771 aTI.SetOriginal(aLastFunction);
775 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
778 if (!GetSolver()->ComputeFunction(aFunction)) {
779 SetErrorCode("Mirror driver failed");
783 catch (Standard_Failure) {
784 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
785 SetErrorCode(aFail->GetMessageString());
789 //Make a Python command
790 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis("
791 << theObject << ", " << theAxis << ")";
797 //=============================================================================
801 //=============================================================================
802 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
803 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
807 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
809 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
810 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
812 //Add a new Copy object
813 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
815 //Add a mirror function
816 Handle(GEOM_Function) aFunction =
817 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
819 //Check if the function is set correctly
820 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
822 GEOMImpl_IMirror aTI (aFunction);
823 aTI.SetAxis(theAxis->GetLastFunction());
824 aTI.SetOriginal(aLastFunction);
828 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
831 if (!GetSolver()->ComputeFunction(aFunction)) {
832 SetErrorCode("Mirror driver failed");
836 catch (Standard_Failure) {
837 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
838 SetErrorCode(aFail->GetMessageString());
842 //Make a Python command
843 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
844 << theObject << ", " << theAxis << ")";
851 //=============================================================================
855 //=============================================================================
856 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
857 (Handle(GEOM_Object) theObject, double theOffset)
861 if (theObject.IsNull()) return NULL;
863 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
864 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
866 //Add a new Offset function
867 Handle(GEOM_Function) aFunction =
868 theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
869 if (aFunction.IsNull()) return NULL;
871 //Check if the function is set correctly
872 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
874 GEOMImpl_IOffset aTI (aFunction);
875 aTI.SetShape(anOriginal);
876 aTI.SetValue(theOffset);
880 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
883 if (!GetSolver()->ComputeFunction(aFunction)) {
884 SetErrorCode("Offset driver failed");
888 catch (Standard_Failure) {
889 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
890 SetErrorCode(aFail->GetMessageString());
894 //Make a Python command
895 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape("
896 << theObject << ", " << theOffset << ")";
902 //=============================================================================
906 //=============================================================================
907 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
908 (Handle(GEOM_Object) theObject, double theOffset)
912 if (theObject.IsNull()) return NULL;
914 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
915 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
917 //Add a new Copy object
918 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
920 //Add a new Offset function
921 Handle(GEOM_Function) aFunction =
922 aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
923 if (aFunction.IsNull()) return NULL;
925 //Check if the function is set correctly
926 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
928 GEOMImpl_IOffset aTI (aFunction);
929 aTI.SetShape(anOriginal);
930 aTI.SetValue(theOffset);
934 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
937 if (!GetSolver()->ComputeFunction(aFunction)) {
938 SetErrorCode("Offset driver failed");
942 catch (Standard_Failure) {
943 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
944 SetErrorCode(aFail->GetMessageString());
948 //Make a Python command
949 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
950 << theObject << ", " << theOffset << ")";
957 //=============================================================================
961 //=============================================================================
962 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
963 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
967 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
969 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
970 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
972 // Get last functions of the arguments
973 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
975 //Add a scale function
976 Handle(GEOM_Function) aFunction =
977 theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
978 if (aFunction.IsNull()) return NULL;
980 //Check if the function is set correctly
981 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
983 GEOMImpl_IScale aTI (aFunction);
984 aTI.SetShape(anOriginal);
986 aTI.SetFactor(theFactor);
990 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
993 if (!GetSolver()->ComputeFunction(aFunction)) {
994 SetErrorCode("Scale driver failed");
998 catch (Standard_Failure) {
999 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1000 SetErrorCode(aFail->GetMessageString());
1004 //Make a Python command
1005 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape("
1006 << theObject << ", " << thePoint << ", " << theFactor << ")";
1012 //=============================================================================
1016 //=============================================================================
1017 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1018 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1022 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
1024 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1025 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1027 //Add a new Copy object
1028 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1030 //Add a scale function
1031 Handle(GEOM_Function) aFunction =
1032 aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1033 if (aFunction.IsNull()) return NULL;
1035 //Check if the function is set correctly
1036 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1038 GEOMImpl_IScale aTI (aFunction);
1039 aTI.SetShape(anOriginal);
1040 aTI.SetPoint(thePoint->GetLastFunction());
1041 aTI.SetFactor(theFactor);
1045 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1048 if (!GetSolver()->ComputeFunction(aFunction)) {
1049 SetErrorCode("Scale driver failed");
1053 catch (Standard_Failure) {
1054 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1055 SetErrorCode(aFail->GetMessageString());
1059 //Make a Python command
1060 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1061 << theObject << ", " << thePoint << ", " << theFactor << ")";
1067 //=============================================================================
1071 //=============================================================================
1072 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1073 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1077 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1079 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1080 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1082 //Add a Position function
1083 Standard_Integer aType = POSITION_SHAPE;
1084 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1086 Handle(GEOM_Function) aFunction =
1087 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1088 if (aFunction.IsNull()) return NULL;
1090 //Check if the function is set correctly
1091 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1093 //Set operation arguments
1094 GEOMImpl_IPosition aTI (aFunction);
1095 aTI.SetShape(anOriginal);
1096 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1097 if (!theStartLCS.IsNull())
1098 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1100 //Compute the Position
1102 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1105 if (!GetSolver()->ComputeFunction(aFunction)) {
1106 SetErrorCode("Position driver failed");
1110 catch (Standard_Failure) {
1111 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1112 SetErrorCode(aFail->GetMessageString());
1116 //Make a Python command
1117 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
1118 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1124 //=============================================================================
1128 //=============================================================================
1129 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1130 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1134 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1136 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1137 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1139 //Add a new Copy object
1140 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1142 //Add a position function
1143 Standard_Integer aType = POSITION_SHAPE_COPY;
1144 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1146 Handle(GEOM_Function) aFunction =
1147 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1148 if (aFunction.IsNull()) return NULL;
1150 //Check if the function is set correctly
1151 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1153 GEOMImpl_IPosition aTI (aFunction);
1154 aTI.SetShape(anOriginal);
1155 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1156 if (!theStartLCS.IsNull())
1157 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1159 //Compute the position
1161 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1164 if (!GetSolver()->ComputeFunction(aFunction)) {
1165 SetErrorCode("Position driver failed");
1169 catch (Standard_Failure) {
1170 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1171 SetErrorCode(aFail->GetMessageString());
1175 //Make a Python command
1176 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1177 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1183 //=============================================================================
1187 //=============================================================================
1188 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1189 Handle(GEOM_Object) theAxis,
1194 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1196 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1197 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1199 // Get last functions of the arguments
1200 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1202 //Add a rotate function
1203 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1205 if (aFunction.IsNull()) return NULL;
1207 //Check if the function is set correctly
1208 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1210 GEOMImpl_IRotate aRI(aFunction);
1212 aRI.SetOriginal(aLastFunction);
1213 aRI.SetAngle(theAngle);
1215 //Compute the translation
1217 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1220 if (!GetSolver()->ComputeFunction(aFunction)) {
1221 SetErrorCode("Rotate driver failed");
1225 catch (Standard_Failure) {
1226 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1227 SetErrorCode(aFail->GetMessageString());
1231 //Make a Python command
1232 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.Rotate(" << theObject
1233 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1239 //=============================================================================
1243 //=============================================================================
1244 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
1248 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1250 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1251 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1253 //Add a new Copy object
1254 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1256 //Add a rotate function
1257 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1258 if (aFunction.IsNull()) return NULL;
1260 //Check if the function is set correctly
1261 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1263 GEOMImpl_IRotate aRI(aFunction);
1264 aRI.SetAxis(theAxis->GetLastFunction());
1265 aRI.SetOriginal(aLastFunction);
1266 aRI.SetAngle(theAngle);
1268 //Compute the translation
1270 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1273 if (!GetSolver()->ComputeFunction(aFunction)) {
1274 SetErrorCode("Rotate driver failed");
1278 catch (Standard_Failure) {
1279 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1280 SetErrorCode(aFail->GetMessageString());
1284 //Make a Python command
1285 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1286 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1292 //=============================================================================
1296 //=============================================================================
1297 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1298 Handle(GEOM_Object) theAxis,
1299 Standard_Integer theNbTimes)
1303 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1305 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1306 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1308 //Add a new Copy object
1309 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1311 //Add a rotate function
1312 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1313 if (aFunction.IsNull()) return NULL;
1315 //Check if the function is set correctly
1316 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1318 GEOMImpl_IRotate aRI(aFunction);
1319 aRI.SetOriginal(aLastFunction);
1320 aRI.SetAxis(theAxis->GetLastFunction());
1321 aRI.SetNbIter1(theNbTimes);
1323 //Compute the translation
1325 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1328 if (!GetSolver()->ComputeFunction(aFunction)) {
1329 SetErrorCode("Rotate driver failed");
1333 catch (Standard_Failure) {
1334 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1335 SetErrorCode(aFail->GetMessageString());
1339 //Make a Python command
1340 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
1341 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1347 //=============================================================================
1351 //=============================================================================
1352 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1353 Handle(GEOM_Object) theAxis,
1355 Standard_Integer theNbTimes1,
1357 Standard_Integer theNbTimes2)
1361 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1363 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1364 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1366 //Add a new Copy object
1367 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1369 //Add a rotate function
1370 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1371 if (aFunction.IsNull()) return NULL;
1373 //Check if the function is set correctly
1374 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1376 GEOMImpl_IRotate aRI(aFunction);
1377 aRI.SetAxis(theAxis->GetLastFunction());
1378 aRI.SetOriginal(aLastFunction);
1379 aRI.SetNbIter1(theNbTimes1);
1380 aRI.SetNbIter2(theNbTimes2);
1381 aRI.SetAngle(theAngle);
1382 aRI.SetStep(theStep);
1384 //Compute the translation
1386 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1389 if (!GetSolver()->ComputeFunction(aFunction)) {
1390 SetErrorCode("Rotate driver failed");
1394 catch (Standard_Failure) {
1395 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1396 SetErrorCode(aFail->GetMessageString());
1400 //Make a Python command
1401 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
1402 << theObject << ", " << theAxis << ", " << theAngle << ", "
1403 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
1409 //=============================================================================
1413 //=============================================================================
1414 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
1415 Handle(GEOM_Object) theCentPoint,
1416 Handle(GEOM_Object) thePoint1,
1417 Handle(GEOM_Object) thePoint2)
1421 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1423 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1424 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1426 // Get last functions of the arguments
1427 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
1428 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
1429 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
1432 //Add a rotate function
1433 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
1435 if (aFunction.IsNull()) return NULL;
1437 //Check if the function is set correctly
1438 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1440 GEOMImpl_IRotate aRI(aFunction);
1441 aRI.SetCentPoint(aCPF);
1442 aRI.SetPoint1(aP1F);
1443 aRI.SetPoint2(aP2F);
1444 aRI.SetOriginal(aLastFunction);
1446 //Compute the translation
1448 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1451 if (!GetSolver()->ComputeFunction(aFunction)) {
1452 SetErrorCode("Rotate driver failed");
1456 catch (Standard_Failure) {
1457 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1458 SetErrorCode(aFail->GetMessageString());
1462 //Make a Python command
1463 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
1464 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
1470 //=============================================================================
1472 * RotateThreePointsCopy
1474 //=============================================================================
1475 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
1476 Handle(GEOM_Object) theCentPoint,
1477 Handle(GEOM_Object) thePoint1,
1478 Handle(GEOM_Object) thePoint2)
1482 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1484 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1485 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1487 //Add a new Copy object
1488 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1490 //Add a rotate function
1491 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
1492 if (aFunction.IsNull()) return NULL;
1494 //Check if the function is set correctly
1495 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1497 GEOMImpl_IRotate aRI(aFunction);
1498 aRI.SetCentPoint(theCentPoint->GetLastFunction());
1499 aRI.SetPoint1(thePoint1->GetLastFunction());
1500 aRI.SetPoint2(thePoint2->GetLastFunction());
1501 aRI.SetOriginal(aLastFunction);
1503 //Compute the translation
1505 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1508 if (!GetSolver()->ComputeFunction(aFunction)) {
1509 SetErrorCode("Rotate driver failed");
1513 catch (Standard_Failure) {
1514 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1515 SetErrorCode(aFail->GetMessageString());
1519 //Make a Python command
1520 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
1521 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";