MantisBT - VTK
View Issue Details
0005775VTK(No Category)public2007-09-25 03:302008-06-03 14:48
emiliano79 
Sean McBride 
normalminoralways
closedfixed 
 
 
0005775: vtkPLYReader does not work on win and mac ASCII ply files
The vtkPLYReader is able to load ply files either in binary format or in ASCII format, but in the second case there is a problem with line termination characters. The vtkPLYReader reads only ASCII lines terminating with LF character (0x0A) according to unix-like operating systems: to achieve platform independence, it is supposed to works fine also on win and mac ASCII files. In the former the lines terminate with CR LF (0x0D 0x0A), in the latter lines terminate with CR (0x0D). So the vtkPLYReader has to recognize different line terminations as well.
I have modified the vtkPLY.cxx file to implement platform independent line termination reading.
Just replace this section in the vtkPLY.cxx file:


 /* convert line-feed and tabs into spaces */
  /* (this guarentees that there will be a space before the */
  /* null character at the end of the string) */

  str[BIG_STRING-2] = ' ';
  str[BIG_STRING-1] = '\0';


  for (ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++) {
    *ptr2 = *ptr;

    if (*ptr == '\t') {
      *ptr = ' ';
      *ptr2 = ' ';
    }

    else if (*ptr == '\n') {
      *ptr = ' ';
      *ptr2 = '\0';
      break;
    }
  }


with:


  /* convert line-feed and tabs into spaces */
  /* (this guarentees that there will be a space before the */
  /* null character at the end of the string) */

  str[BIG_STRING-2] = ' ';
  str[BIG_STRING-1] = '\0';

  for (ptr = str, ptr2 = str_copy; *ptr != '\0'; ptr++, ptr2++) {
    *ptr2 = *ptr;

    if (*ptr == '\t') {
      *ptr = ' ';
      *ptr2 = ' ';
    }

/* -----------------------------------------------------------------------
    *-*-* PATCH *-*-* PATCH *-*-* PATCH *-*-* PATCH *-*-*
--------------------------------------------------------------------------
Patch to allow reading PLY files in Unix, Windows and Mac end line format
------------------------------------------------------------------------*/

    else if (*ptr == '\r') {
      *ptr = ' ';
      *ptr2 = '\0';
    }

/* -----------------------------------------------------------------------
    *-*-* PATCH *-*-* PATCH *-*-* PATCH *-*-* PATCH *-*-*
-------------------------------------------------------------------------/

    else if (*ptr == '\n') {
      *ptr = ' ';
      *ptr2 = '\0';
      break;
    }
  }
No tags attached.
txt plyPatch.txt (2,289) 2007-11-12 15:36
https://www.vtk.org/Bug/file/6221/plyPatch.txt
cxx TestPLYReader.cxx (2,441) 2007-11-12 16:58
https://www.vtk.org/Bug/file/6222/TestPLYReader.cxx
png TestPLYReader.png (32,740) 2007-11-12 16:58
https://www.vtk.org/Bug/file/6223/TestPLYReader.png
png

txt plyTestPatch.txt (3,307) 2007-11-12 16:59
https://www.vtk.org/Bug/file/6224/plyTestPatch.txt
Issue History
2007-09-25 03:30emiliano79New Issue
2007-09-25 03:46emiliano79Note Added: 0009282
2007-11-12 15:36Mathieu CoursolleFile Added: plyPatch.txt
2007-11-12 15:38Mathieu CoursolleNote Added: 0009668
2007-11-12 16:58Mathieu CoursolleFile Added: TestPLYReader.cxx
2007-11-12 16:58Mathieu CoursolleFile Added: TestPLYReader.png
2007-11-12 16:59Mathieu CoursolleFile Added: plyTestPatch.txt
2007-11-12 17:00Mathieu CoursolleNote Added: 0009669
2007-11-14 12:38Sean McBrideStatusbacklog => tabled
2007-11-14 12:38Sean McBrideAssigned To => Sean McBride
2007-11-15 10:50Sean McBrideStatustabled => @80@
2007-11-15 10:50Sean McBrideResolutionopen => fixed
2007-11-15 10:50Sean McBrideNote Added: 0009686
2008-06-03 14:48Sean McBrideStatus@80@ => closed
2008-06-03 14:48Sean McBrideNote Added: 0012229
2011-06-16 13:11Zack GalbreathCategory => (No Category)

Notes
(0009282)
emiliano79   
2007-09-25 03:46   
The modified function in the vtkPLY.cxx file is the get_words() one.
(0009668)
Mathieu Coursolle   
2007-11-12 15:38   
Here is a patch with the proposed changed. It also contains the changes proposed in 5776.

New file types are added (float32, int32 and uint8), to be able to open
the stanford bunny: http://www-graphics.stanford.edu/data/3Dscanrep/ [^]

It was tested on Intel Mac OS 10.5.
(0009669)
Mathieu Coursolle   
2007-11-12 17:00   
I attached a proposed test which loads the stanford bunny available at:
ftp://graphics.stanford.edu/pub/3Dscanrep/bunny.tar.gz [^]

I attached the test file: TestPLYReader.cxx
the validation image: TestPLYReader.png
as well as the updated patch file which include that test.
(0009686)
Sean McBride   
2007-11-15 10:50   
We have just committed a fix for this in CVS, as of 2007-11-15 10:50 ish. Can you please confirm it is fixed? Thanks.
(0012229)
Sean McBride   
2008-06-03 14:48   
Many months with no feedback from reporter. Closed.