From f5b9e11841ae07f5d7ef57405bd9882cf6677502 Mon Sep 17 00:00:00 2001 From: gka Date: Mon, 24 Apr 2006 07:43:11 +0000 Subject: [PATCH] Add method for getting tangent on curve by parameter --- src/GEOMImpl/GEOMImpl_IBasicOperations.cxx | 49 ++++++++++++++++++++++ src/GEOMImpl/GEOMImpl_IBasicOperations.hxx | 3 ++ 2 files changed, 52 insertions(+) diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx index 9a7ba439c..a29b7f90c 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -221,6 +221,55 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve return aPoint; } +//============================================================================= +/*! + * MakeTangentOnCurve + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeTangentOnCurve + (const Handle(GEOM_Object)& theCurve, double theParameter) +{ + SetErrorCode(KO); + + if (theCurve.IsNull()) return NULL; + + //Add a new Vector object + Handle(GEOM_Object) aVec = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR); + + //Add a new Point function for creation a point relativley another point + Handle(GEOM_Function) aFunction = aVec->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TANGENT_CURVE_PAR); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL; + + GEOMImpl_IVector aVI (aFunction); + + Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction(); + if (aRefFunction.IsNull()) return NULL; + + aVI.SetCurve(aRefFunction); + aVI.SetParameter(theParameter); + + //Compute the vector value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Vector 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) << aVec << " = geompy.MakeTangentOnCurve(" + << theCurve << ", " << theParameter << ")"; + + SetErrorCode(OK); + return aVec; +} //============================================================================= /*! diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx index 7106f4cd9..36aa0afcb 100644 --- a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx @@ -47,6 +47,9 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeVectorTwoPnt (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2); + Standard_EXPORT Handle(GEOM_Object) MakeTangentOnCurve(const Handle(GEOM_Object)& theCurve, + double theParameter); + // Line Standard_EXPORT Handle(GEOM_Object) MakeLineTwoPnt (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2); -- 2.39.2