[vtkusers] Suspected bug in vtkOBJReader
johnt at raytechcomputing.com
Tue Oct 31 09:36:51 EST 2000
I believe that the vtkOBJReader class never reads vertex normals from an
input file, due to a bug in vtkOBJReader.cxx at lines 208-209:
208 blank = (char *) strchr (line, (int) ' ');
209 slash = (char *) strchr (line, (int) '/');
210 if (blank && slash && (slash < blank))
This code is in the middle of parsing a vertex/texture/normal string for
the next index into the array of normals. Because the current code
parses from the beginning of the 'line' variable, the resulting 'blank'
value is always less than the 'slash' value and, as a result, the
subsequent if statement (line 210) always evaluates to false. Instead,
the parsing should be done with respect to the current pointer position,
i.e., the correct code is:
208 blank = (char *) strchr (ptr, (int) ' ');
209 slash = (char *) strchr (ptr, (int) '/');
I found this out when using the vtkOBJReader class in a C program, but I
believe you can see it in the tclOBJReader.tcl example. I don't know
much about tcl, but at line 75 (before starting the interactor) I added:
set n [[[wavefront GetOutput] GetPoints] GetNumberOfPoints]
set normals [[[wavefront GetOutput] GetPointData] GetNormals]
set m [normals GetNumberOfNormals]
message .msg -text "There are $n points and $m normals"
and commented out line 81 (wm withdraw .) When I ran this on my PC, the
message window displays "There are 12330 points and 0 normals", even
though there are 4000 or so vertex normals in the cow.obj file.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers