3 #include "GEOMImpl_ITransformOperations.hxx"
7 #include "Utils_ExceptHandlers.hxx"
9 #include <TFunction_DriverTable.hxx>
10 #include <TFunction_Driver.hxx>
11 #include <TFunction_Logbook.hxx>
12 #include <TDF_Tool.hxx>
14 #include "GEOM_Function.hxx"
15 #include "GEOM_PythonDump.hxx"
17 #include "GEOMImpl_TranslateDriver.hxx"
18 #include "GEOMImpl_MirrorDriver.hxx"
19 #include "GEOMImpl_OffsetDriver.hxx"
20 #include "GEOMImpl_ScaleDriver.hxx"
21 #include "GEOMImpl_RotateDriver.hxx"
22 #include "GEOMImpl_PositionDriver.hxx"
24 #include "GEOMImpl_ITranslate.hxx"
25 #include "GEOMImpl_IMirror.hxx"
26 #include "GEOMImpl_IOffset.hxx"
27 #include "GEOMImpl_IScale.hxx"
28 #include "GEOMImpl_IRotate.hxx"
29 #include "GEOMImpl_IPosition.hxx"
31 #include "GEOMImpl_Types.hxx"
33 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
35 //=============================================================================
39 //=============================================================================
41 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
42 : GEOM_IOperations(theEngine, theDocID)
44 MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
47 //=============================================================================
51 //=============================================================================
53 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
55 MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
59 //=============================================================================
63 //=============================================================================
64 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
65 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
69 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
71 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
72 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
74 // Get last functions of the arguments
75 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
76 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
78 //Add a translate function
79 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
81 if (aFunction.IsNull()) return NULL;
83 //Check if the function is set correctly
84 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
86 GEOMImpl_ITranslate aTI (aFunction);
89 aTI.SetOriginal(aLastFunction);
91 //Compute the translation
93 if (!GetSolver()->ComputeFunction(aFunction)) {
94 SetErrorCode("Translation driver failed");
98 catch (Standard_Failure) {
99 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
100 SetErrorCode(aFail->GetMessageString());
104 //Make a Python command
105 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateTwoPoints("
106 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
112 //=============================================================================
116 //=============================================================================
117 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
118 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
122 if (theObject.IsNull()) return NULL;
124 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
125 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
127 //Add a translate function
128 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
130 if (aFunction.IsNull()) return NULL;
132 //Check if the function is set correctly
133 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
135 GEOMImpl_ITranslate aTI(aFunction);
139 aTI.SetOriginal(aLastFunction);
141 //Compute the translation
143 if (!GetSolver()->ComputeFunction(aFunction)) {
144 SetErrorCode("Translation driver failed");
148 catch (Standard_Failure) {
149 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
150 SetErrorCode(aFail->GetMessageString());
154 //Make a Python command
155 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateDXDYDZ("
156 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
163 //=============================================================================
165 * TranslateTwoPointsCopy
167 //=============================================================================
168 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
169 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
173 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
175 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
176 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
178 //Add a new Copy object
179 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
181 //Add a translate function
182 Handle(GEOM_Function) aFunction =
183 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
185 //Check if the function is set correctly
186 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
188 GEOMImpl_ITranslate aTI(aFunction);
189 aTI.SetPoint1(thePoint1->GetLastFunction());
190 aTI.SetPoint2(thePoint2->GetLastFunction());
191 //aTI.SetShape(theObject->GetValue());
192 aTI.SetOriginal(aLastFunction);
194 //Compute the translation
196 if (!GetSolver()->ComputeFunction(aFunction)) {
197 SetErrorCode("Translation driver failed");
201 catch (Standard_Failure) {
202 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
203 SetErrorCode(aFail->GetMessageString());
207 //Make a Python command
208 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
209 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
215 //=============================================================================
217 * TranslateDXDYDZCopy
219 //=============================================================================
220 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
221 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
225 if (theObject.IsNull()) return NULL;
227 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
228 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
230 //Add a new Copy object
231 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
233 //Add a translate function
234 Handle(GEOM_Function) aFunction =
235 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
237 //Check if the function is set correctly
238 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
240 GEOMImpl_ITranslate aTI(aFunction);
244 aTI.SetOriginal(aLastFunction);
246 //Compute the translation
248 if (!GetSolver()->ComputeFunction(aFunction)) {
249 SetErrorCode("Translation driver failed");
253 catch (Standard_Failure) {
254 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
255 SetErrorCode(aFail->GetMessageString());
259 //Make a Python command
260 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
261 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
268 //=============================================================================
272 //=============================================================================
273 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
274 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
278 if (theObject.IsNull() || theVector.IsNull()) return NULL;
280 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
281 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
283 // Get last functions of the arguments
284 Handle(GEOM_Function) aVF = theVector->GetLastFunction();
286 //Add a translate function
287 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
289 if (aFunction.IsNull()) return NULL;
291 //Check if the function is set correctly
292 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
294 GEOMImpl_ITranslate aTI (aFunction);
296 aTI.SetOriginal(aLastFunction);
298 //Compute the translation
300 if (!GetSolver()->ComputeFunction(aFunction)) {
301 SetErrorCode("Translation driver failed");
305 catch (Standard_Failure) {
306 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
307 SetErrorCode(aFail->GetMessageString());
311 //Make a Python command
312 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVector("
313 << theObject << ", " << theVector << ")";
319 //=============================================================================
321 * TranslateVectorCopy
323 //=============================================================================
324 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
325 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
329 if (theObject.IsNull() || theVector.IsNull()) return NULL;
331 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
332 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
334 //Add a new Copy object
335 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
337 //Add a translate function
338 Handle(GEOM_Function) aFunction =
339 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
341 //Check if the function is set correctly
342 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
344 GEOMImpl_ITranslate aTI(aFunction);
345 aTI.SetVector(theVector->GetLastFunction());
346 // aTI.SetShape(theObject->GetValue());
347 aTI.SetOriginal(aLastFunction);
349 //Compute the translation
351 if (!GetSolver()->ComputeFunction(aFunction)) {
352 SetErrorCode("Translation driver failed");
356 catch (Standard_Failure) {
357 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
358 SetErrorCode(aFail->GetMessageString());
362 //Make a Python command
363 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
364 << theObject << ", " << theVector << ")";
370 //=============================================================================
374 //=============================================================================
375 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
376 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
377 double theStep, Standard_Integer theNbTimes)
381 if (theObject.IsNull() || theVector.IsNull()) return NULL;
383 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
384 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
386 //Add a new Copy object
387 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
389 //Add a translate function
390 Handle(GEOM_Function) aFunction =
391 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
393 //Check if the function is set correctly
394 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
396 GEOMImpl_ITranslate aTI(aFunction);
397 aTI.SetVector(theVector->GetLastFunction());
398 aTI.SetOriginal(aLastFunction);
399 aTI.SetStep1(theStep);
400 aTI.SetNbIter1(theNbTimes);
402 //Compute the translation
404 if (!GetSolver()->ComputeFunction(aFunction)) {
405 SetErrorCode("Translation driver failed");
409 catch (Standard_Failure) {
410 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
411 SetErrorCode(aFail->GetMessageString());
415 //Make a Python command
416 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
417 << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
423 //=============================================================================
427 //=============================================================================
428 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
429 Handle(GEOM_Object) theVector,
431 Standard_Integer theNbTimes1,
432 Handle(GEOM_Object) theVector2,
434 Standard_Integer theNbTimes2)
438 if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL;
440 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
441 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
443 //Add a new Copy object
444 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
446 //Add a translate function
447 Handle(GEOM_Function) aFunction =
448 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
450 //Check if the function is set correctly
451 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
453 GEOMImpl_ITranslate aTI(aFunction);
454 aTI.SetVector(theVector->GetLastFunction());
455 aTI.SetVector2(theVector2->GetLastFunction());
456 aTI.SetOriginal(aLastFunction);
457 aTI.SetStep1(theStep1);
458 aTI.SetNbIter1(theNbTimes1);
459 aTI.SetStep2(theStep2);
460 aTI.SetNbIter2(theNbTimes2);
462 //Compute the translation
464 if (!GetSolver()->ComputeFunction(aFunction)) {
465 SetErrorCode("Translation driver failed");
469 catch (Standard_Failure) {
470 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
471 SetErrorCode(aFail->GetMessageString());
475 //Make a Python command
476 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
477 << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1
478 << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
485 //=============================================================================
489 //=============================================================================
490 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
491 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
495 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
497 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
498 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
500 // Get last functions of the arguments
501 Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
503 //Add a mirror function
504 Handle(GEOM_Function) aFunction =
505 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
506 if (aFunction.IsNull()) return NULL;
508 //Check if the function is set correctly
509 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
511 GEOMImpl_IMirror aTI (aFunction);
513 aTI.SetOriginal(aLastFunction);
517 if (!GetSolver()->ComputeFunction(aFunction)) {
518 SetErrorCode("Mirror driver failed");
522 catch (Standard_Failure) {
523 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
524 SetErrorCode(aFail->GetMessageString());
528 //Make a Python command
529 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane("
530 << theObject << ", " << thePlane << ")";
536 //=============================================================================
540 //=============================================================================
541 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
542 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
546 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
548 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
549 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
551 //Add a new Copy object
552 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
554 //Add a mirror function
555 Handle(GEOM_Function) aFunction =
556 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
558 //Check if the function is set correctly
559 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
561 GEOMImpl_IMirror aTI (aFunction);
562 aTI.SetPlane(thePlane->GetLastFunction());
563 aTI.SetOriginal(aLastFunction);
567 if (!GetSolver()->ComputeFunction(aFunction)) {
568 SetErrorCode("Mirror driver failed");
572 catch (Standard_Failure) {
573 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
574 SetErrorCode(aFail->GetMessageString());
578 //Make a Python command
579 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
580 << theObject << ", " << thePlane << ")";
586 //=============================================================================
590 //=============================================================================
591 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
592 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
596 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
598 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
599 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
601 // Get last functions of the arguments
602 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
604 //Add a mirror function
605 Handle(GEOM_Function) aFunction =
606 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
607 if (aFunction.IsNull()) return NULL;
609 //Check if the function is set correctly
610 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
612 GEOMImpl_IMirror aTI (aFunction);
614 aTI.SetOriginal(aLastFunction);
618 if (!GetSolver()->ComputeFunction(aFunction)) {
619 SetErrorCode("Mirror driver failed");
623 catch (Standard_Failure) {
624 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
625 SetErrorCode(aFail->GetMessageString());
629 //Make a Python command
630 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint("
631 << theObject << ", " << thePoint << ")";
637 //=============================================================================
641 //=============================================================================
642 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
643 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
647 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
649 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
650 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
652 //Add a new Copy object
653 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
655 //Add a mirror function
656 Handle(GEOM_Function) aFunction =
657 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
659 //Check if the function is set correctly
660 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
662 GEOMImpl_IMirror aTI (aFunction);
663 aTI.SetPoint(thePoint->GetLastFunction());
664 aTI.SetOriginal(aLastFunction);
668 if (!GetSolver()->ComputeFunction(aFunction)) {
669 SetErrorCode("Mirror driver failed");
673 catch (Standard_Failure) {
674 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
675 SetErrorCode(aFail->GetMessageString());
679 //Make a Python command
680 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
681 << theObject << ", " << thePoint << ")";
687 //=============================================================================
691 //=============================================================================
692 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
693 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
697 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
699 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
700 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
702 // Get last functions of the arguments
703 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
705 //Add a mirror function
706 Handle(GEOM_Function) aFunction =
707 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
708 if (aFunction.IsNull()) return NULL;
710 //Check if the function is set correctly
711 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
713 GEOMImpl_IMirror aTI (aFunction);
715 aTI.SetOriginal(aLastFunction);
719 if (!GetSolver()->ComputeFunction(aFunction)) {
720 SetErrorCode("Mirror driver failed");
724 catch (Standard_Failure) {
725 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
726 SetErrorCode(aFail->GetMessageString());
730 //Make a Python command
731 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis("
732 << theObject << ", " << theAxis << ")";
738 //=============================================================================
742 //=============================================================================
743 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
744 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
748 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
750 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
751 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
753 //Add a new Copy object
754 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
756 //Add a mirror function
757 Handle(GEOM_Function) aFunction =
758 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
760 //Check if the function is set correctly
761 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
763 GEOMImpl_IMirror aTI (aFunction);
764 aTI.SetAxis(theAxis->GetLastFunction());
765 aTI.SetOriginal(aLastFunction);
769 if (!GetSolver()->ComputeFunction(aFunction)) {
770 SetErrorCode("Mirror driver failed");
774 catch (Standard_Failure) {
775 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
776 SetErrorCode(aFail->GetMessageString());
780 //Make a Python command
781 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
782 << theObject << ", " << theAxis << ")";
789 //=============================================================================
793 //=============================================================================
794 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
795 (Handle(GEOM_Object) theObject, double theOffset)
799 if (theObject.IsNull()) return NULL;
801 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
802 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
804 //Add a new Offset function
805 Handle(GEOM_Function) aFunction =
806 theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
807 if (aFunction.IsNull()) return NULL;
809 //Check if the function is set correctly
810 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
812 GEOMImpl_IOffset aTI (aFunction);
813 aTI.SetShape(anOriginal);
814 aTI.SetValue(theOffset);
818 if (!GetSolver()->ComputeFunction(aFunction)) {
819 SetErrorCode("Offset driver failed");
823 catch (Standard_Failure) {
824 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
825 SetErrorCode(aFail->GetMessageString());
829 //Make a Python command
830 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape("
831 << theObject << ", " << theOffset << ")";
837 //=============================================================================
841 //=============================================================================
842 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
843 (Handle(GEOM_Object) theObject, double theOffset)
847 if (theObject.IsNull()) return NULL;
849 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
850 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
852 //Add a new Copy object
853 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
855 //Add a new Offset function
856 Handle(GEOM_Function) aFunction =
857 aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
858 if (aFunction.IsNull()) return NULL;
860 //Check if the function is set correctly
861 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
863 GEOMImpl_IOffset aTI (aFunction);
864 aTI.SetShape(anOriginal);
865 aTI.SetValue(theOffset);
869 if (!GetSolver()->ComputeFunction(aFunction)) {
870 SetErrorCode("Offset driver failed");
874 catch (Standard_Failure) {
875 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
876 SetErrorCode(aFail->GetMessageString());
880 //Make a Python command
881 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
882 << theObject << ", " << theOffset << ")";
889 //=============================================================================
893 //=============================================================================
894 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
895 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
899 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
901 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
902 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
904 // Get last functions of the arguments
905 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
907 //Add a scale function
908 Handle(GEOM_Function) aFunction =
909 theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
910 if (aFunction.IsNull()) return NULL;
912 //Check if the function is set correctly
913 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
915 GEOMImpl_IScale aTI (aFunction);
916 aTI.SetShape(anOriginal);
918 aTI.SetFactor(theFactor);
922 if (!GetSolver()->ComputeFunction(aFunction)) {
923 SetErrorCode("Scale driver failed");
927 catch (Standard_Failure) {
928 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
929 SetErrorCode(aFail->GetMessageString());
933 //Make a Python command
934 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape("
935 << theObject << ", " << thePoint << ", " << theFactor << ")";
941 //=============================================================================
945 //=============================================================================
946 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
947 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
951 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
953 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
954 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
956 //Add a new Copy object
957 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
959 //Add a scale function
960 Handle(GEOM_Function) aFunction =
961 aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
962 if (aFunction.IsNull()) return NULL;
964 //Check if the function is set correctly
965 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
967 GEOMImpl_IScale aTI (aFunction);
968 aTI.SetShape(anOriginal);
969 aTI.SetPoint(thePoint->GetLastFunction());
970 aTI.SetFactor(theFactor);
974 if (!GetSolver()->ComputeFunction(aFunction)) {
975 SetErrorCode("Scale driver failed");
979 catch (Standard_Failure) {
980 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
981 SetErrorCode(aFail->GetMessageString());
985 //Make a Python command
986 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
987 << theObject << ", " << thePoint << ", " << theFactor << ")";
993 //=============================================================================
997 //=============================================================================
998 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
999 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1003 if (theObject.IsNull() || theStartLCS.IsNull() || theEndLCS.IsNull()) return NULL;
1005 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1006 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1008 // Get last functions of the arguments
1009 Handle(GEOM_Function) aStartLCS = theStartLCS->GetLastFunction();
1010 Handle(GEOM_Function) aEndLCS = theEndLCS->GetLastFunction();
1012 //Add a Position function
1013 Handle(GEOM_Function) aFunction =
1014 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_SHAPE);
1015 if (aFunction.IsNull()) return NULL;
1017 //Check if the function is set correctly
1018 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1020 GEOMImpl_IPosition aTI (aFunction);
1021 aTI.SetShape(anOriginal);
1022 aTI.SetStartLCS(aStartLCS);
1023 aTI.SetEndLCS(aEndLCS);
1025 //Compute the Position
1027 if (!GetSolver()->ComputeFunction(aFunction)) {
1028 SetErrorCode("Position driver failed");
1032 catch (Standard_Failure) {
1033 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1034 SetErrorCode(aFail->GetMessageString());
1038 //Make a Python command
1039 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape("
1040 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1046 //=============================================================================
1050 //=============================================================================
1051 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1052 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1056 if (theObject.IsNull() || theStartLCS.IsNull() || theEndLCS.IsNull()) return NULL;
1058 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1059 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1061 //Add a new Copy object
1062 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1064 //Add a position function
1065 Handle(GEOM_Function) aFunction =
1066 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_SHAPE_COPY);
1067 if (aFunction.IsNull()) return NULL;
1069 //Check if the function is set correctly
1070 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1072 GEOMImpl_IPosition aTI (aFunction);
1073 aTI.SetShape(anOriginal);
1074 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1075 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1077 //Compute the position
1079 if (!GetSolver()->ComputeFunction(aFunction)) {
1080 SetErrorCode("Position driver failed");
1084 catch (Standard_Failure) {
1085 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1086 SetErrorCode(aFail->GetMessageString());
1090 //Make a Python command
1091 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1092 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1098 //=============================================================================
1102 //=============================================================================
1103 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1104 Handle(GEOM_Object) theAxis,
1109 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1111 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1112 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1114 // Get last functions of the arguments
1115 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1117 //Add a rotate function
1118 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1120 if (aFunction.IsNull()) return NULL;
1122 //Check if the function is set correctly
1123 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1125 GEOMImpl_IRotate aRI(aFunction);
1127 aRI.SetOriginal(aLastFunction);
1128 aRI.SetAngle(theAngle);
1130 //Compute the translation
1132 if (!GetSolver()->ComputeFunction(aFunction)) {
1133 SetErrorCode("Rotate driver failed");
1137 catch (Standard_Failure) {
1138 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1139 SetErrorCode(aFail->GetMessageString());
1143 //Make a Python command
1144 GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.Rotate(" << theObject
1145 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1151 //=============================================================================
1155 //=============================================================================
1156 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle)
1160 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1162 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1163 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1165 //Add a new Copy object
1166 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1168 //Add a rotate function
1169 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1170 if (aFunction.IsNull()) return NULL;
1172 //Check if the function is set correctly
1173 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1175 GEOMImpl_IRotate aRI(aFunction);
1176 aRI.SetAxis(theAxis->GetLastFunction());
1177 aRI.SetOriginal(aLastFunction);
1178 aRI.SetAngle(theAngle);
1180 //Compute the translation
1182 if (!GetSolver()->ComputeFunction(aFunction)) {
1183 SetErrorCode("Rotate driver failed");
1187 catch (Standard_Failure) {
1188 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1189 SetErrorCode(aFail->GetMessageString());
1193 //Make a Python command
1194 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1195 << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
1201 //=============================================================================
1205 //=============================================================================
1206 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1207 Handle(GEOM_Object) theAxis,
1208 Standard_Integer theNbTimes)
1212 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1214 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1215 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1217 //Add a new Copy object
1218 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1220 //Add a rotate function
1221 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1222 if (aFunction.IsNull()) return NULL;
1224 //Check if the function is set correctly
1225 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1227 GEOMImpl_IRotate aRI(aFunction);
1228 aRI.SetOriginal(aLastFunction);
1229 aRI.SetAxis(theAxis->GetLastFunction());
1230 aRI.SetNbIter1(theNbTimes);
1232 //Compute the translation
1234 if (!GetSolver()->ComputeFunction(aFunction)) {
1235 SetErrorCode("Rotate driver failed");
1239 catch (Standard_Failure) {
1240 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1241 SetErrorCode(aFail->GetMessageString());
1245 //Make a Python command
1246 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D("
1247 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1253 //=============================================================================
1257 //=============================================================================
1258 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1259 Handle(GEOM_Object) theAxis,
1261 Standard_Integer theNbTimes1,
1263 Standard_Integer theNbTimes2)
1267 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1269 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1270 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1272 //Add a new Copy object
1273 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1275 //Add a rotate function
1276 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1277 if (aFunction.IsNull()) return NULL;
1279 //Check if the function is set correctly
1280 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1282 GEOMImpl_IRotate aRI(aFunction);
1283 aRI.SetAxis(theAxis->GetLastFunction());
1284 aRI.SetOriginal(aLastFunction);
1285 aRI.SetNbIter1(theNbTimes1);
1286 aRI.SetNbIter2(theNbTimes2);
1287 aRI.SetAngle(theAngle);
1288 aRI.SetStep(theStep);
1290 //Compute the translation
1292 if (!GetSolver()->ComputeFunction(aFunction)) {
1293 SetErrorCode("Rotate driver failed");
1297 catch (Standard_Failure) {
1298 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1299 SetErrorCode(aFail->GetMessageString());
1303 //Make a Python command
1304 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D("
1305 << theObject << ", " << theAxis << ", " << theAngle << ", "
1306 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";