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);
150 vtkGetStringMacro(Function);
157 int IsScalarResult();
163 int IsVectorResult();
168 double GetScalarResult();
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)
VTK_SIZEHINT(3);
223 double *r = this->GetVectorVariableValue(variableName);
227 double *r = this->GetVectorVariableValue(i);
235 {
return static_cast<int>(this->ScalarVariableNames.size()); }
240 int GetScalarVariableIndex(
const char *
name);
246 {
return static_cast<int>(this->VectorVariableNames.size()); }
251 int GetVectorVariableIndex(
const char *
name);
256 const char* GetScalarVariableName(
int i);
261 const char* GetVectorVariableName(
int i);
269 bool GetScalarVariableNeeded(
int i);
270 bool GetScalarVariableNeeded(
const char* variableName);
279 bool GetVectorVariableNeeded(
int i);
280 bool GetVectorVariableNeeded(
const char* variableName);
286 void RemoveAllVariables();
291 void RemoveScalarVariables();
296 void RemoveVectorVariables();
308 vtkSetMacro(ReplacementValue,
double);
309 vtkGetMacro(ReplacementValue,
double);
315 void CheckExpression(
int &pos,
char **error);
320 void InvalidateFunction();
335 void CopyParseError(
int &
position,
char **error);
338 char* RemoveSpacesFrom(
const char* variableName);
339 int OperatorWithinVariable(
int idx);
341 int BuildInternalFunctionStructure();
342 void BuildInternalSubstringStructure(
int beginIndex,
int endIndex);
343 void AddInternalByte(
unsigned char newByte);
345 int IsSubstringCompletelyEnclosed(
int beginIndex,
int endIndex);
346 int FindEndOfMathFunction(
int beginIndex);
347 int FindEndOfMathConstant(
int beginIndex);
349 int IsVariableName(
int currentIndex);
350 int IsElementaryOperator(
int op);
352 int GetMathFunctionNumber(
int currentIndex);
353 int GetMathFunctionNumberByCheckingParenthesis(
int currentIndex );
354 int GetMathFunctionStringLength(
int mathFunctionNumber);
355 int GetMathConstantNumber(
int currentIndex);
356 int GetMathConstantStringLength(
int mathConstantNumber);
357 unsigned char GetElementaryOperatorNumber(
char op);
358 unsigned int GetOperandNumber(
int currentIndex);
359 int GetVariableNameLength(
int variableNumber);
361 int DisambiguateOperators();
367 void UpdateNeededVariables();
369 vtkSetStringMacro(ParseError);
371 int FindPositionInOriginalFunction(
const int& pos);