19 #include <QStringList> 25 #define FORALL_PLY_TYPES(macro) \ 35 #define FORALL_PLY_TYPEIDS(macro) \ 36 macro(int8_t, PlyFile::CHAR); \ 37 macro(uint8_t, PlyFile::UCHAR); \ 38 macro(int16_t, PlyFile::SHORT); \ 39 macro(uint16_t, PlyFile::USHORT); \ 40 macro(int32_t, PlyFile::INT); \ 41 macro(uint32_t, PlyFile::UINT); \ 42 macro(float, PlyFile::FLOAT); \ 43 macro(double, PlyFile::DOUBLE) 82 #define INLINE_TYPE_ASSOC(T, TYPEID) \ 83 static inline TYPE getType(const T &) { return TYPEID; \ 85 FORALL_PLY_TYPEIDS(INLINE_TYPE_ASSOC)
86 #undef INLINE_TYPE_ASSOC 160 template <
typename T> std::vector<std::vector<T> >*
list()
164 if(getType(T()) != _memType)
166 return (std::vector<std::vector<T> >*)_content;
173 template <
typename T> std::vector<T>*
value()
177 if(getType(T()) != _memType)
179 return (std::vector<T>*)_content;
185 template <
typename T>
const std::vector<std::vector<T> >*
list()
const 189 if(getType(T()) != _memType)
191 return (
const std::vector<std::vector<T> >*)_content;
198 template <
typename T>
const std::vector<T>*
value()
const 202 if(getType(T()) != _memType)
204 return (
const std::vector<T>*)_content;
369 return _properties.size();
398 const Property* property(
size_t pos)
const;
434 bool hasProperty(
const QString& name)
const;
591 return current_element;
602 return _elements.size();
647 return _contentPosition;
659 operator bool()
const {
return is_valid; }
694 bool parseAsciiContent(
QFile& f);
695 bool parseBinaryContent(
QFile& f,
bool little_endian);
701 bool writeHeader(
QFile& f)
const;
702 bool writeAsciiContent(
QFile& f)
const;
703 bool writeBinaryContent(
QFile& f,
bool little_endian)
const;
718 int _version_major, _version_minor;
720 qint64 _contentPosition;
724 #endif // PLYFILE_HPP Class representing an element.
Definition: PlyFile.hpp:333
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:173
The content is written in ASCII.
Definition: PlyFile.hpp:102
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:299
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:601
qint64 contentPosition() const
Get the position of the content in a file.
Definition: PlyFile.hpp:646
TYPE
Enumeration for the possible types of the properties.
Definition: PlyFile.hpp:69
TYPE fileType() const
File type of the property value.
Definition: PlyFile.hpp:222
16 bits unsigned integer
Definition: PlyFile.hpp:73
Element * currentElement()
Get the current element (i.e.
Definition: PlyFile.hpp:590
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:278
Class representing a property in an element.
Definition: PlyFile.hpp:119
The content is written in binary with little endian representation of numbers.
Definition: PlyFile.hpp:103
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:375
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:198
void allocate(size_t size)
Allocate the memory for the property, as long as memType is not INVALID_TYPE.
const QString & name() const
Name of the element.
Definition: PlyFile.hpp:454
bool attach(Element *el)
Attach an element to the file.
Element * element(size_t idx)
Access an element by index.
64 bits floating point
Definition: PlyFile.hpp:77
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:250
PlyFile * parent()
Get the parent of the element.
Definition: PlyFile.hpp:477
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:483
static const unsigned int typeSizes[NB_TYPES]
Array holding the size in byte of the various types.
Definition: PlyFile.hpp:91
bool parseHeader(const QString &filename)
Parse the head of a PLY file.
FORMAT_TYPES
Enumeration of the possible file formats.
Definition: PlyFile.hpp:100
bool validate()
Validate the content.
KIND kind() const
Kind of the property.
Definition: PlyFile.hpp:243
const QString & name() const
Name of the property.
Definition: PlyFile.hpp:215
const QStringList & comments() const
See the comments currently defined.
Definition: PlyFile.hpp:664
The property holds a variable number of values per element.
Definition: PlyFile.hpp:125
void clearComments()
Remove all comments.
Definition: PlyFile.hpp:678
8 bits signed integer
Definition: PlyFile.hpp:70
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
Number of types, also used to mark an invalid type.
Definition: PlyFile.hpp:78
16 bits signed integer
Definition: PlyFile.hpp:72
32 bits signed integer
Definition: PlyFile.hpp:74
TYPE sizeType() const
File type of the size of the property list.
Definition: PlyFile.hpp:236
TYPE memType() const
Memory type of the property value.
Definition: PlyFile.hpp:229
bool error(const QString &str) const
Print an error on the standard output and return false.
32 bits floating point
Definition: PlyFile.hpp:76
PlyFile()
Create a new file.
bool allocated() const
Return true if the element has been allocated.
Definition: PlyFile.hpp:466
8 bits unsigned integer
Definition: PlyFile.hpp:71
static char const *const formatNames[4]
Array of C-string representation of the formats.
Definition: PlyFile.hpp:110
void addComment(QString line)
Add a comment.
The content is written in binary with big endian representation of numbers.
Definition: PlyFile.hpp:104
~Property()
The destructor takes charge to detach the property from any element that contains it...
32 bits unsigned integer
Definition: PlyFile.hpp:75
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:185
The format is not yet specified.
Definition: PlyFile.hpp:101
void resize(size_t s)
Resize the property.
Element * parent()
Get the element containing the property, if any.
Definition: PlyFile.hpp:292
FORMAT_TYPES format() const
Format of the file.
Definition: PlyFile.hpp:540
Class representing the content of a PLY file.
Definition: PlyFile.hpp:65
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:562
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:95
void setKind(KIND k)
Change the kind of the property.
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:653
bool detach(Element *el)
Detach an element from the file.
void setFileType(TYPE ft)
Change the file type of the property.
Definition: PlyFile.hpp:264
size_t nbProperties() const
Number of properties in the element.
Definition: PlyFile.hpp:368
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:160
bool setFormat(FORMAT_TYPES f)
Set the file format, checking the validity of the argument.
Definition: PlyFile.hpp:546
KIND
Kind of a property.
Definition: PlyFile.hpp:123
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:124