-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 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
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include <GEOMImpl_ITranslate.hxx>
#include <GEOMImpl_IMirror.hxx>
+#include <GEOMImpl_IProjection.hxx>
+#include <GEOMImpl_IProjOnCyl.hxx>
#include <GEOMImpl_IOffset.hxx>
#include <GEOMImpl_IScale.hxx>
#include <GEOMImpl_IRotate.hxx>
#include <GEOM_Function.hxx>
#include <GEOM_PythonDump.hxx>
-#include <Basics_OCCTVersion.hxx>
-
#include "utilities.h"
-#include <OpUtil.hxx>
#include <Utils_ExceptHandlers.hxx>
#include <TFunction_DriverTable.hxx>
#include <TFunction_Driver.hxx>
-#include <TFunction_Logbook.hxx>
#include <TDF_Tool.hxx>
#include <BRep_Tool.hxx>
*/
//=============================================================================
-GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
-: GEOM_IOperations(theEngine, theDocID)
+GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine)
+: GEOM_IOperations(theEngine)
{
MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
}
//Compute the translation
try {
-#if OCC_VERSION_LARGE > 0x06010000
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Compute the translation
try {
-#if OCC_VERSION_LARGE > 0x06010000
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a translate function
Handle(GEOM_Function) aFunction =
//Compute the translation
try {
-#if OCC_VERSION_LARGE > 0x06010000
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a translate function
Handle(GEOM_Function) aFunction =
//Compute the translation
try {
-#if OCC_VERSION_LARGE > 0x06010000
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Compute the translation
try {
-#if OCC_VERSION_LARGE > 0x06010000
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a translate function
Handle(GEOM_Function) aFunction =
//Compute the translation
try {
-#if OCC_VERSION_LARGE > 0x06010000
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Add a translate function
if (theCopy) {
- aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ aCopy = GetEngine()->AddObject(theObject->GetType());
aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
}
else {
//Compute the translation
try {
-#if OCC_VERSION_LARGE > 0x06010000
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(theObject->GetType());
//Add a translate function
Handle(GEOM_Function) aFunction =
//Compute the translation
try {
-#if OCC_VERSION_LARGE > 0x06010000
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(theObject->GetType());
//Add a translate function
Handle(GEOM_Function) aFunction =
//Compute the translation
try {
-#if OCC_VERSION_LARGE > 0x06010000
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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Compute the mirror
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a mirror function
Handle(GEOM_Function) aFunction =
//Compute the mirror
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Compute the mirror
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a mirror function
Handle(GEOM_Function) aFunction =
//Compute the mirror
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Compute the mirror
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a mirror function
Handle(GEOM_Function) aFunction =
//Compute the mirror
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Mirror driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
* OffsetShape
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
- (Handle(GEOM_Object) theObject, double theOffset)
+Handle(GEOM_Object)
+GEOMImpl_ITransformOperations::OffsetShape (Handle(GEOM_Object) theObject,
+ double theOffset,
+ bool theJoinByPipes)
{
SetErrorCode(KO);
if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
GEOMImpl_IOffset aTI (aFunction);
- aTI.SetShape(anOriginal);
- aTI.SetValue(theOffset);
+ aTI.SetShape( anOriginal );
+ aTI.SetValue( theOffset );
+ aTI.SetJoinByPipes( theJoinByPipes );
//Compute the offset
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Offset driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << "geompy.Offset("
- << theObject << ", " << theOffset << ")";
+ if (theJoinByPipes)
+ GEOM::TPythonDump(aFunction) << "geompy.Offset("
+ << theObject << ", " << theOffset << ")";
+ else
+ GEOM::TPythonDump(aFunction) << theObject << " = geompy.MakeOffsetIntersectionJoin("
+ << theObject << ", " << theOffset << ")";
SetErrorCode(OK);
return theObject;
* OffsetShapeCopy
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
- (Handle(GEOM_Object) theObject, double theOffset)
+Handle(GEOM_Object)
+GEOMImpl_ITransformOperations::OffsetShapeCopy( Handle(GEOM_Object) theObject,
+ double theOffset,
+ bool theJoinByPipes)
{
SetErrorCode(KO);
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a new Offset function
Handle(GEOM_Function) aFunction =
if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
GEOMImpl_IOffset aTI (aFunction);
- aTI.SetShape(anOriginal);
- aTI.SetValue(theOffset);
+ aTI.SetShape( anOriginal );
+ aTI.SetValue( theOffset );
+ aTI.SetJoinByPipes( theJoinByPipes );
//Compute the offset
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Offset driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Make a Python command
- GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
- << theObject << ", " << theOffset << ")";
+ if (theJoinByPipes)
+ GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
+ << theObject << ", " << theOffset << ")";
+ else
+ GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffsetIntersectionJoin("
+ << theObject << ", " << theOffset << ")";
SetErrorCode(OK);
return aCopy;
* ProjectShapeCopy
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy
- (Handle(GEOM_Object) theSource, Handle(GEOM_Object) theTarget)
+Handle(GEOM_Object)
+GEOMImpl_ITransformOperations::ProjectShapeCopy (Handle(GEOM_Object) theSource,
+ Handle(GEOM_Object) theTarget)
{
SetErrorCode(KO);
Handle(GEOM_Function) aLastFunction = theSource->GetLastFunction();
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be projected
+ Handle(GEOM_Object) aCopy;
+
+ TopoDS_Shape aTarget = theTarget->GetValue();
+ if ( aTarget.IsNull() ) return NULL;
+ if ( aTarget.ShapeType() == TopAbs_EDGE ||
+ aTarget.ShapeType() == TopAbs_WIRE )
+ {
+ // a TPythonDump prevents dumping ProjectPointOnWire(),
+ // dump of MakeProjection() is done at the end of this function
+ GEOM::TPythonDump preventDump(aLastFunction, /*append=*/true);
+ Standard_Integer dummy;
+ ProjectPointOnWire( theSource, theTarget, aCopy, dummy );
+ if ( aCopy.IsNull() || !IsDone() )
+ return NULL;
+ }
+ else
+ {
+ //Add a new Projection object
+ aCopy = GetEngine()->AddObject(GEOM_PROJECTION);
+
+ //Add a Projection function
+ Handle(GEOM_Function) aFunction =
+ aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY);
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL;
+
+ GEOMImpl_IMirror aTI (aFunction);
+ aTI.SetPlane(theTarget->GetLastFunction());
+ aTI.SetOriginal(aLastFunction);
+
+ //Compute the Projection
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Projection driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return NULL;
+ }
+ }
+
+ //Make a Python command
+ Handle(GEOM_Function) aFunction = aCopy->GetLastFunction();
+ GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection("
+ << theSource << ", " << theTarget << ")";
+
+ SetErrorCode(OK);
+ return aCopy;
+}
+
+//=============================================================================
+/*!
+ * ProjectPointOnWire
+ */
+//=============================================================================
+Standard_Real GEOMImpl_ITransformOperations::ProjectPointOnWire
+ (Handle(GEOM_Object) thePoint,
+ Handle(GEOM_Object) theWire,
+ Handle(GEOM_Object) &thePointOnEdge,
+ Standard_Integer &theEdgeInWireIndex)
+{
+ Standard_Real aResult = -1.;
+
+ SetErrorCode(KO);
+
+ if (thePoint.IsNull() || theWire.IsNull()) {
+ return aResult;
+ }
+
+ Handle(GEOM_Function) aLastFunction = thePoint->GetLastFunction();
+
+ if (aLastFunction.IsNull()) {
+ //There is no function which creates an object to be projected
+ return aResult;
+ }
+
//Add a new Projection object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
+ thePointOnEdge = GetEngine()->AddObject(GEOM_PROJECTION);
//Add a Projection function
- Handle(GEOM_Function) aFunction =
- aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY);
+ Handle(GEOM_Function) aFunction = thePointOnEdge->AddFunction
+ (GEOMImpl_ProjectionDriver::GetID(), PROJECTION_ON_WIRE);
//Check if the function is set correctly
- if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL;
+ if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) {
+ return aResult;
+ }
- GEOMImpl_IMirror aTI (aFunction);
- aTI.SetPlane(theTarget->GetLastFunction());
- aTI.SetOriginal(aLastFunction);
+ GEOMImpl_IProjection aProj (aFunction);
+ aProj.SetPoint(aLastFunction);
+ aProj.SetShape(theWire->GetLastFunction());
//Compute the Projection
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Projection driver failed");
- return NULL;
+ return aResult;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
- return NULL;
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return aResult;
}
+ aResult = aProj.GetU();
+ theEdgeInWireIndex = aProj.GetIndex();
+
+
//Make a Python command
- GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection("
- << theSource << ", " << theTarget << ")";
+ GEOM::TPythonDump(aFunction) << "(u, " << thePointOnEdge
+ << ", EdgeInWireIndex) = geompy.MakeProjectionOnWire(" << thePoint
+ << ", " << theWire << ")";
SetErrorCode(OK);
- return aCopy;
-}
+ return aResult;
+}
//=============================================================================
/*!
//Compute the scale
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Scale driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a scale function
Handle(GEOM_Function) aFunction =
//Compute the scale
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Scale driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
Handle(GEOM_Object) aCopy; //Add a new Copy object
Handle(GEOM_Function) aFunction;
if (doCopy) {
- aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ aCopy = GetEngine()->AddObject(theObject->GetType());
aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
}
else {
//Compute the scale
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Scale driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//Compute the Position
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Position driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
//Add a new Copy object
- Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a position function
Standard_Integer aType = POSITION_SHAPE_COPY;
//Compute the position
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Position driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
Handle(GEOM_Object) aCopy;
if (theCopy) {
- aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+ aCopy = GetEngine()->AddObject(theObject->GetType());
aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
}
else
//Compute the position
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Position driver failed");
return NULL;
}
}
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
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());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a rotate function
aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
//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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
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());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(theObject->GetType());
//Add a rotate function
aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
//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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
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());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(theObject->GetType());
//Add a rotate function
aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D_STEP);
//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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
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());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(theObject->GetType());
//Add a rotate function
aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
//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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
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());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(theObject->GetType());
//Add a rotate function
aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
//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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
//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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
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());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
//Add a rotate function
aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
//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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
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());
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GEOM_COPY);
// Add a transform function (depends on theSample function)
Handle(GEOM_Function) aFunction =
// 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());
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
return NULL;
}
SetErrorCode(OK);
return aCopy;
}
+
+//=============================================================================
+/*!
+ * MakeProjectionOnCylinder
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ITransformOperations::MakeProjectionOnCylinder
+ (const Handle(GEOM_Object) &theObject,
+ const Standard_Real theRadius,
+ const Standard_Real theStartAngle,
+ const Standard_Real theAngleLength,
+ const Standard_Real theAngleRotation)
+{
+ SetErrorCode(KO);
+
+ if (theObject.IsNull()) {
+ return NULL;
+ }
+
+ Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
+
+ if (aLastFunction.IsNull()) {
+ //There is no function which creates an object to be projected
+ return NULL;
+ }
+
+ //Add a new Projection object
+ Handle(GEOM_Object) aResult =
+ GetEngine()->AddObject(GEOM_PROJECTION);
+
+ //Add a Projection function
+ Handle(GEOM_Function) aFunction = aResult->AddFunction
+ (GEOMImpl_ProjectionDriver::GetID(), PROJECTION_ON_CYLINDER);
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) {
+ return aResult;
+ }
+
+ GEOMImpl_IProjOnCyl aProj (aFunction);
+
+ aProj.SetShape(aLastFunction);
+ aProj.SetRadius(theRadius);
+ aProj.SetStartAngle(theStartAngle);
+ aProj.SetAngleLength(theAngleLength);
+ aProj.SetAngleRotation(theAngleRotation);
+
+ //Compute the Projection
+ try {
+ OCC_CATCH_SIGNALS;
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Projection driver failed");
+ return aResult;
+ }
+ }
+ catch (Standard_Failure& aFail) {
+ SetErrorCode(aFail.GetMessageString());
+ return aResult;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump(aFunction)
+ << aResult << " = geompy.MakeProjectionOnCylinder("
+ << theObject << ", " << theRadius << ", " << theStartAngle
+ << ", " << theAngleLength << ", " << theAngleRotation << ")";
+
+ SetErrorCode(OK);
+
+ return aResult;
+}