45 #ifndef __vtkFunctionParser_h
46 #define __vtkFunctionParser_h
51 #define VTK_PARSER_IMMEDIATE 1
52 #define VTK_PARSER_UNARY_MINUS 2
55 #define VTK_PARSER_ADD 3
56 #define VTK_PARSER_SUBTRACT 4
57 #define VTK_PARSER_MULTIPLY 5
58 #define VTK_PARSER_DIVIDE 6
59 #define VTK_PARSER_POWER 7
60 #define VTK_PARSER_ABSOLUTE_VALUE 8
61 #define VTK_PARSER_EXPONENT 9
62 #define VTK_PARSER_CEILING 10
63 #define VTK_PARSER_FLOOR 11
64 #define VTK_PARSER_LOGARITHM 12
65 #define VTK_PARSER_LOGARITHME 13
66 #define VTK_PARSER_LOGARITHM10 14
67 #define VTK_PARSER_SQUARE_ROOT 15
68 #define VTK_PARSER_SINE 16
69 #define VTK_PARSER_COSINE 17
70 #define VTK_PARSER_TANGENT 18
71 #define VTK_PARSER_ARCSINE 19
72 #define VTK_PARSER_ARCCOSINE 20
73 #define VTK_PARSER_ARCTANGENT 21
74 #define VTK_PARSER_HYPERBOLIC_SINE 22
75 #define VTK_PARSER_HYPERBOLIC_COSINE 23
76 #define VTK_PARSER_HYPERBOLIC_TANGENT 24
77 #define VTK_PARSER_MIN 25
78 #define VTK_PARSER_MAX 26
79 #define VTK_PARSER_CROSS 27
80 #define VTK_PARSER_SIGN 28
83 #define VTK_PARSER_VECTOR_UNARY_MINUS 29
84 #define VTK_PARSER_DOT_PRODUCT 30
85 #define VTK_PARSER_VECTOR_ADD 31
86 #define VTK_PARSER_VECTOR_SUBTRACT 32
87 #define VTK_PARSER_SCALAR_TIMES_VECTOR 33
88 #define VTK_PARSER_VECTOR_TIMES_SCALAR 34
89 #define VTK_PARSER_VECTOR_OVER_SCALAR 35
90 #define VTK_PARSER_MAGNITUDE 36
91 #define VTK_PARSER_NORMALIZE 37
94 #define VTK_PARSER_IHAT 38
95 #define VTK_PARSER_JHAT 39
96 #define VTK_PARSER_KHAT 40
99 #define VTK_PARSER_IF 41
102 #define VTK_PARSER_VECTOR_IF 42
105 #define VTK_PARSER_LESS_THAN 43
108 #define VTK_PARSER_GREATER_THAN 44
111 #define VTK_PARSER_EQUAL_TO 45
114 #define VTK_PARSER_AND 46
117 #define VTK_PARSER_OR 47
122 #define VTK_PARSER_BEGIN_VARIABLES 48
125 #define VTK_PARSER_ERROR_RESULT VTK_FLOAT_MAX
136 void SetFunction(
const char *
function);
142 int IsScalarResult();
146 int IsVectorResult();
149 double GetScalarResult();
153 double* GetVectorResult();
155 double *
r = this->GetVectorResult();
156 result[0] = r[0]; result[1] = r[1]; result[2] = r[2]; };
164 void SetScalarVariableValue(
const char* variableName,
double value);
165 void SetScalarVariableValue(
int i,
double value);
170 double GetScalarVariableValue(
const char* variableName);
171 double GetScalarVariableValue(
int i);
179 void SetVectorVariableValue(
const char* variableName,
double xValue,
180 double yValue,
double zValue);
183 this->SetVectorVariableValue(variableName,values[0],values[1],values[2]);};
184 void SetVectorVariableValue(
int i,
double xValue,
double yValue,
187 this->SetVectorVariableValue(i,values[0],values[1],values[2]);};
192 double* GetVectorVariableValue(
const char* variableName);
194 double *
r = this->GetVectorVariableValue(variableName);
195 value[0] = r[0]; value[1] = r[1]; value[2] = r[2]; };
196 double* GetVectorVariableValue(
int i);
198 double *
r = this->GetVectorVariableValue(i);
199 value[0] = r[0]; value[1] = r[1]; value[2] = r[2]; };
213 char* GetScalarVariableName(
int i);
216 char* GetVectorVariableName(
int i);
219 void RemoveAllVariables();
222 void RemoveScalarVariables();
225 void RemoveVectorVariables();
240 void CheckExpression(
int &pos,
char **error);
243 void InvalidateFunction();
256 void CopyParseError(
int &
position,
char **error);
259 char* RemoveSpacesFrom(
const char* variableName);
260 int OperatorWithinVariable(
int idx);
262 int BuildInternalFunctionStructure();
263 void BuildInternalSubstringStructure(
int beginIndex,
int endIndex);
264 void AddInternalByte(
unsigned char newByte);
266 int IsSubstringCompletelyEnclosed(
int beginIndex,
int endIndex);
267 int FindEndOfMathFunction(
int beginIndex);
268 int FindEndOfMathConstant(
int beginIndex);
270 int IsVariableName(
int currentIndex);
271 int IsElementaryOperator(
int op);
273 int GetMathFunctionNumber(
int currentIndex);
274 int GetMathFunctionNumberByCheckingParenthesis(
int currentIndex );
275 int GetMathFunctionStringLength(
int mathFunctionNumber);
276 int GetMathConstantNumber(
int currentIndex);
277 int GetMathConstantStringLength(
int mathConstantNumber);
278 unsigned char GetElementaryOperatorNumber(
char op);
279 unsigned char GetOperandNumber(
int currentIndex);
280 int GetVariableNameLength(
int variableNumber);
282 int DisambiguateOperators();
286 int FindPositionInOriginalFunction(
const int& pos);
vtkTimeStamp VariableMTime
void SetVectorVariableValue(int i, const double values[3])
abstract base class for most VTK objects
#define vtkGetMacro(name, type)
#define VTKCOMMONMISC_EXPORT
record modification and/or execution time
void SetVectorVariableValue(const char *variableName, const double values[3])
GLsizei const GLfloat * value
#define vtkSetStringMacro(name)
GLdouble GLdouble GLdouble r
char ** ScalarVariableNames
#define vtkTypeMacro(thisClass, superclass)
double * ScalarVariableValues
virtual void PrintSelf(ostream &os, vtkIndent indent)
vtkTimeStamp FunctionMTime
Parse and evaluate a mathematical expression.
a simple class to control print indentation
GLboolean GLenum GLenum GLvoid * values
void GetVectorVariableValue(const char *variableName, double value[3])
int NumberOfScalarVariables
char * FunctionWithSpaces
#define vtkGetStringMacro(name)
vtkTimeStamp EvaluateMTime
double ** VectorVariableValues
void GetVectorResult(double result[3])
void GetVectorVariableValue(int i, double value[3])
#define vtkBooleanMacro(name, type)
int NumberOfVectorVariables
char ** VectorVariableNames
#define vtkSetMacro(name, type)