reading .xyz file format
in
Programming Questions
•
2 years ago
I am trying to read the CAD format .xyz which:
Header:
4 bytes: XYZ1
2 bytes, unsigned int: Width
2 bytes, unsigned int: Height
Data:
ZLib-compressed. Use ZLib.dll uncompress to decompress it...
The output size of the data is (image and palette):
(Width * Height) + (256 * 3)
The input size of the data is:
FileSize - 8
In english, the data starts after the header and ends at the end of the file, and the image, when decompressed, is just a palette and then image data.
The palette is simply a series of colors in RGB order, no 4th byte for the palette entries.
The data is just a bunch of palette indexes, in standard x,y order.
and looks like:
- Comment lines begin with '#" in column 1, and may appear anywhere;
- Blank lines may appear anywhere.
- The coordinates of a point are written on a single line, separated by spaces;
Example XYZ File:
# Corners of a tetrahedron # 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0
what are the suggestions on reading this into processing?
There is one C++ library that will read this format, but obviously it isn't processing.
I am wondering if I could read it as a string and then split it back up as needed.
1