Calculator parsing issue
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
There is a problem with the Python parser where it will not recognise a variable that begins with the letters of a mathematical function, e.g. a variable called "absolute" with cause an error because "abs" is a function and it will expect a bracket.
Here is a test case:
8<--------------------------------------- from paraview.simple import * cone = Cone() calc = Calculator(cone) calc.Function = "17" calc.ResultArrayName = "absolute" calc2 = Calculator(calc) calc2.ScalarVariable = ["abs", "abs", "0"] calc2.Function = "absolute - 15" calc2.UpdatePipeline() --------------------------------------->8
Here is a patch to fix:
8<--------------------------------------- Index: ./VTK/Common/vtkFunctionParser.cxx
RCS file: /cvsroot/ParaView3/ParaView3/VTK/Common/vtkFunctionParser.cxx,v retrieving revision 1.44 diff -r1.44 vtkFunctionParser.cxx 1455,1457c1455,1460 < index += this->GetMathFunctionStringLength(functionNumber); < currentChar = this->Function[index]; < if ( currentChar != '(' )
currentChar = this->Function[index+this->GetMathFunctionStringLength(functionNumber)]; if ( currentChar == '(' ) { index += this->GetMathFunctionStringLength(functionNumber); } else
1459,1460d1461 < vtkErrorMacro("Syntax error: input to math function not in " < << "parentheses; see position " << index); 1463c1464 < return 0;
return 1;
--------------------------------------->8