X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_I3DPrimOperations.cxx;h=12d2e4df2fd86486aad5a7471a93db6933c09381;hb=d31a3237c7845182896f0a2b9d276eb89a8e273f;hp=cbadd3a4996d9cd6e4e636ab8e3add3e1e53c63a;hpb=3468a943e05903238dbf37e7925c8e32fcb4241d;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index cbadd3a49..12d2e4df2 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 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 @@ -18,10 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include -#include +#include #include @@ -1293,6 +1294,88 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways return aPrism; } +//============================================================================= +/*! + * MakeDraftPrism + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism + (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse) +{ + SetErrorCode(KO); + + if (theBase.IsNull() || theInitShape.IsNull()) return NULL; + + Handle(GEOM_Object) aPrism = NULL; + + if ( theFuse ) + { + //Add a new Extruded Boss object + aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS); + } + else + { + //Add a new Extruded Cut object + aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT); + } + + //Add a new Prism function for the creation of a Draft Prism feature + Handle(GEOM_Function) aFunction = + aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL; + + GEOMImpl_IPrism aCI (aFunction); + + Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction(); + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + + if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL; + + // Set parameters + aCI.SetBase(aRefBase); + aCI.SetInitShape(aRefInit); + aCI.SetH(theHeight); + aCI.SetDraftAngle(theAngle); + if ( theFuse ) + aCI.SetFuseFlag(1); + else + aCI.SetFuseFlag(0); + + //Compute the Draft Prism Feature value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Extrusion can not be created, check input data"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + if(theFuse) + { + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss(" + << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")"; + } + else + { + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut(" + << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")"; + } + + SetErrorCode(OK); + return aPrism; +} + //============================================================================= /*! * MakePipe @@ -1404,7 +1487,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle( //Make a Python command GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution(" - << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; + << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)"; SetErrorCode(OK); return aRevolution; @@ -1462,7 +1545,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways //Make a Python command GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways(" - << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; + << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)"; SetErrorCode(OK); return aRevolution;