MorphoGraphX
|
Class representing the content of a PLY file. More...
#include <PlyFile.hpp>
Classes | |
class | Element |
Class representing an element. More... | |
class | Property |
Class representing a property in an element. More... | |
Public Types | |
enum | TYPE { CHAR, UCHAR, SHORT, USHORT, INT, UINT, FLOAT, DOUBLE, NB_TYPES, INVALID_TYPE } |
Enumeration for the possible types of the properties. More... | |
enum | FORMAT_TYPES { UNSPECIFIED_FORMAT, ASCII, BINARY_LITTLE_ENDIAN, BINARY_BIG_ENDIAN } |
Enumeration of the possible file formats. More... | |
Public Member Functions | |
PlyFile () | |
Create a new file. | |
void | clear () |
Remove any element from the file, and reset version number and format. | |
bool | init (FORMAT_TYPES format=BINARY_LITTLE_ENDIAN, const QString &version="1.0") |
Initialize the file with a format and a version. | |
bool | validate () |
Validate the content. More... | |
void | allocate () |
Allocate all the properties of all the element in the file. | |
FORMAT_TYPES | format () const |
Format of the file. | |
bool | setFormat (FORMAT_TYPES f) |
Set the file format, checking the validity of the argument. | |
bool | setVersion (QString version) |
Set the format version, checking it's validity. | |
const QString & | version () const |
Version fo the format. | |
Element * | element (size_t idx) |
Access an element by index. | |
const Element * | element (size_t idx) const |
Access an element by index. | |
Element * | element (const QString &name) |
Access an element by name. | |
const Element * | element (const QString &name) const |
Access an element by name. | |
Element * | createElement (const QString &name, size_t nb_elements) |
Create a element name with nb_elements items. | |
Element * | currentElement () |
Get the current element (i.e. More... | |
bool | hasElement (const QString &name) const |
Check if the element name exists. | |
size_t | nbElements () const |
Return the number of elements in the file. | |
bool | attach (Element *el) |
Attach an element to the file. | |
bool | detach (Element *el) |
Detach an element from the file. | |
bool | parseHeader (const QString &filename) |
Parse the head of a PLY file. More... | |
bool | parseContent () |
Parse the content of the current file. More... | |
bool | error (const QString err) const |
Write the error on standard out, possibly with file and line number if they have been specified. More... | |
bool | save (const QString &filename) const |
Save the file to filename . | |
qint64 | contentPosition () const |
Get the position of the content in a file. More... | |
bool | isValid () const |
Check if the last call to PlyFile::validate was successful of not. | |
operator bool () const | |
Check if the last call to PlyFile::validate was successful of not. | |
const QStringList & | comments () const |
See the comments currently defined. | |
void | addComment (QString line) |
Add a comment. More... | |
void | clearComments () |
Remove all comments. | |
void | _attach (Element *el) |
void | _detach (Element *el) |
Static Public Attributes | |
static const unsigned int | typeSizes [NB_TYPES] |
Array holding the size in byte of the various types. | |
static char const *const | typeNames [NB_TYPES+1] |
Array of C-string representation of the types. | |
static char const *const | formatNames [4] |
Array of C-string representation of the formats. | |
Protected Member Functions | |
bool | parseAsciiContent (QFile &f) |
bool | parseBinaryContent (QFile &f, bool little_endian) |
bool | readFormat (const QStringList &fields) |
bool | readElement (const QStringList &fields) |
bool | readProperty (const QStringList &fields) |
bool | writeHeader (QFile &f) const |
bool | writeAsciiContent (QFile &f) const |
bool | writeBinaryContent (QFile &f, bool little_endian) const |
TYPE | parseType (QString typeName) const |
Protected Attributes | |
QList< Element * > | _elements |
QHash< QString, int > | _element_map |
Element * | current_element |
QString | filename |
int | line_nb |
FORMAT_TYPES | _format |
QString | _version |
QStringList | _comments |
int | _version_major |
int | _version_minor |
bool | is_valid |
qint64 | _contentPosition |
Class representing the content of a PLY file.
A PLY file is a collection of elements, with a format and a version number (that currently should be 1.0).
Each element has a name, that must be unique in the file, a size (i.e. how many items they contain), and a set of properties, shared by the elements.
Each property has:
Enumeration of the possible file formats.
Enumeration for the possible types of the properties.
void mgx::util::PlyFile::addComment | ( | QString | line | ) |
Add a comment.
If the line contains new lines, it will be split
|
inline |
Get the position of the content in a file.
This is set by PlyFile::parseHeader
|
inline |
Get the current element (i.e.
the last one created with createElement
bool mgx::util::PlyFile::error | ( | const QString | err | ) | const |
Write the error on standard out, possibly with file and line number if they have been specified.
Then, returns false.
bool mgx::util::PlyFile::parseContent | ( | ) |
Parse the content of the current file.
The file's header must have been parsed. This gives the user the opportunity to change the memory type of the properties before reading. Also, any property with a INVALID_TYPE
memory type will be skipped instead of read.
bool mgx::util::PlyFile::parseHeader | ( | const QString & | filename | ) |
Parse the head of a PLY file.
bool mgx::util::PlyFile::validate | ( | ) |
Validate the content.
This must be called before writing