[vtkusers] STLReader bug

Gregory Bleiker gregory.bleiker at phonak.ch
Thu Nov 14 11:11:24 EST 2002


Hi all
I think there is a bug in the stlreader class, and I failed to read a file because of it:
Check the comment about skipping the first 255 chars (which you really should): There's no code to match the comment. Probably duplicating the numChars line would work...

Greetings
Gregory 


int vtkSTLReader::GetSTLFileType(FILE *fp)
{
  unsigned char header[256];
  int type, i;
  int numChars;

  //  Read a little from the file to figure what type it is.
  //
  // skip 255 characters so we are past any first line comment */
  numChars = static_cast<int>(fread ((unsigned char *)header, 1, 255, fp));
  for (i = 0, type=VTK_ASCII; i< numChars && type == VTK_ASCII; i++) // don't test \0
    {
    if (header[i] > 127)
      {
      type = VTK_BINARY;
      }
    }

  // Reset file for reading
  //
  rewind (fp);
  return type;
}




More information about the vtkusers mailing list