View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015557VTK(No Category)public2015-06-27 11:372015-08-13 10:11
ReporterTsutomu Ikegami 
Assigned ToT.J. Corona 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version6.0.0 
Target VersionFixed in Version 
Summary0015557: vtkFunctionParser gives wrong results for numeric literals
DescriptionThe vtkFunctionParser wrongly parses numeric literals with exponent notation. For example, "3.0e+01" is parsed as 31.0 = 3.0e01 + 01. I have confirmed the phenomena on VTK version 6.2.0.

----- sample code in python -----
import vtk
f = vtk.vtkFunctionParser()
f.SetFunction("3.0e+01")
print f.GetScalarResult()

=> 31.0
---------------------------------

I noticed that only the '(\d)e-(\d)' case is treated specially in vtkFunctionParser.cxx:l.1542, but I have no graceful idea to fix it.
TagsNo tags attached.
ProjectTBD
Typeincorrect functionality
Attached Files

 Relationships

  Notes
(0034974)
T.J. Corona (developer)
2015-08-12 10:57

Scientific notation with a unary plus operator now behaves correctly. Additionally, the unary plus operator has been added to vtkFunctionParser. For more information, see

https://gitlab.kitware.com/tjcorona/vtk/commit/1f890b9bfa5e45cdfd748f9147225907c980da00 [^]
(0034979)
Tsutomu Ikegami (reporter)
2015-08-12 21:28

Thank you for the correction. Please allow me to add a quick patch. This corrects "3.0E-01" case, which is also parsed by atof() function at line 2034.

--- vtkFunctionParser.cxx.orig 2015-08-13 10:21:58.000000000 +0900
+++ vtkFunctionParser.cxx 2015-08-13 10:22:47.000000000 +0900
@@ -1563,7 +1563,7 @@
           !((this->Function[i] == '-' || this->Function[i] == '+') &&
             (this->IsElementaryOperator(this->Function[i-1]) ||
              this->Function[i-1] == '(' ||
- (this->Function[i-1] == 'e' && i > 1 &&
+ ((this->Function[i-1] == 'e' || this->Function[i-1] == 'E') && i > 1 &&
               isdigit(this->Function[i-2])))) &&
           !(this->Function[i] == '.' &&
             (i+1 < this->FunctionLength) &&
(0034986)
T.J. Corona (developer)
2015-08-13 10:11

Thanks! This addition has been made. For more information, see

https://gitlab.kitware.com/vtk/vtk/commit/c5c1880ab61b37fa931f60ad359a0f1e4ee308c6 [^]

 Issue History
Date Modified Username Field Change
2015-06-27 11:37 Tsutomu Ikegami New Issue
2015-08-07 12:58 T.J. Corona Assigned To => T.J. Corona
2015-08-12 10:57 T.J. Corona Note Added: 0034974
2015-08-12 10:57 T.J. Corona Status backlog => closed
2015-08-12 10:57 T.J. Corona Resolution open => fixed
2015-08-12 21:28 Tsutomu Ikegami Note Added: 0034979
2015-08-12 21:28 Tsutomu Ikegami Status closed => backlog
2015-08-12 21:28 Tsutomu Ikegami Resolution fixed => reopened
2015-08-13 10:11 T.J. Corona Note Added: 0034986
2015-08-13 10:11 T.J. Corona Status backlog => closed
2015-08-13 10:11 T.J. Corona Resolution reopened => fixed


Copyright © 2000 - 2018 MantisBT Team