XYZ_IO is a C++ library which reads and writes files in the XYZ, XYZL and XYZF formats.
XYZ files are a simple way of storing information about sets of points in 3D.
An XYZ file has a simple structure. There are three kinds of records:
- COMMENT LINES begin with the character '#' and are ignored;
- BLANK LINES are gnored;
- COORDINATE LINES each contain one triple of XYZ coordinates;
Here is an example of an XYZ file containing 13 points:
# cube.xyz
#
0.000000 0.000000 0.000000
1.000000 0.000000 0.000000
1.000000 1.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
1.000000 0.000000 1.000000
1.000000 1.000000 1.000000
0.000000 1.000000 1.000000
Of course, in many cases, we would like to describe LINES between the points. We can add this information by including a second file, called an XYZL file, which consists of a string of point indices. A line is drawn from one point to the next, and so on for each point listed in a record. Thus, an XYZL file associated with the above XYZ file might be:
# cube.xyzl
#
0 1 2 3 0
4 5 6 7 4
0 4
1 5
2 6
3 7
We might also like to describe FACES defined by the points. We can add this information by including a file, called an XYZF file, which consists of a string of point indices. A face is defined by listing in counterclockwise order the vertices that lie on it. The first vertex is not repeated as the final vertex. Thus, an XYZF file associated with the above XYZ file might be:
# cube.xyzf
#
0 3 2 1
1 2 6 5
4 5 6 7
4 7 3 0
0 1 5 4
2 3 7 6
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
XYZ_IO is available in a C++ version and a FORTRAN90 version and a MATLAB version.
IVREAD, a FORTRAN90 program which can convert graphics information between various 3D formats, including the XYZ format.
PDB_TO_XYZ, a FORTRAN90 program which reads the ATOM records from a PDB file, and writes the atomic coordinates to an XYZ file.
STRIPACK_INTERACTIVE, a FORTRAN90 program which reads an XYZ file of 3D points on the unit sphere, computes the Delaunay triangulation, and writes it to a file.
XY, a data directory which contains examples of XY files, a simple 2D graphics point and line format;
XYZ, a data directory which contains examples of XYZ files, a simple 3D graphics point and line format;
XYZ_DISPLAY, a MATLAB program which reads XYZ information defining points in 3D, and displays an image in the MATLAB graphics window.
XYZ_DISPLAY_OPENGL, a C++ program which reads an XYZ file of 3D point coordinates, and displays an image of those points using OpenGL.
XYZ_TO_PDB, a FORTRAN90 program which reads a set of XYZ spatial coordinates, and rewrites them as ATOM records in a PDB file.
XYZF, a data directory which contains examples of XYZF files, a simple 3D graphics point and face format;
XYZF_DISPLAY, a MATLAB program which reads XYZF information defining points and faces in 3D, and displays an image in a MATLAB graphics window.
XYZF_DISPLAY_OPENGL, a C++ program which reads XYZF information defining 3D points and faces and displays an image using OpenGL.
XYZL, a data directory which contains examples of XYZL files, a simple 3D graphics point and line format;
XYZL_DISPLAY, a MATLAB program which reads XYZL information defining points and lines in 3D, and displays an image in a MATLAB graphics window.
XYZL_DISPLAY_OPENGL, a C++ program which reads XYZL information defining 3D points and lines and displays an image using OpenGL.
- xyz_io.cpp, the source code.
- xyz_io.hpp, the include file.
- xyz_io_prb.cpp, a sample calling program.
- xyz_io_prb_output.txt, the output file.
- helix.xyz, an XYZ file created by the example program.
- xy_io_prb_02.xyz, an XYZ file created by the example program.
- cube.xyz, an XYZ file of points created by the example program.
- cube.xyzl, an XYZL file of lines created by the example program.
- cube.xyzf, an XYZF file of lines created by the example program.
- CH_EQI is true if two characters are equal, disregarding case.
- CH_TO_DIGIT returns the integer value of a base 10 digit.
- I4VEC_COPY copies an I4VEC.
- R8VEC_COPY copies an R8VEC.
- S_LEN_TRIM returns the length of a string to the last nonblank.
- S_TO_I4 reads an I4 from a string.
- S_TO_I4VEC reads an I4VEC from a string.
- S_TO_R8 reads an R8 value from a string.
- S_TO_R8VEC reads an R8VEC from a string.
- S_WORD_COUNT counts the number of "words" in a string.
- TIMESTAMP prints the current YMDHMS date as a time stamp.
- XYZ_DATA_PRINT prints the data for an XYZ file.
- XYZ_DATA_READ reads the data in an XYZ file.
- XYZ_DATA_WRITE writes the data for an XYZ file.
- XYZ_EXAMPLE sets up data suitable for an XYZ file.
- XYZ_EXAMPLE_SIZE sizes an example XYZ dataset.
- XYZ_HEADER_PRINT prints the header of an XYZ file.
- XYZ_HEADER_READ reads the header of an XYZ file.
- XYZ_HEADER_WRITE writes the header of an XYZ file.
- XYZ_READ reads the header and data from an XYZ file.
- XYZ_READ_TEST tests the XYZ file read routines.
- XYZ_WRITE writes the header and data for an XYZ file.
- XYZ_WRITE_TEST tests the XYZ write routines.
- XYZF_DATA_PRINT prints the data of an XYZF file.
- XYZF_DATA_READ reads the data in an XYZF file.
- XYZF_DATA_WRITE writes the data of an XYZF file.
- XYZF_EXAMPLE sets data suitable for a pair of XYZ and XYZF files.
- XYZF_EXAMPLE_SIZE sizes the data to be created by XYZF_EXAMPLE.
- XYZF_HEADER_PRINT prints the header of an XYZF file.
- XYZF_HEADER_READ determines the number of face items in an XYZF file.
- XYZF_HEADER_WRITE writes the header of an XYZF file.
- XYZF_WRITE writes the header and data for an XYZF file.
- XYZL_DATA_PRINT prints the data of an XYZL file.
- XYZL_DATA_READ reads the data in an XYZL file.
- XYZL_DATA_WRITE writes the data of an XYZL file.
- XYZL_EXAMPLE sets data suitable for a pair of XYZ and XYZL files.
- XYZL_EXAMPLE_SIZE sizes the data to be created by XYZL_EXAMPLE.
- XYZL_HEADER_PRINT prints the header of an XYZL file.
- XYZL_HEADER_READ determines the number of line items in an XYZL file.
- XYZL_HEADER_WRITE writes the header of an XYZL file.
- XYZL_WRITE writes the header and data for an XYZL file.
You can go up one level to the C++ source codes.
Last revised on 25 October 2010.