+
+//=============================================================================
+/*!
+ * RotateThreePoints
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
+ Handle(GEOM_Object) theCentPoint,
+ Handle(GEOM_Object) thePoint1,
+ Handle(GEOM_Object) thePoint2)
+{
+ SetErrorCode(KO);
+
+ if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
+
+ Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
+ if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
+
+ // Get last functions of the arguments
+ Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
+ Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
+ Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
+
+
+ //Add a rotate function
+ aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
+
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
+
+ GEOMImpl_IRotate aRI(aFunction);
+ aRI.SetCentPoint(aCPF);
+ aRI.SetPoint1(aP1F);
+ aRI.SetPoint2(aP2F);
+ aRI.SetOriginal(aLastFunction);
+
+ //Compute the translation
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Rotate driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
+ << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
+
+ SetErrorCode(OK);
+ return theObject;
+}
+
+//=============================================================================
+/*!
+ * RotateThreePointsCopy
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
+ Handle(GEOM_Object) theCentPoint,
+ Handle(GEOM_Object) thePoint1,
+ Handle(GEOM_Object) thePoint2)
+{
+ SetErrorCode(KO);
+
+ if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
+
+ Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
+ if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
+
+ //Add a new Copy object
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+
+ //Add a rotate function
+ aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
+
+ GEOMImpl_IRotate aRI(aFunction);
+ aRI.SetCentPoint(theCentPoint->GetLastFunction());
+ aRI.SetPoint1(thePoint1->GetLastFunction());
+ aRI.SetPoint2(thePoint2->GetLastFunction());
+ aRI.SetOriginal(aLastFunction);
+
+ //Compute the translation
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Rotate driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
+ << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
+
+ SetErrorCode(OK);
+ return aCopy;
+}
+
+//=============================================================================
+/*!
+ * TransformLikeOtherCopy
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy
+ (Handle(GEOM_Object) theObject,
+ Handle(GEOM_Object) theSample)
+{
+ SetErrorCode(KO);
+
+ if (theObject.IsNull() || theSample.IsNull()) return NULL;
+
+ Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
+ if (aLastFunction.IsNull()) return NULL; // There is no function which creates an object to be transformed
+
+ Handle(GEOM_Function) aSampleFunc = theSample->GetLastFunction();
+ if (aSampleFunc.IsNull()) return NULL; // There is no function which creates a sample object
+
+ // Add a new Copy object
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+
+ // Add a transform function (depends on theSample function)
+ Handle(GEOM_Function) aFunction =
+ aCopy->AddFunction(aSampleFunc->GetDriverGUID(), aSampleFunc->GetType());
+ if (aFunction.IsNull()) return NULL;
+
+ // Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != aSampleFunc->GetDriverGUID()) return NULL;
+
+ if (aSampleFunc->GetDriverGUID() == GEOMImpl_TranslateDriver::GetID()) {
+ switch (aSampleFunc->GetType()) {
+ case TRANSLATE_1D:
+ {
+ GEOMImpl_ITranslate aRI_sample (aSampleFunc);
+ GEOMImpl_ITranslate aRI_target (aFunction);
+
+ aRI_target.SetVector(aRI_sample.GetVector());
+ aRI_target.SetStep1(aRI_sample.GetStep1());
+ aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
+
+ aRI_target.SetOriginal(aLastFunction);
+ }
+ break;
+ case TRANSLATE_2D:
+ {
+ GEOMImpl_ITranslate aRI_sample (aSampleFunc);
+ GEOMImpl_ITranslate aRI_target (aFunction);
+
+ aRI_target.SetVector(aRI_sample.GetVector());
+ aRI_target.SetStep1(aRI_sample.GetStep1());
+ aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
+
+ aRI_target.SetVector2(aRI_sample.GetVector2());
+ aRI_target.SetStep2(aRI_sample.GetStep2());
+ aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
+
+ aRI_target.SetOriginal(aLastFunction);
+ }
+ break;
+ default:
+ {
+ SetErrorCode("Not implemented case of TransformLikeOtherCopy");
+ return NULL;
+ }
+ }
+ }
+ else if (aSampleFunc->GetDriverGUID() == GEOMImpl_RotateDriver::GetID()) {
+ switch (aSampleFunc->GetType()) {
+ case ROTATE_1D:
+ {
+ GEOMImpl_IRotate aRI_sample (aSampleFunc);
+ GEOMImpl_IRotate aRI_target (aFunction);
+
+ aRI_target.SetAxis(aRI_sample.GetAxis());
+ aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
+
+ aRI_target.SetOriginal(aLastFunction);
+ }
+ break;
+ case ROTATE_2D:
+ {
+ GEOMImpl_IRotate aRI_sample (aSampleFunc);
+ GEOMImpl_IRotate aRI_target (aFunction);
+
+ aRI_target.SetAxis(aRI_sample.GetAxis());
+
+ aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
+ aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
+
+ aRI_target.SetAngle(aRI_sample.GetAngle());
+ aRI_target.SetStep(aRI_sample.GetStep());
+
+ aRI_target.SetDir2(aRI_sample.GetDir2());
+
+ aRI_target.SetOriginal(aLastFunction);
+ }
+ break;
+ case ROTATE_THREE_POINTS_COPY:
+ {
+ GEOMImpl_IRotate aRI_sample (aSampleFunc);
+ GEOMImpl_IRotate aRI_target (aFunction);
+
+ aRI_target.SetCentPoint(aRI_sample.GetCentPoint());
+ aRI_target.SetPoint1(aRI_sample.GetPoint1());
+ aRI_target.SetPoint2(aRI_sample.GetPoint2());
+
+ aRI_target.SetOriginal(aLastFunction);
+ }
+ break;
+ default:
+ {
+ SetErrorCode("Not implemented case of TransformLikeOtherCopy");
+ return NULL;
+ }
+ }
+ }
+ else {
+ SetErrorCode("Not implemented case of TransformLikeOtherCopy");
+ return NULL;
+ }
+
+ // Compute the transformation
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ //GEOM::TPythonDump(aFunction) << aCopy << " = geompy.TransformLikeOtherCopy("
+ // << theObject << ", " << theSample << ")";
+
+ SetErrorCode(OK);
+ return aCopy;
+}