48 #ifndef vtkFunctionParser_h
49 #define vtkFunctionParser_h
54 #define VTK_PARSER_IMMEDIATE 1
55 #define VTK_PARSER_UNARY_MINUS 2
58 #define VTK_PARSER_ADD 3
59 #define VTK_PARSER_SUBTRACT 4
60 #define VTK_PARSER_MULTIPLY 5
61 #define VTK_PARSER_DIVIDE 6
62 #define VTK_PARSER_POWER 7
63 #define VTK_PARSER_ABSOLUTE_VALUE 8
64 #define VTK_PARSER_EXPONENT 9
65 #define VTK_PARSER_CEILING 10
66 #define VTK_PARSER_FLOOR 11
67 #define VTK_PARSER_LOGARITHM 12
68 #define VTK_PARSER_LOGARITHME 13
69 #define VTK_PARSER_LOGARITHM10 14
70 #define VTK_PARSER_SQUARE_ROOT 15
71 #define VTK_PARSER_SINE 16
72 #define VTK_PARSER_COSINE 17
73 #define VTK_PARSER_TANGENT 18
74 #define VTK_PARSER_ARCSINE 19
75 #define VTK_PARSER_ARCCOSINE 20
76 #define VTK_PARSER_ARCTANGENT 21
77 #define VTK_PARSER_HYPERBOLIC_SINE 22
78 #define VTK_PARSER_HYPERBOLIC_COSINE 23
79 #define VTK_PARSER_HYPERBOLIC_TANGENT 24
80 #define VTK_PARSER_MIN 25
81 #define VTK_PARSER_MAX 26
82 #define VTK_PARSER_SIGN 28
85 #define VTK_PARSER_CROSS 27
86 #define VTK_PARSER_VECTOR_UNARY_MINUS 29
87 #define VTK_PARSER_DOT_PRODUCT 30
88 #define VTK_PARSER_VECTOR_ADD 31
89 #define VTK_PARSER_VECTOR_SUBTRACT 32
90 #define VTK_PARSER_SCALAR_TIMES_VECTOR 33
91 #define VTK_PARSER_VECTOR_TIMES_SCALAR 34
92 #define VTK_PARSER_VECTOR_OVER_SCALAR 35
93 #define VTK_PARSER_MAGNITUDE 36
94 #define VTK_PARSER_NORMALIZE 37
97 #define VTK_PARSER_IHAT 38
98 #define VTK_PARSER_JHAT 39
99 #define VTK_PARSER_KHAT 40
102 #define VTK_PARSER_IF 41
105 #define VTK_PARSER_VECTOR_IF 42
108 #define VTK_PARSER_LESS_THAN 43
111 #define VTK_PARSER_GREATER_THAN 44
114 #define VTK_PARSER_EQUAL_TO 45
117 #define VTK_PARSER_AND 46
120 #define VTK_PARSER_OR 47
125 #define VTK_PARSER_BEGIN_VARIABLES 48
128 #define VTK_PARSER_ERROR_RESULT VTK_FLOAT_MAX
142 void SetFunction(
const char *
function);
143 vtkGetStringMacro(Function);
148 int IsScalarResult();
152 int IsVectorResult();
155 double GetScalarResult();
159 double* GetVectorResult();
161 double *r = this->GetVectorResult();
162 result[0] = r[0]; result[1] = r[1]; result[2] = r[2]; };
170 void SetScalarVariableValue(
const char* variableName,
double value);
171 void SetScalarVariableValue(
int i,
double value);
176 double GetScalarVariableValue(
const char* variableName);
177 double GetScalarVariableValue(
int i);
185 void SetVectorVariableValue(
const char* variableName,
double xValue,
186 double yValue,
double zValue);
188 const double values[3]) {
189 this->SetVectorVariableValue(variableName,values[0],values[1],values[2]);};
190 void SetVectorVariableValue(
int i,
double xValue,
double yValue,
193 this->SetVectorVariableValue(i,values[0],values[1],values[2]);};
198 double* GetVectorVariableValue(
const char* variableName);
200 double *r = this->GetVectorVariableValue(variableName);
201 value[0] = r[0]; value[1] = r[1]; value[2] = r[2]; };
202 double* GetVectorVariableValue(
int i);
204 double *r = this->GetVectorVariableValue(i);
205 value[0] = r[0]; value[1] = r[1]; value[2] = r[2]; };
210 vtkGetMacro(NumberOfScalarVariables,
int);
215 vtkGetMacro(NumberOfVectorVariables,
int);
219 char* GetScalarVariableName(
int i);
222 char* GetVectorVariableName(
int i);
225 void RemoveAllVariables();
228 void RemoveScalarVariables();
231 void RemoveVectorVariables();
238 vtkSetMacro(ReplaceInvalidValues,
int);
239 vtkGetMacro(ReplaceInvalidValues,
int);
240 vtkBooleanMacro(ReplaceInvalidValues,
int);
241 vtkSetMacro(ReplacementValue,
double);
242 vtkGetMacro(ReplacementValue,
double);
246 void CheckExpression(
int &pos,
char **error);
249 void InvalidateFunction();
262 void CopyParseError(
int &
position,
char **error);
265 char* RemoveSpacesFrom(
const char* variableName);
266 int OperatorWithinVariable(
int idx);
268 int BuildInternalFunctionStructure();
269 void BuildInternalSubstringStructure(
int beginIndex,
int endIndex);
270 void AddInternalByte(
unsigned char newByte);
272 int IsSubstringCompletelyEnclosed(
int beginIndex,
int endIndex);
273 int FindEndOfMathFunction(
int beginIndex);
274 int FindEndOfMathConstant(
int beginIndex);
276 int IsVariableName(
int currentIndex);
277 int IsElementaryOperator(
int op);
279 int GetMathFunctionNumber(
int currentIndex);
280 int GetMathFunctionNumberByCheckingParenthesis(
int currentIndex );
281 int GetMathFunctionStringLength(
int mathFunctionNumber);
282 int GetMathConstantNumber(
int currentIndex);
283 int GetMathConstantStringLength(
int mathConstantNumber);
284 unsigned char GetElementaryOperatorNumber(
char op);
285 unsigned char GetOperandNumber(
int currentIndex);
286 int GetVariableNameLength(
int variableNumber);
288 int DisambiguateOperators();
290 vtkSetStringMacro(ParseError);
292 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