Public Member Functions | Private Member Functions | Private Attributes

lssr::PLYIO Class Reference

A class for input and output to ply files. More...

#include <PLYIO.hpp>

Collaboration diagram for lssr::PLYIO:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PLYIO ()
 Ctor.
void addElement (PLYElement *e)
 Adds the given element to the file.
void setVertexArray (float *array, size_t n)
 Sets the vertex array (for meshes).
void setNormalArray (float *array, size_t n)
 Sets the normal array (for meshes).
void setColorArray (float *array, size_t n)
 Sets the color array (for vertex colors).
void setIndexArray (unsigned int *array, size_t n)
 Sets the index buffer.
void save (string filename, bool binary=true)
 Save the currently present information to the given file.
void read (string filename)
 Reads all supported information from the given file.
virtual ~PLYIO ()
 Dtor.
float * getVertexArray (size_t &n)
 Returns the interlaced vertex array (or a null pointer if not set).
float * getNormalArray (size_t &n)
 Returns the interlaced normal array (or a null pointer if not set).
float * getColorArray (size_t &)
 Returns the interlaced color array (or a null pointer if not set).
float ** getIndexedVertexArray (size_t &n)
 Returns an index accessible representation (2D array) of the vertex data.
float ** getIndexedNormalArray (size_t &n)
 Returns an index accessible representation (2D array) of the vertex data.
void setIndexedVertexArray (float **arr, size_t size)
 Adds indexed vertex data.
void setIndexedNormalArray (float **arr, size_t size)
 Adds indexed vertex data.
unsigned int * getIndexArray (size_t &n)
 Returns the index array of a mesh.
bool containsElement (PLYElement &e)
 Returns true if the current element contains the provided element.
bool containsElement (string elementName)
 Returns true if the current element lists contains an element with the given name.
bool hasProperty (PLYElement &e, Property &p)
 Checks if e} has property p}.
void printElementsInHeader ()
 Prints all elements and properties to stdout.

Private Member Functions

float ** interlacedBufferToIndexedBuffer (float *src, size_t n)
float * indexedBufferToInterlacedBuffer (float **src, size_t n)
void writeHeader (ofstream &str)
void writeElements (ofstream &str)
void writeFacesBinary (ofstream &str, PLYElement *e)
void writeFacesASCII (ofstream &str, PLYElement *e)
void writeVerticesBinary (ofstream &str, PLYElement *e)
void writeVerticesASCII (ofstream &str, PLYElement *e)
void writeNormalsBinary (ofstream &out, PLYElement *e)
void writeNormalsASCII (ofstream &out, PLYElement *e)
void readVerticesBinary (ifstream &in, PLYElement *descr)
void readFacesBinary (ifstream &in, PLYElement *descr)
void readNormalsBinary (ifstream &in, PLYElement *descr)
void readVerticesASCII (ifstream &in, PLYElement *descr)
void readFacesASCII (ifstream &in, PLYElement *descr)
void readNormalsASCII (ifstream &in, PLYElement *descr)
void readHeader (ifstream &str)
char * putElementInBuffer (char *buffer, string s, float value)
bool isSupported (string element_name)
bool parseHeaderLine (const char *line)
void loadElements (ifstream &in)
void deleteBuffers ()
void allocVertexBuffers (PLYElement *dscr)
void copyElementToVertexBuffer (ifstream &str, Property *, float *buffer, size_t position)
template<typename T >
void copyElementToVertexBuffer (char *src, float *buffer, size_t positon)

Private Attributes

float * m_vertices
float * m_normals
float * m_colors
unsigned int * m_indices
size_t m_numberOfNormals
size_t m_numberOfVertices
size_t m_numberOfFaces
bool m_binary
vector< PLYElement * > m_elements

Detailed Description

A class for input and output to ply files.

Definition at line 37 of file PLYIO.hpp.


Constructor & Destructor Documentation

lssr::PLYIO::PLYIO (  ) 

Ctor.

Definition at line 19 of file PLYIO.cpp.

lssr::PLYIO::~PLYIO (  )  [virtual]

Dtor.

Definition at line 33 of file PLYIO.cpp.


Member Function Documentation

void lssr::PLYIO::addElement ( PLYElement e  ) 

Adds the given element to the file.

Parameters:
element A ply element description

Definition at line 1406 of file PLYIO.cpp.

void lssr::PLYIO::allocVertexBuffers ( PLYElement dscr  )  [private]

Definition at line 743 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool lssr::PLYIO::containsElement ( string  elementName  ) 

Returns true if the current element lists contains an element with the given name.

Definition at line 1411 of file PLYIO.cpp.

Here is the call graph for this function:

bool lssr::PLYIO::containsElement ( PLYElement e  ) 

Returns true if the current element contains the provided element.

Parameters:
e A ply element description object
void lssr::PLYIO::copyElementToVertexBuffer ( ifstream &  str,
Property p,
float *  buffer,
size_t  position 
) [private]

Definition at line 978 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T >
void lssr::PLYIO::copyElementToVertexBuffer ( char *  src,
float *  buffer,
size_t  positon 
) [private]
void lssr::PLYIO::deleteBuffers (  )  [private]

Definition at line 767 of file PLYIO.cpp.

Here is the caller graph for this function:

float * lssr::PLYIO::getColorArray ( size_t &  n  ) 

Returns the interlaced color array (or a null pointer if not set).

Parameters:
n Contains the number of Vertices in the array
Returns:
A pointer to color data

Definition at line 65 of file PLYIO.cpp.

unsigned int * lssr::PLYIO::getIndexArray ( size_t &  n  ) 

Returns the index array of a mesh.

Parameters:
n The number of faces in the mesh
Returns:
A pointer to the index data

Definition at line 78 of file PLYIO.cpp.

float ** lssr::PLYIO::getIndexedNormalArray ( size_t &  n  ) 

Returns an index accessible representation (2D array) of the vertex data.

Parameters:
n Contains the number of vertices
Returns:
A pointer to 2D vertex data.

Using this method, the preferred interlaced representation is converted into a 2D array. Be careful with large data sets since the information is duplicated.

Definition at line 905 of file PLYIO.cpp.

Here is the call graph for this function:

float ** lssr::PLYIO::getIndexedVertexArray ( size_t &  n  ) 

Returns an index accessible representation (2D array) of the vertex data.

Parameters:
n Contains the number of vertices
Returns:
A pointer to 2D vertex data.

Using this method, the preferred interlaced representation is converted into a 2D array. Be careful with large data sets since the information is duplicated.

Definition at line 898 of file PLYIO.cpp.

Here is the call graph for this function:

float * lssr::PLYIO::getNormalArray ( size_t &  n  ) 

Returns the interlaced normal array (or a null pointer if not set).

Parameters:
n Contains the number of Vertices in the array
Returns:
A pointer to normal data

Definition at line 52 of file PLYIO.cpp.

float * lssr::PLYIO::getVertexArray ( size_t &  n  ) 

Returns the interlaced vertex array (or a null pointer if not set).

Parameters:
n Contains the number of Vertices in the array
Returns:
A pointer to vertex data

Definition at line 39 of file PLYIO.cpp.

bool lssr::PLYIO::hasProperty ( PLYElement e,
Property p 
)

Checks if e} has property p}.

float * lssr::PLYIO::indexedBufferToInterlacedBuffer ( float **  src,
size_t  n 
) [private]

Definition at line 1355 of file PLYIO.cpp.

Here is the caller graph for this function:

float ** lssr::PLYIO::interlacedBufferToIndexedBuffer ( float *  src,
size_t  n 
) [private]

Definition at line 1320 of file PLYIO.cpp.

Here is the caller graph for this function:

bool lssr::PLYIO::isSupported ( string  element_name  )  [private]

Definition at line 1250 of file PLYIO.cpp.

Here is the caller graph for this function:

void lssr::PLYIO::loadElements ( ifstream &  in  )  [private]

Definition at line 284 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool lssr::PLYIO::parseHeaderLine ( const char *  line  )  [private]

Definition at line 180 of file PLYIO.cpp.

Here is the caller graph for this function:

void lssr::PLYIO::printElementsInHeader (  ) 

Prints all elements and properties to stdout.

Definition at line 361 of file PLYIO.cpp.

char * lssr::PLYIO::putElementInBuffer ( char *  buffer,
string  s,
float  value 
) [private]

Definition at line 689 of file PLYIO.cpp.

Here is the caller graph for this function:

void lssr::PLYIO::read ( string  filename  ) 

Reads all supported information from the given file.

Parameters:
filename A ply file

Definition at line 138 of file PLYIO.cpp.

Here is the call graph for this function:

void lssr::PLYIO::readFacesASCII ( ifstream &  in,
PLYElement descr 
) [private]

Definition at line 1030 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::readFacesBinary ( ifstream &  in,
PLYElement descr 
) [private]

Definition at line 1054 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::readHeader ( ifstream &  str  )  [private]

Definition at line 156 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::readNormalsASCII ( ifstream &  in,
PLYElement descr 
) [private]

Definition at line 945 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::readNormalsBinary ( ifstream &  in,
PLYElement descr 
) [private]

Definition at line 912 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::readVerticesASCII ( ifstream &  in,
PLYElement descr 
) [private]

Definition at line 795 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::readVerticesBinary ( ifstream &  in,
PLYElement descr 
) [private]

Definition at line 848 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::save ( string  filename,
bool  binary = true 
)

Save the currently present information to the given file.

Parameters:
filename The output file
binary If, the data is writen in binary format (default). Set this param to false to create an ASCII ply file

Definition at line 115 of file PLYIO.cpp.

Here is the call graph for this function:

void lssr::PLYIO::setColorArray ( float *  array,
size_t  n 
)

Sets the color array (for vertex colors).

Parameters:
array An array containing color information
n The number of elements in the array

Definition at line 109 of file PLYIO.cpp.

void lssr::PLYIO::setIndexArray ( unsigned int *  array,
size_t  n 
)

Sets the index buffer.

Parameters:
array A index buffer
n The number of faces encoded in the buffer

The number of face in the buffer is n} / 3 since each face consists of three vertices that are referenced in the buffer.

Definition at line 103 of file PLYIO.cpp.

void lssr::PLYIO::setIndexedNormalArray ( float **  arr,
size_t  size 
)

Adds indexed vertex data.

Parameters:
arr Indexed vertex data
size The number of vertices in the provided 2D array

The provided data is converted. Beware of memory overhead.

Definition at line 1399 of file PLYIO.cpp.

Here is the call graph for this function:

void lssr::PLYIO::setIndexedVertexArray ( float **  arr,
size_t  size 
)

Adds indexed vertex data.

Parameters:
arr Indexed vertex data
size The number of vertices in the provided 2D array

The provided data is converted. Beware of memory overhead.

Definition at line 1392 of file PLYIO.cpp.

Here is the call graph for this function:

void lssr::PLYIO::setNormalArray ( float *  array,
size_t  n 
)

Sets the normal array (for meshes).

Parameters:
array A set of normal coordinated
n The number of normals in the array

This version uses an interlaced array. Hence the number of floats in the array is 3 * n}.

Definition at line 97 of file PLYIO.cpp.

void lssr::PLYIO::setVertexArray ( float *  array,
size_t  n 
)

Sets the vertex array (for meshes).

Parameters:
array A vertex array
n The number of vertices in the array

This version uses an interlaced array. Hence the number of floats in the array is 3 * n}.

Definition at line 91 of file PLYIO.cpp.

void lssr::PLYIO::writeElements ( ofstream &  str  )  [private]

Definition at line 412 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::writeFacesASCII ( ofstream &  str,
PLYElement e 
) [private]

Definition at line 493 of file PLYIO.cpp.

Here is the caller graph for this function:

void lssr::PLYIO::writeFacesBinary ( ofstream &  str,
PLYElement e 
) [private]

Definition at line 1255 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::writeHeader ( ofstream &  str  )  [private]

Definition at line 383 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::writeNormalsASCII ( ofstream &  out,
PLYElement e 
) [private]

Definition at line 582 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::writeNormalsBinary ( ofstream &  out,
PLYElement e 
) [private]

Definition at line 626 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::writeVerticesASCII ( ofstream &  str,
PLYElement e 
) [private]

Definition at line 437 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void lssr::PLYIO::writeVerticesBinary ( ofstream &  str,
PLYElement e 
) [private]

Definition at line 508 of file PLYIO.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

bool lssr::PLYIO::m_binary [private]

Definition at line 263 of file PLYIO.hpp.

float* lssr::PLYIO::m_colors [private]

Definition at line 256 of file PLYIO.hpp.

vector<PLYElement*> lssr::PLYIO::m_elements [private]

Definition at line 265 of file PLYIO.hpp.

unsigned int* lssr::PLYIO::m_indices [private]

Definition at line 257 of file PLYIO.hpp.

float* lssr::PLYIO::m_normals [private]

Definition at line 255 of file PLYIO.hpp.

size_t lssr::PLYIO::m_numberOfFaces [private]

Definition at line 261 of file PLYIO.hpp.

Definition at line 259 of file PLYIO.hpp.

Definition at line 260 of file PLYIO.hpp.

float* lssr::PLYIO::m_vertices [private]

Definition at line 254 of file PLYIO.hpp.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Defines