From d14cfb530818c8571a82a83ab53e9b1ce940c054 Mon Sep 17 00:00:00 2001 From: gka Date: Mon, 15 May 2006 13:56:15 +0000 Subject: [PATCH] Added tangent plane for face --- idl/GEOM_Gen.idl | 14 ++++++ idl/GEOM_Superv.idl | 14 ++++++ src/GEOMImpl/GEOMImpl_IBasicOperations.cxx | 57 ++++++++++++++++++++++ src/GEOMImpl/GEOMImpl_IBasicOperations.hxx | 6 +++ src/GEOMImpl/GEOMImpl_IPlane.hxx | 10 ++++ src/GEOM_I/GEOM_IBasicOperations_i.cc | 36 ++++++++++++++ src/GEOM_I/GEOM_IBasicOperations_i.hh | 5 ++ src/GEOM_I_Superv/GEOM_Superv_i.cc | 13 +++++ src/GEOM_I_Superv/GEOM_Superv_i.hh | 5 ++ 9 files changed, 160 insertions(+) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index cd043a608..44892982f 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -357,6 +357,20 @@ module GEOM GEOM_Object MakeMarker (in double theOX , in double theOY , in double theOZ, in double theXDX, in double theXDY, in double theXDZ, in double theYDX, in double theYDY, in double theYDZ); + + /*! + * Create a tangent plane to specified face in the point with specified parameters. + * Values of parameters should be between 0. and 1.0 + * \param theFace - face for which tangent plane shuold be built. + * \param theParameterU - value of parameter by U + * \param theParameterV - value of parameter Vthe + * \param theTrimSize - defines sizes of created face + * \return New GEOM_Object, containing the face built on tangent plane. + */ + GEOM_Object MakeTangentPlaneOnFace(in GEOM_Object theFace, + in double theParameterU, + in double theParameterV, + in double theTrimSize); }; interface GEOM_ITransformOperations : GEOM_IOperations diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 40faded97..3d5d15a17 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -96,6 +96,20 @@ module GEOM in double theXDX, in double theXDY, in double theXDZ, in double theYDX, in double theYDY, in double theYDZ) ; + /*! + * Create a tangent plane to specified face in the point with specified parameters. + * Values of parameters should be between 0. and 1.0 + * \param theFace - face for which tangent plane shuold be built. + * \param theParameterU - value of parameter by U + * \param theParameterV - value of parameter Vthe + * \param theTrimSize - defines sizes of created face + * \return New GEOM_Object, containing the face built on tangent plane. + */ + GEOM_Object MakeTangentPlaneOnFace(in GEOM_Object theFace, + in double theParameterU, + in double theParameterV, + in double theTrimSize); + //-----------------------------------------------------------// // Primitives Construction : 3DPrimOperations // //-----------------------------------------------------------// diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx index a29b7f90c..b23389335 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -690,3 +690,60 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker SetErrorCode(OK); return aMarker; } + +//============================================================================= +/*! + * MakeTangentPlaneOnFace + */ +//============================================================================= + +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace, + double theParamU, + double theParamV, + double theSize) +{ + SetErrorCode(KO); + + if (theFace.IsNull()) return NULL; + + //Add a new Plane object + Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE); + + //Add a new Plane function + Handle(GEOM_Function) aFunction = + aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_TANGENT_FACE); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL; + + GEOMImpl_IPlane aPI (aFunction); + + Handle(GEOM_Function) aRef = theFace->GetLastFunction(); + if (aRef.IsNull()) return NULL; + + aPI.SetFace(aRef); + aPI.SetSize(theSize); + aPI.SetParameterU(theParamU); + aPI.SetParameterV(theParamV); + + //Compute the Plane value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Plane 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) << aPlane << " = geompy.MakeTangentPlaneOnFace(" + << theFace << ", " <GetReference(PLN_ARG_PNT1); } Handle(GEOM_Function) GetPoint2() { return _func->GetReference(PLN_ARG_PNT2); } Handle(GEOM_Function) GetPoint3() { return _func->GetReference(PLN_ARG_PNT3); } + + void SetParameterU(double theParamU) { _func->SetReal(PLN_ARG_PARAM_U, theParamU); } + double GetParameterU() { return _func->GetReal(PLN_ARG_PARAM_U); } + + void SetParameterV(double theParamV) { _func->SetReal(PLN_ARG_PARAM_V, theParamV); } + double GetParameterV() { return _func->GetReal(PLN_ARG_PARAM_V); } private: diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.cc b/src/GEOM_I/GEOM_IBasicOperations_i.cc index b67314b0b..cc5fa043a 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.cc +++ b/src/GEOM_I/GEOM_IBasicOperations_i.cc @@ -419,3 +419,39 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker return GetObject(anObject); } + +//============================================================================= +/*! + * MakeTangentPlaneOnFace + */ +//============================================================================= + +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeTangentPlaneOnFace + (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theParameterU, + CORBA::Double theParameterV, + CORBA::Double theTrimSize) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theFace == NULL) return aGEOMObject._retn(); + + //Get the reference face + + Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject + (theFace->GetStudyID(), theFace->GetEntry()); + if (aRef.IsNull()) return aGEOMObject._retn(); + + //Create the plane + + Handle(GEOM_Object) anObject = + GetOperations()->MakeTangentPlaneOnFace(aRef, theParameterU,theParameterV,theTrimSize); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.hh b/src/GEOM_I/GEOM_IBasicOperations_i.hh index 8cee133b5..b4d3db0cf 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.hh +++ b/src/GEOM_I/GEOM_IBasicOperations_i.hh @@ -84,6 +84,11 @@ class GEOM_IBasicOperations_i : CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ, CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ); + GEOM::GEOM_Object_ptr MakeTangentPlaneOnFace (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theParameterU, + CORBA::Double theParameterV, + CORBA::Double theTrimSize); + ::GEOMImpl_IBasicOperations* GetOperations() { return (::GEOMImpl_IBasicOperations*)GetImpl(); } }; diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 0150c5e9d..d53601a3e 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -630,6 +630,19 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeMarker return myBasicOp->MakeMarker(theOX, theOY, theOZ, theXDX, theXDY, theXDZ, theYDX, theYDY, theYDZ); } +//============================================================================= +// MakeTangentPlaneOnFace: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeTangentPlaneOnFace (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theParameterU, + CORBA::Double theParameterV, + CORBA::Double theTrimSize) +{ + MESSAGE("GEOM_Superv_i::MakeTangentPlaneOnFace"); + getBasicOp(); + return myBasicOp->MakeTangentPlaneOnFace(theFace, theParameterU,theParameterV,theTrimSize); +} + //================= Primitives Construction : 3DPrimOperations ================ //============================================================================= // MakeBox: diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 6b143ff66..733d7d955 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -164,6 +164,11 @@ public: CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ, CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ); + GEOM::GEOM_Object_ptr MakeTangentPlaneOnFace (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theParameterU, + CORBA::Double theParameterV, + CORBA::Double theTrimSize); + //-----------------------------------------------------------// // Primitives Construction : 3DPrimOperations // //-----------------------------------------------------------// -- 2.39.2