Go to the documentation of this file.
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)
78 INVALID_TYPE = NB_TYPES
81 #define INLINE_TYPE_ASSOC(T, TYPEID) \
82 static inline TYPE getType(const T &) { return TYPEID; \
85 #undef INLINE_TYPE_ASSOC
90 static const unsigned int typeSizes[NB_TYPES];
94 static char const*
const typeNames[NB_TYPES + 1][3];
100 UNSPECIFIED_FORMAT = 0,
109 static char const*
const formatNames[4];
149 void allocate(
size_t size);
159 template <
typename T> std::vector<std::vector<T> >*
list()
163 if(getType(T()) != _memType)
165 return (std::vector<std::vector<T> >*)_content;
172 template <
typename T> std::vector<T>*
value()
176 if(getType(T()) != _memType)
178 return (std::vector<T>*)_content;
184 template <
typename T>
const std::vector<std::vector<T> >*
list()
const
188 if(getType(T()) != _memType)
190 return (
const std::vector<std::vector<T> >*)_content;
197 template <
typename T>
const std::vector<T>*
value()
const
201 if(getType(T()) != _memType)
203 return (
const std::vector<T>*)_content;
209 bool error(
const QString& str)
const;
258 bool rename(
const QString&
n);
272 void setMemType(
TYPE mt);
286 void setKind(KIND k);
305 bool setParent(
Element* parent);
368 return _properties.size();
388 QStringList properties()
const;
397 const Property* property(
size_t pos)
const;
401 Property* property(
const QString& name);
405 const Property* property(
const QString& name)
const;
414 Property* createValue(
const QString& name,
TYPE file,
TYPE mem = INVALID_TYPE);
428 bool error(
const QString& str)
const;
433 bool hasProperty(
const QString& name)
const;
448 Property* detach(
const QString& name);
460 bool rename(
const QString&
n);
490 void _rename_prop(
Property* prop,
const QString& new_name);
524 bool init(
FORMAT_TYPES format = BINARY_LITTLE_ENDIAN,
const QString& version =
"1.0");
547 if(f != UNSPECIFIED_FORMAT) {
557 bool setVersion(QString version);
568 Element* element(
size_t idx);
572 const Element* element(
size_t idx)
const;
576 Element* element(
const QString& name);
580 const Element* element(
const QString& name)
const;
584 Element* createElement(
const QString& name,
size_t nb_elements);
590 return current_element;
595 bool hasElement(
const QString& name)
const;
601 return _elements.size();
607 bool attach(Element* el);
612 bool detach(Element* el);
619 bool parseHeader(
const QString& filename);
633 bool error(
const QString
err)
const;
638 bool save(
const QString& filename)
const;
646 return _contentPosition;
658 operator bool()
const {
return is_valid; }
672 void addComment(QString line);
685 void _attach(Element* el);
690 void _detach(Element* el);
693 bool parseAsciiContent(QFile& f);
694 bool parseBinaryContent(QFile& f,
bool little_endian);
696 bool readFormat(
const QStringList& fields);
697 bool readElement(
const QStringList& fields);
698 bool readProperty(
const QStringList& fields);
700 bool writeHeader(QFile& f)
const;
701 bool writeAsciiContent(QFile& f)
const;
702 bool writeBinaryContent(QFile& f,
bool little_endian)
const;
704 TYPE parseType(QString typeName)
const;
@ NB_TYPES
Number of types, also used to mark an invalid type.
bool setFormat(FORMAT_TYPES f)
Set the file format, checking the validity of the argument.
const QString & name() const
Name of the property.
@ FLOAT
32 bits floating point
const QString & name() const
Name of the element.
bool allocated() const
Return true if the element has been allocated.
@ INT
32 bits signed integer
@ UINT
32 bits unsigned integer
PlyFile * parent()
Get the parent of the element.
KIND kind() const
Kind of the property.
size_t nbProperties() const
Number of properties in the element.
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...
TYPE memType() const
Memory type of the property value.
@ USHORT
16 bits unsigned integer
Distributed matrix library.
FORMAT_TYPES format() const
Format of the file.
size_t size() const
Size of the property, that is the number of elements stored in it.
TYPE
Enumeration for the possible types of the properties.
const QString & version() const
Version fo the format.
void setFileType(TYPE ft)
Change the file type of the property.
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...
#define INLINE_TYPE_ASSOC(T, TYPEID)
@ CHAR
8 bits signed integer
@ ASCII
The content is written in ASCII.
TYPE fileType() const
File type of the property value.
FORMAT_TYPES
Enumeration of the possible file formats.
mgx_EXPORT HVecUS resize(const HVecUS &data, const Point3i &before, const Point3i &after, bool center)
bool isValid() const
Check if the last call to PlyFile::validate was successful of not.
QHash< QString, int > _element_map
size_t size() const
Number of items in the element.
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...
QHash< QString, int > _property_map
Element * current_element
@ SHORT
16 bits signed integer
void setSizeType(TYPE st)
Change the file type of the size of the property.
TYPE sizeType() const
File type of the size of the property list.
void clearComments()
Remove all comments.
@ BINARY_LITTLE_ENDIAN
The content is written in binary with little endian representation of numbers.
@ VALUE
The property holds a single value per element.
QList< Element * > _elements
#define FORALL_PLY_TYPEIDS(macro)
const QStringList & comments() const
See the comments currently defined.
Element * currentElement()
Get the current element (i.e.
qint64 contentPosition() const
Get the position of the content in a file.
@ UCHAR
8 bits unsigned integer
Element * parent()
Get the element containing the property, if any.
size_t nbElements() const
Return the number of elements in the file.
const PlyFile * parent() const
Get the parent of the element.
@ DOUBLE
64 bits floating point
QList< Property * > _properties
const Element * parent() const
Get the element containing the property, if any.
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...