15 #define FORALL_PLY_TYPES(macro) \
25 #define FORALL_PLY_TYPEIDS(macro) \
26 macro(int8_t, PlyFile::CHAR); \
27 macro(uint8_t, PlyFile::UCHAR); \
28 macro(int16_t, PlyFile::SHORT); \
29 macro(uint16_t, PlyFile::USHORT); \
30 macro(int32_t, PlyFile::INT); \
31 macro(uint32_t, PlyFile::UINT); \
32 macro(float, PlyFile::FLOAT); \
33 macro(double, PlyFile::DOUBLE)
72 #define INLINE_TYPE_ASSOC(T, TYPEID) \
73 static inline TYPE getType(const T &) { return TYPEID; \
75 FORALL_PLY_TYPEIDS(INLINE_TYPE_ASSOC)
76 #undef INLINE_TYPE_ASSOC
150 template <
typename T> std::vector<std::vector<T> >*
list()
154 if(getType(T()) != _memType)
156 return (std::vector<std::vector<T> >*)_content;
163 template <
typename T> std::vector<T>*
value()
167 if(getType(T()) != _memType)
169 return (std::vector<T>*)_content;
175 template <
typename T>
const std::vector<std::vector<T> >*
list()
const
179 if(getType(T()) != _memType)
181 return (
const std::vector<std::vector<T> >*)_content;
188 template <
typename T>
const std::vector<T>*
value()
const
192 if(getType(T()) != _memType)
194 return (
const std::vector<T>*)_content;
359 return _properties.size();
581 return current_element;
592 return _elements.size();
637 return _contentPosition;
649 operator bool()
const {
return is_valid; }
684 bool parseAsciiContent(
QFile& f);
685 bool parseBinaryContent(
QFile& f,
bool little_endian);
691 bool writeHeader(
QFile& f)
const;
692 bool writeAsciiContent(
QFile& f)
const;
693 bool writeBinaryContent(
QFile& f,
bool little_endian)
const;
708 int _version_major, _version_minor;
710 qint64 _contentPosition;
714 #endif // PLYFILE_HPP
Class representing an element.
Definition: PlyFile.hpp:323
std::vector< T > * value()
Return a pointer to the values help by the property as long as the property is a value and the type i...
Definition: PlyFile.hpp:163
The content is written in ASCII.
Definition: PlyFile.hpp:92
Element * createElement(const QString &name, size_t nb_elements)
Create a element name with nb_elements items.
const Element * parent() const
Get the element containing the property, if any.
Definition: PlyFile.hpp:289
bool setVersion(QString version)
Set the format version, checking it's validity.
size_t nbElements() const
Return the number of elements in the file.
Definition: PlyFile.hpp:591
qint64 contentPosition() const
Get the position of the content in a file.
Definition: PlyFile.hpp:636
TYPE
Enumeration for the possible types of the properties.
Definition: PlyFile.hpp:59
TYPE fileType() const
File type of the property value.
Definition: PlyFile.hpp:212
16 bits unsigned integer
Definition: PlyFile.hpp:63
Element * currentElement()
Get the current element (i.e.
Definition: PlyFile.hpp:580
bool save(const QString &filename) const
Save the file to filename.
void setSizeType(TYPE st)
Change the file type of the size of the property.
Definition: PlyFile.hpp:268
Class representing a property in an element.
Definition: PlyFile.hpp:109
The content is written in binary with little endian representation of numbers.
Definition: PlyFile.hpp:93
AttribBase(const QString &name) const QString & name()
Default constructor of named attribute.
Definition: Attributes.hpp:54
bool hasElement(const QString &name) const
Check if the element name exists.
size_t size() const
Number of items in the element.
Definition: PlyFile.hpp:365
bool error(const QString err) const
Write the error on standard out, possibly with file and line number if they have been specified...
void setMemType(TYPE mt)
Change the memory type of the property.
const std::vector< T > * value() const
Return a pointer to the values help by the property as long as the property is a value and the type i...
Definition: PlyFile.hpp:188
bool hasProperty(const QString &name) const
Returns true if the element has a property names name.
void allocate(size_t size)
Allocate the memory for the property, as long as memType is not INVALID_TYPE.
Element(const QString &name, PlyFile *parent=0)
Element constructor.
const QString & name() const
Name of the element.
Definition: PlyFile.hpp:444
bool attach(Element *el)
Attach an element to the file.
QStringList properties() const
Get the list of property names.
Element * element(size_t idx)
Access an element by index.
64 bits floating point
Definition: PlyFile.hpp:67
Property(const QString &name, Element *el=0)
Constructor of a property.
size_t size() const
Size of the property, that is the number of elements stored in it.
Definition: PlyFile.hpp:240
Property * createValue(const QString &name, TYPE file, TYPE mem=INVALID_TYPE)
Create a new value property if the name doesn't already exist.
PlyFile * parent()
Get the parent of the element.
Definition: PlyFile.hpp:467
bool init(FORMAT_TYPES format=BINARY_LITTLE_ENDIAN, const QString &version="1.0")
Initialize the file with a format and a version.
const PlyFile * parent() const
Get the parent of the element.
Definition: PlyFile.hpp:473
static const unsigned int typeSizes[NB_TYPES]
Array holding the size in byte of the various types.
Definition: PlyFile.hpp:81
bool parseHeader(const QString &filename)
Parse the head of a PLY file.
void allocate()
Allocate all the properties of all the element in the file.
FORMAT_TYPES
Enumeration of the possible file formats.
Definition: PlyFile.hpp:90
bool validate()
Validate the content.
KIND kind() const
Kind of the property.
Definition: PlyFile.hpp:233
Property * createList(const QString &name, TYPE size, TYPE file, TYPE mem=INVALID_TYPE)
Create a new value property if the name doesn't already exist.
const QString & name() const
Name of the property.
Definition: PlyFile.hpp:205
const QStringList & comments() const
See the comments currently defined.
Definition: PlyFile.hpp:654
The property holds a variable number of values per element.
Definition: PlyFile.hpp:115
void clearComments()
Remove all comments.
Definition: PlyFile.hpp:668
8 bits signed integer
Definition: PlyFile.hpp:60
Property * property(size_t pos)
Access a property by index number.
Number of types, also used to mark an invalid type.
Definition: PlyFile.hpp:68
void clear()
Remove any property attached to this element.
16 bits signed integer
Definition: PlyFile.hpp:62
32 bits signed integer
Definition: PlyFile.hpp:64
TYPE sizeType() const
File type of the size of the property list.
Definition: PlyFile.hpp:226
void allocate()
Allocate the memory for all the properties attached to the element.
TYPE memType() const
Memory type of the property value.
Definition: PlyFile.hpp:219
bool error(const QString &str) const
Write the error in the standard out and return false.
bool error(const QString &str) const
Print an error on the standard output and return false.
32 bits floating point
Definition: PlyFile.hpp:66
PlyFile()
Create a new file.
bool detach(Property *prop)
Remove a property from the element.
bool allocated() const
Return true if the element has been allocated.
Definition: PlyFile.hpp:456
8 bits unsigned integer
Definition: PlyFile.hpp:61
static char const *const formatNames[4]
Array of C-string representation of the formats.
Definition: PlyFile.hpp:100
bool setParent(PlyFile *p)
Change the parent of the element, only if the new parent doesn't have an element with the same name...
void addComment(QString line)
Add a comment.
The content is written in binary with big endian representation of numbers.
Definition: PlyFile.hpp:94
void resize(size_t n)
Change the number of items in the element.
~Property()
The destructor takes charge to detach the property from any element that contains it...
32 bits unsigned integer
Definition: PlyFile.hpp:65
const std::vector< std::vector< T > > * list() const
Return a pointer to the list help by the property as long as the property is a list and the type is c...
Definition: PlyFile.hpp:175
The format is not yet specified.
Definition: PlyFile.hpp:91
bool rename(const QString &n)
Rename the element, only if the containing PLY file doesn't already contain an element with the new n...
void resize(size_t s)
Resize the property.
Element * parent()
Get the element containing the property, if any.
Definition: PlyFile.hpp:282
FORMAT_TYPES format() const
Format of the file.
Definition: PlyFile.hpp:530
Class representing the content of a PLY file.
Definition: PlyFile.hpp:55
bool setParent(Element *parent)
Change the parent, only if the new parent doesn't already have a property with the same name...
const QString & version() const
Version fo the format.
Definition: PlyFile.hpp:552
void deallocate()
Free the memory occupied by the property.
static char const *const typeNames[NB_TYPES+1]
Array of C-string representation of the types.
Definition: PlyFile.hpp:85
void setKind(KIND k)
Change the kind of the property.
bool attach(Property *prop)
Attach a property to the element.
bool rename(const QString &n)
Change the name of the property, only if the new name doesn't conflict with one of the other properti...
bool isValid() const
Check if the last call to PlyFile::validate was successful of not.
Definition: PlyFile.hpp:643
bool detach(Element *el)
Detach an element from the file.
void setFileType(TYPE ft)
Change the file type of the property.
Definition: PlyFile.hpp:254
size_t nbProperties() const
Number of properties in the element.
Definition: PlyFile.hpp:358
std::vector< std::vector< T > > * list()
Return a pointer to the list help by the property as long as the property is a list and the type is c...
Definition: PlyFile.hpp:150
bool setFormat(FORMAT_TYPES f)
Set the file format, checking the validity of the argument.
Definition: PlyFile.hpp:536
KIND
Kind of a property.
Definition: PlyFile.hpp:113
~Element()
The destructor takes care of detaching the element from the PLY file that contains it...
bool parseContent()
Parse the content of the current file.
void clear()
Remove any element from the file, and reset version number and format.
The property holds a single value per element.
Definition: PlyFile.hpp:114