45 #ifndef __vtkFunctionParser_h
46 #define __vtkFunctionParser_h
50 #define VTK_PARSER_IMMEDIATE 1
51 #define VTK_PARSER_UNARY_MINUS 2
54 #define VTK_PARSER_ADD 3
55 #define VTK_PARSER_SUBTRACT 4
56 #define VTK_PARSER_MULTIPLY 5
57 #define VTK_PARSER_DIVIDE 6
58 #define VTK_PARSER_POWER 7
59 #define VTK_PARSER_ABSOLUTE_VALUE 8
60 #define VTK_PARSER_EXPONENT 9
61 #define VTK_PARSER_CEILING 10
62 #define VTK_PARSER_FLOOR 11
63 #define VTK_PARSER_LOGARITHM 12
64 #define VTK_PARSER_LOGARITHME 13
65 #define VTK_PARSER_LOGARITHM10 14
66 #define VTK_PARSER_SQUARE_ROOT 15
67 #define VTK_PARSER_SINE 16
68 #define VTK_PARSER_COSINE 17
69 #define VTK_PARSER_TANGENT 18
70 #define VTK_PARSER_ARCSINE 19
71 #define VTK_PARSER_ARCCOSINE 20
72 #define VTK_PARSER_ARCTANGENT 21
73 #define VTK_PARSER_HYPERBOLIC_SINE 22
74 #define VTK_PARSER_HYPERBOLIC_COSINE 23
75 #define VTK_PARSER_HYPERBOLIC_TANGENT 24
76 #define VTK_PARSER_MIN 25
77 #define VTK_PARSER_MAX 26
78 #define VTK_PARSER_CROSS 27
79 #define VTK_PARSER_SIGN 28
82 #define VTK_PARSER_VECTOR_UNARY_MINUS 29
83 #define VTK_PARSER_DOT_PRODUCT 30
84 #define VTK_PARSER_VECTOR_ADD 31
85 #define VTK_PARSER_VECTOR_SUBTRACT 32
86 #define VTK_PARSER_SCALAR_TIMES_VECTOR 33
87 #define VTK_PARSER_VECTOR_TIMES_SCALAR 34
88 #define VTK_PARSER_VECTOR_OVER_SCALAR 35
89 #define VTK_PARSER_MAGNITUDE 36
90 #define VTK_PARSER_NORMALIZE 37
93 #define VTK_PARSER_IHAT 38
94 #define VTK_PARSER_JHAT 39
95 #define VTK_PARSER_KHAT 40
98 #define VTK_PARSER_IF 41
101 #define VTK_PARSER_VECTOR_IF 42
104 #define VTK_PARSER_LESS_THAN 43
107 #define VTK_PARSER_GREATER_THAN 44
110 #define VTK_PARSER_EQUAL_TO 45
113 #define VTK_PARSER_AND 46
116 #define VTK_PARSER_OR 47
121 #define VTK_PARSER_BEGIN_VARIABLES 48
124 #define VTK_PARSER_ERROR_RESULT VTK_LARGE_FLOAT
135 void SetFunction(
const char *
function);
136 vtkGetStringMacro(Function);
141 int IsScalarResult();
145 int IsVectorResult();
148 double GetScalarResult();
152 double* GetVectorResult();
154 double *r = this->GetVectorResult();
155 result[0] = r[0]; result[1] = r[1]; result[2] = r[2]; };
163 void SetScalarVariableValue(
const char* variableName,
double value);
164 void SetScalarVariableValue(
int i,
double value);
169 double GetScalarVariableValue(
const char* variableName);
170 double GetScalarVariableValue(
int i);
178 void SetVectorVariableValue(
const char* variableName,
double xValue,
179 double yValue,
double zValue);
180 void SetVectorVariableValue(
const char* variableName,
181 const double values[3]) {
182 this->SetVectorVariableValue(variableName,values[0],values[1],values[2]);};
183 void SetVectorVariableValue(
int i,
double xValue,
double yValue,
186 this->SetVectorVariableValue(i,values[0],values[1],values[2]);};
191 double* GetVectorVariableValue(
const char* variableName);
193 double *r = this->GetVectorVariableValue(variableName);
194 value[0] = r[0]; value[1] = r[1]; value[2] = r[2]; };
195 double* GetVectorVariableValue(
int i);
197 double *r = this->GetVectorVariableValue(i);
198 value[0] = r[0]; value[1] = r[1]; value[2] = r[2]; };
203 vtkGetMacro(NumberOfScalarVariables,
int);
208 vtkGetMacro(NumberOfVectorVariables,
int);
212 char* GetScalarVariableName(
int i);
215 char* GetVectorVariableName(
int i);
218 void RemoveAllVariables();
221 void RemoveScalarVariables();
224 void RemoveVectorVariables();
231 vtkSetMacro(ReplaceInvalidValues,
int);
232 vtkGetMacro(ReplaceInvalidValues,
int);
233 vtkBooleanMacro(ReplaceInvalidValues,
int);
234 vtkSetMacro(ReplacementValue,
double);
235 vtkGetMacro(ReplacementValue,
double);
239 void CheckExpression(
int &pos,
char **error);
252 void CopyParseError(
int &
position,
char **error);
255 char* RemoveSpacesFrom(
const char* variableName);
256 int OperatorWithinVariable(
int idx);
258 int BuildInternalFunctionStructure();
259 void BuildInternalSubstringStructure(
int beginIndex,
int endIndex);
260 void AddInternalByte(
unsigned char newByte);
262 int IsSubstringCompletelyEnclosed(
int beginIndex,
int endIndex);
263 int FindEndOfMathFunction(
int beginIndex);
264 int FindEndOfMathConstant(
int beginIndex);
266 int IsVariableName(
int currentIndex);
267 int IsElementaryOperator(
int op);
269 int GetMathFunctionNumber(
int currentIndex);
270 int GetMathFunctionNumberByCheckingParenthesis(
int currentIndex );
271 int GetMathFunctionStringLength(
int mathFunctionNumber);
272 int GetMathConstantNumber(
int currentIndex);
273 int GetMathConstantStringLength(
int mathConstantNumber);
274 unsigned char GetElementaryOperatorNumber(
char op);
275 unsigned char GetOperandNumber(
int currentIndex);
276 int GetVariableNameLength(
int variableNumber);
278 int DisambiguateOperators();
280 vtkSetStringMacro(ParseError);
282 int FindPositionInOriginalFunction(
const int& pos);