Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:17:23

0001 // Created on: 1991-01-14
0002 // Created by: Arnaud BOUZY
0003 // Copyright (c) 1991-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Expr_NamedFunction_HeaderFile
0018 #define _Expr_NamedFunction_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <TCollection_AsciiString.hxx>
0024 #include <Expr_GeneralFunction.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <NCollection_Array1.hxx>
0027 class Expr_GeneralExpression;
0028 class Expr_NamedUnknown;
0029 
0030 class Expr_NamedFunction : public Expr_GeneralFunction
0031 {
0032 
0033 public:
0034   //! Creates a function of given variables <vars> with name
0035   //! <name> defined by the expression <exp>.
0036   Standard_EXPORT Expr_NamedFunction(
0037     const TCollection_AsciiString&                            name,
0038     const occ::handle<Expr_GeneralExpression>&                exp,
0039     const NCollection_Array1<occ::handle<Expr_NamedUnknown>>& vars);
0040 
0041   //! Sets the name <newname> to <me>.
0042   Standard_EXPORT void SetName(const TCollection_AsciiString& newname);
0043 
0044   //! Returns the name assigned to <me>
0045   Standard_EXPORT TCollection_AsciiString GetName() const;
0046 
0047   //! Returns the number of variables of <me>.
0048   Standard_EXPORT int NbOfVariables() const override;
0049 
0050   //! Returns the variable denoted by <index> in <me>.
0051   //! Raises OutOfRange if <index> is greater than
0052   //! NbOfVariables of <me>, or less than or equal to zero.
0053   Standard_EXPORT occ::handle<Expr_NamedUnknown> Variable(const int index) const override;
0054 
0055   //! Computes the value of <me> with the given variables.
0056   //! Raises DimensionMismatch if Length(vars) is different from
0057   //! Length(values).
0058   Standard_EXPORT double Evaluate(const NCollection_Array1<occ::handle<Expr_NamedUnknown>>& vars,
0059                                   const NCollection_Array1<double>& values) const override;
0060 
0061   //! Returns a copy of <me> with the same form.
0062   Standard_EXPORT occ::handle<Expr_GeneralFunction> Copy() const override;
0063 
0064   //! Returns Derivative of <me> for variable <var>.
0065   Standard_EXPORT occ::handle<Expr_GeneralFunction> Derivative(
0066     const occ::handle<Expr_NamedUnknown>& var) const override;
0067 
0068   //! Returns Derivative of <me> for variable <var> with
0069   //! degree <deg>.
0070   Standard_EXPORT occ::handle<Expr_GeneralFunction> Derivative(
0071     const occ::handle<Expr_NamedUnknown>& var,
0072     const int                             deg) const override;
0073 
0074   //! Tests if <me> and <func> are similar functions (same
0075   //! name and same used expression).
0076   Standard_EXPORT bool IsIdentical(const occ::handle<Expr_GeneralFunction>& func) const override;
0077 
0078   //! Tests if <me> is linear on variable on range <index>
0079   Standard_EXPORT bool IsLinearOnVariable(const int index) const override;
0080 
0081   Standard_EXPORT TCollection_AsciiString GetStringName() const override;
0082 
0083   //! Returns equivalent expression of <me>.
0084   Standard_EXPORT occ::handle<Expr_GeneralExpression> Expression() const;
0085 
0086   //! Modifies expression of <me>.
0087   //! Warning: Beware of derivatives. See FunctionDerivative
0088   Standard_EXPORT void SetExpression(const occ::handle<Expr_GeneralExpression>& exp);
0089 
0090   DEFINE_STANDARD_RTTIEXT(Expr_NamedFunction, Expr_GeneralFunction)
0091 
0092 private:
0093   TCollection_AsciiString                            myName;
0094   occ::handle<Expr_GeneralExpression>                myExp;
0095   NCollection_Array1<occ::handle<Expr_NamedUnknown>> myVariables;
0096 };
0097 
0098 #endif // _Expr_NamedFunction_HeaderFile