MCPcopy Create free account
hub / github.com/Kitware/VTK / Parse

Method Parse

Common/Misc/vtkFunctionParser.cxx:93–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93int vtkFunctionParser::Parse()
94{
95 int result;
96 int i;
97
98 if (this->Function == nullptr)
99 {
100 vtkErrorMacro("Parse: no function has been set");
101 return 0;
102 }
103
104 result = this->CheckSyntax();
105 if (!result)
106 {
107 return 0;
108 }
109
110 this->BuildInternalFunctionStructure();
111
112 // need to make sure that the ambiguous operators are correct
113 // - scalar/vector +
114 // - scalar/vector -
115 // - scalar/vector unary minus
116 // - scalar/vector unary plus
117 // - * (2 scalars) or scalar multiple (scalar, vector)
118 result = this->DisambiguateOperators();
119 if (!result)
120 {
121 vtkErrorMacro("Parse: Error deciding between ambiguous operators");
122 return 0;
123 }
124
125 // need to recalculate stack size based on number of vector variables
126 // in byte code
127 for (i = 0; i < this->ByteCodeSize; i++)
128 {
129 if ((this->ByteCode[i] >= VTK_PARSER_BEGIN_VARIABLES +
130 static_cast<unsigned int>(this->GetNumberOfScalarVariables())) ||
131 (this->ByteCode[i] == VTK_PARSER_IHAT) || (this->ByteCode[i] == VTK_PARSER_JHAT) ||
132 (this->ByteCode[i] == VTK_PARSER_KHAT))
133 {
134 this->StackSize += 2;
135 }
136 }
137
138 if (this->StackSize)
139 {
140 this->Stack = new double[this->StackSize];
141 if (!this->Stack)
142 {
143 vtkErrorMacro("Parse: Out of memory");
144 return 0;
145 }
146 }
147
148 // Collect meta-data about variables that are needed for evaluation of the
149 // function.
150 this->UpdateNeededVariables();

Callers 1

EvaluateMethod · 0.95

Calls 5

CheckSyntaxMethod · 0.95
DisambiguateOperatorsMethod · 0.95
UpdateNeededVariablesMethod · 0.95
ModifiedMethod · 0.45

Tested by

no test coverage detected