// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
+// License as published by the Free Software Foundation; either
// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx>
#include <GEOMImpl_Types.hxx>
+#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
//=============================================================================
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Translation driver failed");
return NULL;
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Translation driver failed");
return NULL;
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Translation driver failed");
return NULL;
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Translation driver failed");
return NULL;
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Translation driver failed");
return NULL;
SetErrorCode(OK);
return theObject;
}
-
//=============================================================================
/*!
* TranslateVectorCopy
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Translation driver failed");
return NULL;
return aCopy;
}
+//=============================================================================
+/*!
+ * TranslateVectorDistance
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
+ (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy)
+{
+ SetErrorCode(KO);
+
+ if (theObject.IsNull() || theVector.IsNull()) return NULL;
+
+ Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
+ if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
+
+ Handle(GEOM_Object) aCopy; //Add a new Copy object
+ Handle(GEOM_Function) aFunction;
+
+ //Add a translate function
+ if (theCopy) {
+ aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
+ }
+ else {
+ aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
+ }
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
+
+ GEOMImpl_ITranslate aTI(aFunction);
+ aTI.SetVector(theVector->GetLastFunction());
+ aTI.SetDistance(theDistance);
+// aTI.SetShape(theObject->GetValue());
+ aTI.SetOriginal(aLastFunction);
+
+ //Compute the translation
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Translation driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ if (theCopy) {
+ GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance("
+ << theObject << ", " << theVector << ", " << theDistance << ")";
+ SetErrorCode(OK);
+ return aCopy;
+ }
+
+ GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVectorDistance("
+ << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")";
+ SetErrorCode(OK);
+ return theObject;
+}
+
//=============================================================================
/*!
* Translate1D
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Translation driver failed");
return NULL;
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Translation driver failed");
return NULL;
//Compute the mirror
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
//Compute the mirror
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
//Compute the mirror
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
//Compute the mirror
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
//Compute the mirror
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
//Compute the mirror
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
//Compute the offset
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Offset driver failed");
return NULL;
//Compute the offset
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Offset driver failed");
return NULL;
//Compute the scale
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Scale driver failed");
return NULL;
//Compute the scale
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Scale driver failed");
return NULL;
{
SetErrorCode(KO);
- if (theObject.IsNull() || theStartLCS.IsNull() || theEndLCS.IsNull()) return NULL;
+ if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
- // Get last functions of the arguments
- Handle(GEOM_Function) aStartLCS = theStartLCS->GetLastFunction();
- Handle(GEOM_Function) aEndLCS = theEndLCS->GetLastFunction();
-
//Add a Position function
+ Standard_Integer aType = POSITION_SHAPE;
+ if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
+
Handle(GEOM_Function) aFunction =
- theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_SHAPE);
+ theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
+ //Set operation arguments
GEOMImpl_IPosition aTI (aFunction);
aTI.SetShape(anOriginal);
- aTI.SetStartLCS(aStartLCS);
- aTI.SetEndLCS(aEndLCS);
+ aTI.SetEndLCS(theEndLCS->GetLastFunction());
+ if (!theStartLCS.IsNull())
+ aTI.SetStartLCS(theStartLCS->GetLastFunction());
//Compute the Position
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Position driver failed");
return NULL;
{
SetErrorCode(KO);
- if (theObject.IsNull() || theStartLCS.IsNull() || theEndLCS.IsNull()) return NULL;
+ if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
//Add a position function
+ Standard_Integer aType = POSITION_SHAPE_COPY;
+ if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
+
Handle(GEOM_Function) aFunction =
- aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_SHAPE_COPY);
+ aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
GEOMImpl_IPosition aTI (aFunction);
aTI.SetShape(anOriginal);
- aTI.SetStartLCS(theStartLCS->GetLastFunction());
aTI.SetEndLCS(theEndLCS->GetLastFunction());
+ if (!theStartLCS.IsNull())
+ aTI.SetStartLCS(theStartLCS->GetLastFunction());
//Compute the position
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Position driver failed");
return NULL;
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Rotate driver failed");
return NULL;
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Rotate driver failed");
return NULL;
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Rotate driver failed");
return NULL;
//Compute the translation
try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Rotate driver failed");
return NULL;
SetErrorCode(OK);
return aCopy;
}
+
+//=============================================================================
+/*!
+ * 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_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ 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_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ 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;
+}
+