46 #ifndef vtkFunctionParser_h
47 #define vtkFunctionParser_h
49 #include "vtkCommonMiscModule.h"
55 #define VTK_PARSER_IMMEDIATE 1
56 #define VTK_PARSER_UNARY_MINUS 2
57 #define VTK_PARSER_UNARY_PLUS 3
60 #define VTK_PARSER_ADD 4
61 #define VTK_PARSER_SUBTRACT 5
62 #define VTK_PARSER_MULTIPLY 6
63 #define VTK_PARSER_DIVIDE 7
64 #define VTK_PARSER_POWER 8
65 #define VTK_PARSER_ABSOLUTE_VALUE 9
66 #define VTK_PARSER_EXPONENT 10
67 #define VTK_PARSER_CEILING 11
68 #define VTK_PARSER_FLOOR 12
69 #define VTK_PARSER_LOGARITHM 13
70 #define VTK_PARSER_LOGARITHME 14
71 #define VTK_PARSER_LOGARITHM10 15
72 #define VTK_PARSER_SQUARE_ROOT 16
73 #define VTK_PARSER_SINE 17
74 #define VTK_PARSER_COSINE 18
75 #define VTK_PARSER_TANGENT 19
76 #define VTK_PARSER_ARCSINE 20
77 #define VTK_PARSER_ARCCOSINE 21
78 #define VTK_PARSER_ARCTANGENT 22
79 #define VTK_PARSER_HYPERBOLIC_SINE 23
80 #define VTK_PARSER_HYPERBOLIC_COSINE 24
81 #define VTK_PARSER_HYPERBOLIC_TANGENT 25
82 #define VTK_PARSER_MIN 26
83 #define VTK_PARSER_MAX 27
84 #define VTK_PARSER_SIGN 29
87 #define VTK_PARSER_CROSS 28
88 #define VTK_PARSER_VECTOR_UNARY_MINUS 30
89 #define VTK_PARSER_VECTOR_UNARY_PLUS 31
90 #define VTK_PARSER_DOT_PRODUCT 32
91 #define VTK_PARSER_VECTOR_ADD 33
92 #define VTK_PARSER_VECTOR_SUBTRACT 34
93 #define VTK_PARSER_SCALAR_TIMES_VECTOR 35
94 #define VTK_PARSER_VECTOR_TIMES_SCALAR 36
95 #define VTK_PARSER_VECTOR_OVER_SCALAR 37
96 #define VTK_PARSER_MAGNITUDE 38
97 #define VTK_PARSER_NORMALIZE 39
100 #define VTK_PARSER_IHAT 40
101 #define VTK_PARSER_JHAT 41
102 #define VTK_PARSER_KHAT 42
105 #define VTK_PARSER_IF 43
108 #define VTK_PARSER_VECTOR_IF 44
111 #define VTK_PARSER_LESS_THAN 45
114 #define VTK_PARSER_GREATER_THAN 46
117 #define VTK_PARSER_EQUAL_TO 47
120 #define VTK_PARSER_AND 48
123 #define VTK_PARSER_OR 49
128 #define VTK_PARSER_BEGIN_VARIABLES 50
131 #define VTK_PARSER_ERROR_RESULT VTK_FLOAT_MAX
149 void SetFunction(const
char *
function);
157 int IsScalarResult();
163 int IsVectorResult();
168 double GetScalarResult();
174 double* GetVectorResult();
175 void GetVectorResult(
double result[3]) {
176 double *r = this->GetVectorResult();
177 result[0] = r[0]; result[1] = r[1]; result[2] = r[2]; };
187 void SetScalarVariableValue(
const char* variableName,
double value);
188 void SetScalarVariableValue(
int i,
double value);
195 double GetScalarVariableValue(
const char* variableName);
196 double GetScalarVariableValue(
int i);
206 void SetVectorVariableValue(
const char* variableName,
double xValue,
207 double yValue,
double zValue);
209 const double values[3]) {
210 this->SetVectorVariableValue(variableName,values[0],values[1],values[2]);};
211 void SetVectorVariableValue(
int i,
double xValue,
double yValue,
214 this->SetVectorVariableValue(i,values[0],values[1],values[2]);};
221 double* GetVectorVariableValue(
const char* variableName);
223 double *r = this->GetVectorVariableValue(variableName);
224 value[0] = r[0]; value[1] = r[1]; value[2] = r[2]; };
225 double* GetVectorVariableValue(
int i);
227 double *r = this->GetVectorVariableValue(i);
228 value[0] = r[0]; value[1] = r[1]; value[2] = r[2]; };
235 {
return static_cast<int>(this->ScalarVariableNames.size()); }
241 {
return static_cast<int>(this->VectorVariableNames.size()); }
246 const char* GetScalarVariableName(
int i);
251 const char* GetVectorVariableName(
int i);
259 bool GetScalarVariableNeeded(
int i);
260 bool GetScalarVariableNeeded(
const char* variableName);
269 bool GetVectorVariableNeeded(
int i);
270 bool GetVectorVariableNeeded(
const char* variableName);
276 void RemoveAllVariables();
281 void RemoveScalarVariables();
286 void RemoveVectorVariables();
296 vtkGetMacro(ReplaceInvalidValues,
int);
299 vtkGetMacro(ReplacementValue,
double);
305 void CheckExpression(
int &pos,
char **error);
310 void InvalidateFunction();
325 void CopyParseError(
int &
position,
char **error);
328 char* RemoveSpacesFrom(const
char* variableName);
329 int OperatorWithinVariable(
int idx);
331 int BuildInternalFunctionStructure();
332 void BuildInternalSubstringStructure(
int beginIndex,
int endIndex);
333 void AddInternalByte(
unsigned char newByte);
335 int IsSubstringCompletelyEnclosed(
int beginIndex,
int endIndex);
336 int FindEndOfMathFunction(
int beginIndex);
337 int FindEndOfMathConstant(
int beginIndex);
339 int IsVariableName(
int currentIndex);
340 int IsElementaryOperator(
int op);
342 int GetMathFunctionNumber(
int currentIndex);
343 int GetMathFunctionNumberByCheckingParenthesis(
int currentIndex );
344 int GetMathFunctionStringLength(
int mathFunctionNumber);
345 int GetMathConstantNumber(
int currentIndex);
346 int GetMathConstantStringLength(
int mathConstantNumber);
347 unsigned char GetElementaryOperatorNumber(
char op);
348 unsigned char GetOperandNumber(
int currentIndex);
349 int GetVariableNameLength(
int variableNumber);
351 int DisambiguateOperators();
357 void UpdateNeededVariables();
359 vtkSetStringMacro(ParseError);
361 int FindPositionInOriginalFunction(const
int& pos);
364 char* FunctionWithSpaces;
367 std::
vector<std::
string> ScalarVariableNames;
368 std::
vector<std::
string> VectorVariableNames;
369 std::
vector<
double> ScalarVariableValues;
374 unsigned char *ByteCode;
388 int ReplaceInvalidValues;
389 double ReplacementValue;
391 int ParseErrorPositon;
void SetVectorVariableValue(int i, const double values[3])
Set the value of a vector variable.
abstract base class for most VTK objects
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeUInt32 vtkMTimeType
record modification and/or execution time
void SetVectorVariableValue(const char *variableName, const double values[3])
Set the value of a vector variable.
templated base type for containers of constant size.
Parse and evaluate a mathematical expression.
a simple class to control print indentation
void GetVectorVariableValue(const char *variableName, double value[3])
Get the value of a vector variable.
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void GetVectorVariableValue(int i, double value[3])
Get the value of a vector variable.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
int GetNumberOfScalarVariables()
Get the number of scalar variables.
int GetNumberOfVectorVariables()
Get the number of vector variables.