0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / Expr / Expr_GeneralExpression.hxx
CommitLineData
42cf5bc1 1// Created on: 1991-01-10
2// Created by: Arnaud BOUZY
3// Copyright (c) 1991-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _Expr_GeneralExpression_HeaderFile
18#define _Expr_GeneralExpression_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
25e59720 23#include <Standard_Transient.hxx>
42cf5bc1 24#include <Standard_Integer.hxx>
25#include <Standard_Boolean.hxx>
26#include <Standard_Real.hxx>
27#include <Expr_Array1OfNamedUnknown.hxx>
28#include <TColStd_Array1OfReal.hxx>
29class Standard_OutOfRange;
30class Standard_NumericError;
31class Expr_NotEvaluable;
32class Expr_InvalidOperand;
33class Expr_NamedUnknown;
34class TCollection_AsciiString;
35
36
37class Expr_GeneralExpression;
25e59720 38DEFINE_STANDARD_HANDLE(Expr_GeneralExpression, Standard_Transient)
42cf5bc1 39
40//! Defines the general purposes of any expression.
25e59720 41class Expr_GeneralExpression : public Standard_Transient
42cf5bc1 42{
43
44public:
45
46
47 //! Returns the number of sub-expressions contained
48 //! in <me> ( >= 0)
49 Standard_EXPORT virtual Standard_Integer NbSubExpressions() const = 0;
50
51 //! Returns the <I>-th sub-expression of <me>
52 //! raises OutOfRange if <I> > NbSubExpressions(me)
53 Standard_EXPORT virtual const Handle(Expr_GeneralExpression)& SubExpression (const Standard_Integer I) const = 0;
54
55 //! Returns a GeneralExpression after replacement of
56 //! NamedUnknowns by an associated expression and after
57 //! values computation.
58 Standard_EXPORT virtual Handle(Expr_GeneralExpression) Simplified() const = 0;
59
60 //! Returns a GeneralExpression after a simplification
61 //! of the arguments of <me>.
62 Standard_EXPORT virtual Handle(Expr_GeneralExpression) ShallowSimplified() const = 0;
63
64 //! Returns a copy of <me> having the same unknowns and
65 //! functions.
66 Standard_EXPORT virtual Handle(Expr_GeneralExpression) Copy() const = 0;
67
68 //! Tests if <me> contains NamedUnknowns.
69 Standard_EXPORT virtual Standard_Boolean ContainsUnknowns() const = 0;
70
71 //! Tests if <exp> is contained in <me>.
72 Standard_EXPORT virtual Standard_Boolean Contains (const Handle(Expr_GeneralExpression)& exp) const = 0;
73
74 //! Tests if <me> is linear on every NamedUnknown it
75 //! contains.
76 Standard_EXPORT virtual Standard_Boolean IsLinear() const = 0;
77
78 //! Tests if <me> can be shared by one or more expressions
79 //! or must be copied. This method returns False as a
80 //! default value. To be redefined ( especially for
81 //! NamedUnknown).
82 Standard_EXPORT virtual Standard_Boolean IsShareable() const;
83
84 //! Tests if <me> and <Other> define the same expression.
85 //! Warning: This method does not include any simplification before
86 //! testing. It could also be very slow; to be used
87 //! carefully.
88 Standard_EXPORT virtual Standard_Boolean IsIdentical (const Handle(Expr_GeneralExpression)& Other) const = 0;
89
90 //! Returns the derivative on <X> unknown of <me>
91 Standard_EXPORT virtual Handle(Expr_GeneralExpression) Derivative (const Handle(Expr_NamedUnknown)& X) const = 0;
92
93 //! Returns the <N>-th derivative on <X> unknown of <me>.
94 //! Raise OutOfRange if N <= 0
95 Standard_EXPORT virtual Handle(Expr_GeneralExpression) NDerivative (const Handle(Expr_NamedUnknown)& X, const Standard_Integer N) const;
96
97 //! Replaces all occurences of <var> with copies of <with>
98 //! in <me>. Copies of <with> are made with the Copy() method.
99 //! Raises InvalidOperand if <with> contains <me>.
100 Standard_EXPORT virtual void Replace (const Handle(Expr_NamedUnknown)& var, const Handle(Expr_GeneralExpression)& with) = 0;
101
102 //! Returns the value of <me> (as a Real) by
103 //! replacement of <vars> by <vals>.
104 //! Raises NotEvaluable if <me> contains NamedUnknown not
105 //! in <vars> or NumericError if result cannot be computed.
106 Standard_EXPORT virtual Standard_Real Evaluate (const Expr_Array1OfNamedUnknown& vars, const TColStd_Array1OfReal& vals) const = 0;
107
108 //! Returns the value of <me> (as a Real) by
109 //! replacement of <vars> by <vals>.
110 //! Raises NotEvaluable if <me> contains NamedUnknown not
111 //! in <vars> or NumericError if result cannot be computed.
112 Standard_EXPORT Standard_Real EvaluateNumeric() const;
113
114 //! returns a string representing <me> in a readable way.
115 Standard_EXPORT virtual TCollection_AsciiString String() const = 0;
116
117
118
119
25e59720 120 DEFINE_STANDARD_RTTIEXT(Expr_GeneralExpression,Standard_Transient)
42cf5bc1 121
122protected:
123
124
125
126
127private:
128
129
130
131
132};
133
134
135
136
137
138
139
140#endif // _Expr_GeneralExpression_HeaderFile