0031697: Foundation Classes - Expr_GeneralExpression::Derivative does not seem to...
[occt.git] / src / QABugs / QABugs_20.cxx
index 9f841bb..6c8a996 100644 (file)
@@ -3471,6 +3471,54 @@ static Standard_Integer OCC31294(Draw_Interpretor& di, Standard_Integer, const c
   return 0;
 }
 
+#include <ExprIntrp_GenExp.hxx>
+#include <Expr_GeneralExpression.hxx>
+#include <Expr_NamedUnknown.hxx>
+//=======================================================================
+//function :  OCC31697
+//purpose  : 
+//=======================================================================
+static Standard_Integer OCC31697(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+  if (argc < 3)
+  {
+    di << "Usage : " << argv[0] << " expression  variable\n";
+    return 1;
+  }
+
+  TCollection_AsciiString  anExpStr(argv[1]);
+  TCollection_AsciiString  aVarStr(argv[2]);
+
+  Handle(ExprIntrp_GenExp) exprIntrp = ExprIntrp_GenExp::Create();
+
+  //
+  // Create the expression
+  exprIntrp->Process(anExpStr);
+
+  if (!exprIntrp->IsDone())
+  {
+    di << "Interpretation of expression " << argv[1] << " failed\n";
+    return 1;
+  }
+
+  Handle(Expr_GeneralExpression) anExpr = exprIntrp->Expression();
+  Handle(Expr_NamedUnknown) aVar = new Expr_NamedUnknown(aVarStr);
+
+  if (!anExpr->Contains(aVar))
+  {
+    di << "Expression " << argv[1] << " does not contain variable " << argv[2] << "\n";
+    return 1;
+  }
+
+  Handle(Expr_GeneralExpression) aDer = anExpr->Derivative(aVar);
+
+  TCollection_AsciiString  aDerStr = aDer->String();
+
+  di << "The derivative of the " << argv[1] << " by " << argv[2] << " is equal to " << aDerStr << "\n";
+
+  return 0;
+}
+
 void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -3537,5 +3585,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   theCommands.Add("OCC30704_1", "OCC30704_1", __FILE__, OCC30704_1, group);
   theCommands.Add("OCC31294", "OCC31294", __FILE__, OCC31294, group);
 
+  theCommands.Add("OCC31697", "OCC31697 expression variable", __FILE__, OCC31697, group);
+
   return;
 }