Go to the documentation of this file.
49 #ifndef vtkFunctionParser_h
50 #define vtkFunctionParser_h
52 #include "vtkCommonMiscModule.h"
58 #define VTK_PARSER_IMMEDIATE 1
59 #define VTK_PARSER_UNARY_MINUS 2
60 #define VTK_PARSER_UNARY_PLUS 3
63 #define VTK_PARSER_ADD 4
64 #define VTK_PARSER_SUBTRACT 5
65 #define VTK_PARSER_MULTIPLY 6
66 #define VTK_PARSER_DIVIDE 7
67 #define VTK_PARSER_POWER 8
68 #define VTK_PARSER_ABSOLUTE_VALUE 9
69 #define VTK_PARSER_EXPONENT 10
70 #define VTK_PARSER_CEILING 11
71 #define VTK_PARSER_FLOOR 12
72 #define VTK_PARSER_LOGARITHM 13
73 #define VTK_PARSER_LOGARITHME 14
74 #define VTK_PARSER_LOGARITHM10 15
75 #define VTK_PARSER_SQUARE_ROOT 16
76 #define VTK_PARSER_SINE 17
77 #define VTK_PARSER_COSINE 18
78 #define VTK_PARSER_TANGENT 19
79 #define VTK_PARSER_ARCSINE 20
80 #define VTK_PARSER_ARCCOSINE 21
81 #define VTK_PARSER_ARCTANGENT 22
82 #define VTK_PARSER_HYPERBOLIC_SINE 23
83 #define VTK_PARSER_HYPERBOLIC_COSINE 24
84 #define VTK_PARSER_HYPERBOLIC_TANGENT 25
85 #define VTK_PARSER_MIN 26
86 #define VTK_PARSER_MAX 27
87 #define VTK_PARSER_SIGN 29
90 #define VTK_PARSER_CROSS 28
91 #define VTK_PARSER_VECTOR_UNARY_MINUS 30
92 #define VTK_PARSER_VECTOR_UNARY_PLUS 31
93 #define VTK_PARSER_DOT_PRODUCT 32
94 #define VTK_PARSER_VECTOR_ADD 33
95 #define VTK_PARSER_VECTOR_SUBTRACT 34
96 #define VTK_PARSER_SCALAR_TIMES_VECTOR 35
97 #define VTK_PARSER_VECTOR_TIMES_SCALAR 36
98 #define VTK_PARSER_VECTOR_OVER_SCALAR 37
99 #define VTK_PARSER_MAGNITUDE 38
100 #define VTK_PARSER_NORMALIZE 39
103 #define VTK_PARSER_IHAT 40
104 #define VTK_PARSER_JHAT 41
105 #define VTK_PARSER_KHAT 42
108 #define VTK_PARSER_IF 43
111 #define VTK_PARSER_VECTOR_IF 44
114 #define VTK_PARSER_LESS_THAN 45
117 #define VTK_PARSER_GREATER_THAN 46
120 #define VTK_PARSER_EQUAL_TO 47
123 #define VTK_PARSER_AND 48
126 #define VTK_PARSER_OR 49
131 #define VTK_PARSER_BEGIN_VARIABLES 50
134 #define VTK_PARSER_ERROR_RESULT VTK_FLOAT_MAX
160 int IsScalarResult();
166 int IsVectorResult();
171 double GetScalarResult();
177 double* GetVectorResult();
178 void GetVectorResult(
double result[3]) {
179 double *r = this->GetVectorResult();
180 result[0] = r[0]; result[1] = r[1]; result[2] = r[2]; };
210 double yValue,
double zValue);
212 const double values[3]) {
213 this->SetVectorVariableValue(variableName,values[0],values[1],values[2]);};
217 this->SetVectorVariableValue(i,values[0],values[1],values[2]);};
226 double *r = this->GetVectorVariableValue(variableName);
230 double *r = this->GetVectorVariableValue(i);
238 {
return static_cast<int>(this->ScalarVariableNames.size()); }
244 {
return static_cast<int>(this->VectorVariableNames.size()); }
299 vtkGetMacro(ReplaceInvalidValues,
int);
302 vtkGetMacro(ReplacementValue,
double);
331 char* RemoveSpacesFrom(const
char* variableName);
332 int OperatorWithinVariable(
int idx);
334 int BuildInternalFunctionStructure();
335 void BuildInternalSubstringStructure(
int beginIndex,
int endIndex);
336 void AddInternalByte(
unsigned char newByte);
338 int IsSubstringCompletelyEnclosed(
int beginIndex,
int endIndex);
339 int FindEndOfMathFunction(
int beginIndex);
340 int FindEndOfMathConstant(
int beginIndex);
342 int IsVariableName(
int currentIndex);
343 int IsElementaryOperator(
int op);
345 int GetMathFunctionNumber(
int currentIndex);
346 int GetMathFunctionNumberByCheckingParenthesis(
int currentIndex );
347 int GetMathFunctionStringLength(
int mathFunctionNumber);
348 int GetMathConstantNumber(
int currentIndex);
349 int GetMathConstantStringLength(
int mathConstantNumber);
350 unsigned char GetElementaryOperatorNumber(
char op);
351 unsigned char GetOperandNumber(
int currentIndex);
352 int GetVariableNameLength(
int variableNumber);
354 int DisambiguateOperators();
360 void UpdateNeededVariables();
362 vtkSetStringMacro(ParseError);
364 int FindPositionInOriginalFunction(const
int& pos);
367 char* FunctionWithSpaces;
370 std::
vector<std::
string> ScalarVariableNames;
371 std::
vector<std::
string> VectorVariableNames;
372 std::
vector<
double> ScalarVariableValues;
377 unsigned char *ByteCode;
391 int ReplaceInvalidValues;
392 double ReplacementValue;
394 int ParseErrorPositon;
double GetScalarVariableValue(int i)
bool GetVectorVariableNeeded(const char *variableName)
const char * GetVectorVariableName(int i)
Get the ith vector variable name.
void SetVectorVariableValue(int i, const double values[3])
record modification and/or execution time
void InvalidateFunction()
Allow the user to force the function to be re-parsed.
abstract base class for most VTK objects
void SetVectorVariableValue(int i, double xValue, double yValue, double zValue)
bool GetScalarVariableNeeded(int i)
Returns whether a scalar variable is needed for the function evaluation.
void RemoveScalarVariables()
Remove all the scalar variables.
void SetScalarVariableValue(int i, double value)
static vtkFunctionParser * New()
bool GetScalarVariableNeeded(const char *variableName)
vtkTypeUInt64 vtkMTimeType
void SetVectorVariableValue(const char *variableName, const double values[3])
void GetVectorVariableValue(const char *variableName, double value[3])
void CheckExpression(int &pos, char **error)
Check the validity of the function expression.
a simple class to control print indentation
void SetScalarVariableValue(const char *variableName, double value)
Set the value of a scalar variable.
bool GetVectorVariableNeeded(int i)
Returns whether a vector variable is needed for the function evaluation.
double GetScalarVariableValue(const char *variableName)
Get the value of a scalar variable.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkMTimeType GetMTime() override
Return parser's MTime.
~vtkFunctionParser() override
void GetVectorVariableValue(int i, double value[3])
double * GetVectorVariableValue(int i)
Parse and evaluate a mathematical expression.
const char * GetScalarVariableName(int i)
Get the ith scalar variable name.
void RemoveVectorVariables()
Remove all the vector variables.
int GetNumberOfScalarVariables()
Get the number of scalar variables.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
templated base type for containers of constant size.
int GetNumberOfVectorVariables()
Get the number of vector variables.
void SetVectorVariableValue(const char *variableName, double xValue, double yValue, double zValue)
Set the value of a vector variable.
double * GetVectorVariableValue(const char *variableName)
Get the value of a vector variable.
void RemoveAllVariables()
Remove all the current variables.