]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Add method for getting tangent on curve by parameter
authorgka <gka@opencascade.com>
Mon, 24 Apr 2006 07:43:11 +0000 (07:43 +0000)
committergka <gka@opencascade.com>
Mon, 24 Apr 2006 07:43:11 +0000 (07:43 +0000)
src/GEOMImpl/GEOMImpl_IBasicOperations.cxx
src/GEOMImpl/GEOMImpl_IBasicOperations.hxx

index 9a7ba439c387645d142b02d2581fad04fd0b2d2a..a29b7f90c3aeaaa714fa4693eb3f1f79a97682a7 100644 (file)
@@ -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;
+}
 
 //=============================================================================
 /*!
index 7106f4cd98da2d25946427e81b2263b57eb4a921..36aa0afcbfa1668efc81b67b470c07c881ba8666 100644 (file)
@@ -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);