48 #ifndef vtkFunctionParser_h
49 #define vtkFunctionParser_h
54 #define VTK_PARSER_IMMEDIATE 1
55 #define VTK_PARSER_UNARY_MINUS 2
56 #define VTK_PARSER_UNARY_PLUS 3
59 #define VTK_PARSER_ADD 4
60 #define VTK_PARSER_SUBTRACT 5
61 #define VTK_PARSER_MULTIPLY 6
62 #define VTK_PARSER_DIVIDE 7
63 #define VTK_PARSER_POWER 8
64 #define VTK_PARSER_ABSOLUTE_VALUE 9
65 #define VTK_PARSER_EXPONENT 10
66 #define VTK_PARSER_CEILING 11
67 #define VTK_PARSER_FLOOR 12
68 #define VTK_PARSER_LOGARITHM 13
69 #define VTK_PARSER_LOGARITHME 14
70 #define VTK_PARSER_LOGARITHM10 15
71 #define VTK_PARSER_SQUARE_ROOT 16
72 #define VTK_PARSER_SINE 17
73 #define VTK_PARSER_COSINE 18
74 #define VTK_PARSER_TANGENT 19
75 #define VTK_PARSER_ARCSINE 20
76 #define VTK_PARSER_ARCCOSINE 21
77 #define VTK_PARSER_ARCTANGENT 22
78 #define VTK_PARSER_HYPERBOLIC_SINE 23
79 #define VTK_PARSER_HYPERBOLIC_COSINE 24
80 #define VTK_PARSER_HYPERBOLIC_TANGENT 25
81 #define VTK_PARSER_MIN 26
82 #define VTK_PARSER_MAX 27
83 #define VTK_PARSER_SIGN 29
86 #define VTK_PARSER_CROSS 28
87 #define VTK_PARSER_VECTOR_UNARY_MINUS 30
88 #define VTK_PARSER_VECTOR_UNARY_PLUS 31
89 #define VTK_PARSER_DOT_PRODUCT 32
90 #define VTK_PARSER_VECTOR_ADD 33
91 #define VTK_PARSER_VECTOR_SUBTRACT 34
92 #define VTK_PARSER_SCALAR_TIMES_VECTOR 35
93 #define VTK_PARSER_VECTOR_TIMES_SCALAR 36
94 #define VTK_PARSER_VECTOR_OVER_SCALAR 37
95 #define VTK_PARSER_MAGNITUDE 38
96 #define VTK_PARSER_NORMALIZE 39
99 #define VTK_PARSER_IHAT 40
100 #define VTK_PARSER_JHAT 41
101 #define VTK_PARSER_KHAT 42
104 #define VTK_PARSER_IF 43
107 #define VTK_PARSER_VECTOR_IF 44
110 #define VTK_PARSER_LESS_THAN 45
113 #define VTK_PARSER_GREATER_THAN 46
116 #define VTK_PARSER_EQUAL_TO 47
119 #define VTK_PARSER_AND 48
122 #define VTK_PARSER_OR 49
127 #define VTK_PARSER_BEGIN_VARIABLES 50
130 #define VTK_PARSER_ERROR_RESULT VTK_FLOAT_MAX
144 void SetFunction(
const char *
function);
145 vtkGetStringMacro(Function);
150 int IsScalarResult();
154 int IsVectorResult();
157 double GetScalarResult();
161 double* GetVectorResult();
163 double *r = this->GetVectorResult();
164 result[0] = r[0]; result[1] = r[1]; result[2] = r[2]; };
172 void SetScalarVariableValue(
const char* variableName,
double value);
173 void SetScalarVariableValue(
int i,
double value);
178 double GetScalarVariableValue(
const char* variableName);
179 double GetScalarVariableValue(
int i);
187 void SetVectorVariableValue(
const char* variableName,
double xValue,
188 double yValue,
double zValue);
190 const double values[3]) {
191 this->SetVectorVariableValue(variableName,values[0],values[1],values[2]);};
192 void SetVectorVariableValue(
int i,
double xValue,
double yValue,
195 this->SetVectorVariableValue(i,values[0],values[1],values[2]);};
200 double* GetVectorVariableValue(
const char* variableName);
202 double *r = this->GetVectorVariableValue(variableName);
203 value[0] = r[0]; value[1] = r[1]; value[2] = r[2]; };
204 double* GetVectorVariableValue(
int i);
206 double *r = this->GetVectorVariableValue(i);
207 value[0] = r[0]; value[1] = r[1]; value[2] = r[2]; };
212 vtkGetMacro(NumberOfScalarVariables,
int);
217 vtkGetMacro(NumberOfVectorVariables,
int);
221 char* GetScalarVariableName(
int i);
224 char* GetVectorVariableName(
int i);
227 void RemoveAllVariables();
230 void RemoveScalarVariables();
233 void RemoveVectorVariables();
240 vtkSetMacro(ReplaceInvalidValues,
int);
241 vtkGetMacro(ReplaceInvalidValues,
int);
242 vtkBooleanMacro(ReplaceInvalidValues,
int);
243 vtkSetMacro(ReplacementValue,
double);
244 vtkGetMacro(ReplacementValue,
double);
248 void CheckExpression(
int &pos,
char **error);
251 void InvalidateFunction();
264 void CopyParseError(
int &
position,
char **error);
267 char* RemoveSpacesFrom(
const char* variableName);
268 int OperatorWithinVariable(
int idx);
270 int BuildInternalFunctionStructure();
271 void BuildInternalSubstringStructure(
int beginIndex,
int endIndex);
272 void AddInternalByte(
unsigned char newByte);
274 int IsSubstringCompletelyEnclosed(
int beginIndex,
int endIndex);
275 int FindEndOfMathFunction(
int beginIndex);
276 int FindEndOfMathConstant(
int beginIndex);
278 int IsVariableName(
int currentIndex);
279 int IsElementaryOperator(
int op);
281 int GetMathFunctionNumber(
int currentIndex);
282 int GetMathFunctionNumberByCheckingParenthesis(
int currentIndex );
283 int GetMathFunctionStringLength(
int mathFunctionNumber);
284 int GetMathConstantNumber(
int currentIndex);
285 int GetMathConstantStringLength(
int mathConstantNumber);
286 unsigned char GetElementaryOperatorNumber(
char op);
287 unsigned char GetOperandNumber(
int currentIndex);
288 int GetVariableNameLength(
int variableNumber);
290 int DisambiguateOperators();
292 vtkSetStringMacro(ParseError);
294 int FindPositionInOriginalFunction(
const int& pos);
vtkTimeStamp VariableMTime
void SetVectorVariableValue(int i, const double values[3])
abstract base class for most VTK objects
#define VTKCOMMONMISC_EXPORT
record modification and/or execution time
void SetVectorVariableValue(const char *variableName, const double values[3])
char ** ScalarVariableNames
double * ScalarVariableValues
virtual void PrintSelf(ostream &os, vtkIndent indent)
vtkTimeStamp FunctionMTime
Parse and evaluate a mathematical expression.
virtual unsigned long GetMTime()
a simple class to control print indentation
void GetVectorVariableValue(const char *variableName, double value[3])
int NumberOfScalarVariables
char * FunctionWithSpaces
vtkTimeStamp EvaluateMTime
double ** VectorVariableValues
void GetVectorResult(double result[3])
void GetVectorVariableValue(int i, double value[3])
int NumberOfVectorVariables
char ** VectorVariableNames