[vtkusers] Suspected bug in vtkOBJReader

Bill Lorensen wlorens1 at nycap.rr.com
Tue Oct 31 23:24:41 EST 2000


John,
Thanks for the bug report. Your fix is certainly correct. However, I believe 
that the bug only occurs when a texture id is present. In the OBJReader.tcl 
example, cow.obj does not have texture id's, thus the lines 208... are never 
reached.
I don't believe we have an obj files with texture. I'll try to generate one 
so we can test your fix,

Bill

At 09:36 AM 10/31/00 -0500, John Tourtellott wrote:
>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)) 
>     211      { 
>
>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] 
>    vtkNormals normals 
>    set normals [[[wavefront GetOutput] GetPointData] GetNormals] 
>    set m [normals GetNumberOfNormals] 
>    message .msg -text "There are $n points and $m normals" 
>    pack    .msg 
>
>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...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20001031/538dc825/attachment.htm>


More information about the vtkusers mailing list