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])
177 double* r = this->GetVectorResult();
191 void SetScalarVariableValue(
const char* variableName,
double value);
192 void SetScalarVariableValue(
int i,
double value);
199 double GetScalarVariableValue(
const char* variableName);
200 double GetScalarVariableValue(
int i);
210 void SetVectorVariableValue(
211 const char* variableName,
double xValue,
double yValue,
double zValue);
214 this->SetVectorVariableValue(variableName, values[0], values[1], values[2]);
216 void SetVectorVariableValue(
int i,
double xValue,
double yValue,
double zValue);
219 this->SetVectorVariableValue(i, values[0], values[1], values[2]);
227 double* GetVectorVariableValue(
const char* variableName)
VTK_SIZEHINT(3);
230 double* r = this->GetVectorVariableValue(variableName);
238 double* r = this->GetVectorVariableValue(i);
253 int GetScalarVariableIndex(
const char*
name);
263 int GetVectorVariableIndex(
const char*
name);
268 const char* GetScalarVariableName(
int i);
273 const char* GetVectorVariableName(
int i);
281 bool GetScalarVariableNeeded(
int i);
282 bool GetScalarVariableNeeded(
const char* variableName);
291 bool GetVectorVariableNeeded(
int i);
292 bool GetVectorVariableNeeded(
const char* variableName);
298 void RemoveAllVariables();
303 void RemoveScalarVariables();
308 void RemoveVectorVariables();
319 vtkBooleanMacro(ReplaceInvalidValues,
vtkTypeBool);
320 vtkSetMacro(ReplacementValue,
double);
321 vtkGetMacro(ReplacementValue,
double);
327 void CheckExpression(
int& pos,
char** error);
332 void InvalidateFunction();
347 void CopyParseError(
int&
position,
char** error);
350 char* RemoveSpacesFrom(
const char* variableName);
351 int OperatorWithinVariable(
int idx);
353 int BuildInternalFunctionStructure();
354 void BuildInternalSubstringStructure(
int beginIndex,
int endIndex);
355 void AddInternalByte(
unsigned int newByte);
357 int IsSubstringCompletelyEnclosed(
int beginIndex,
int endIndex);
358 int FindEndOfMathFunction(
int beginIndex);
359 int FindEndOfMathConstant(
int beginIndex);
361 int IsVariableName(
int currentIndex);
362 int IsElementaryOperator(
int op);
364 int GetMathFunctionNumber(
int currentIndex);
365 int GetMathFunctionNumberByCheckingParenthesis(
int currentIndex);
366 int GetMathFunctionStringLength(
int mathFunctionNumber);
367 int GetMathConstantNumber(
int currentIndex);
368 int GetMathConstantStringLength(
int mathConstantNumber);
369 unsigned char GetElementaryOperatorNumber(
char op);
370 unsigned int GetOperandNumber(
int currentIndex);
371 int GetVariableNameLength(
int variableNumber);
373 int DisambiguateOperators();
379 void UpdateNeededVariables();
381 vtkSetStringMacro(ParseError);
383 int FindPositionInOriginalFunction(
const int& pos);