52#ifndef __PLYREADER_HH__
53#define __PLYREADER_HH__
66#include <OpenMesh/Core/System/config.h>
67#include <OpenMesh/Core/Utils/SingletonT.hh>
68#include <OpenMesh/Core/IO/reader/BaseReader.hh>
69#include <OpenMesh/Core/Utils/GenProg.hh>
103 std::string
get_magic()
const override {
return "PLY"; }
105 bool read(
const std::string& _filename,
109 bool read(std::istream& _is,
113 bool can_u_read(
const std::string& _filename)
const override;
117 ValueTypeINT8, ValueTypeCHAR,
118 ValueTypeUINT8, ValueTypeUCHAR,
119 ValueTypeINT16, ValueTypeSHORT,
120 ValueTypeUINT16, ValueTypeUSHORT,
121 ValueTypeINT32, ValueTypeINT,
122 ValueTypeUINT32, ValueTypeUINT,
123 ValueTypeFLOAT32, ValueTypeFLOAT,
124 ValueTypeFLOAT64, ValueTypeDOUBLE
129 bool can_u_read(std::istream& _is)
const;
131 bool read_ascii(std::istream& _in, BaseImporter& _bi,
const Options& _opt)
const;
132 bool read_binary(std::istream& _in, BaseImporter& _bi,
bool swap,
const Options& _opt)
const;
134 void readValue(ValueType _type , std::istream& _in,
float& _value)
const;
135 void readValue(ValueType _type , std::istream& _in,
double& _value)
const;
136 void readValue(ValueType _type , std::istream& _in,
unsigned int& _value)
const;
137 void readValue(ValueType _type , std::istream& _in,
unsigned short& _value)
const;
138 void readValue(ValueType _type , std::istream& _in,
unsigned char& _value)
const;
139 void readValue(ValueType _type , std::istream& _in,
int& _value)
const;
140 void readValue(ValueType _type , std::istream& _in,
short& _value)
const;
141 void readValue(ValueType _type , std::istream& _in,
signed char& _value)
const;
144 void readInteger(ValueType _type, std::istream& _in, T& _value)
const;
147 void consume_input(std::istream& _in,
int _count)
const {
150 int loops = _count / 8 ;
153 for (
auto i = 0 ; i < loops; ++i) {
154 _in.read(
reinterpret_cast<char*
>(&buff[0]), 8);
158 _in.read(
reinterpret_cast<char*
>(&buff[0]), _count - 8 * loops );
161 mutable unsigned char buff[8];
164 mutable Options options_;
167 mutable Options userOptions_;
169 mutable unsigned int vertexCount_;
170 mutable unsigned int faceCount_;
172 mutable uint vertexDimension_;
175 XCOORD,YCOORD,ZCOORD,
177 COLORRED,COLORGREEN,COLORBLUE,COLORALPHA,
178 XNORM,YNORM,ZNORM, CUSTOM_PROP, VERTEX_INDICES,
179 TEXCOORD, TEXNUMBER, UNSUPPORTED
183 mutable std::map<ValueType, int> scalar_size_;
191 ValueType listIndexType;
192 PropertyInfo():property(UNSUPPORTED),value(Unsupported),name(
""),listIndexType(Unsupported){}
193 PropertyInfo(Property _p, ValueType _v):property(_p),value(_v),name(
""),listIndexType(Unsupported){}
194 PropertyInfo(Property _p, ValueType _v,
const std::string& _n):property(_p),value(_v),name(_n),listIndexType(Unsupported){}
209 std::vector< PropertyInfo > properties_;
212 mutable std::vector< ElementInfo > elements_;
214 mutable std::vector< std::string > texture_files_;
217 inline void read(_PLYReader_::ValueType _type, std::istream& _in, T& _value, OpenMesh::GenProg::TrueType )
const
219 readValue(_type, _in, _value);
223 inline void read(_PLYReader_::ValueType _type, std::istream& _in, T& _value, OpenMesh::GenProg::FalseType )
const
229 inline void readInteger(_PLYReader_::ValueType _type, std::istream& _in, T& _value, OpenMesh::GenProg::TrueType )
const
231 readInteger(_type, _in, _value);
235 inline void readInteger(_PLYReader_::ValueType _type, std::istream& _in, T& _value, OpenMesh::GenProg::FalseType )
const
241 template<
bool binary,
typename T,
typename Handle>
242 void readCreateCustomProperty(std::istream& _in, BaseImporter& _bi, Handle _h,
const std::string& _propName,
const ValueType _valueType,
const ValueType _listType)
const;
244 template<
bool binary,
typename Handle>
245 void readCustomProperty(std::istream& _in, BaseImporter& _bi, Handle _h,
const std::string& _propName,
const _PLYReader_::ValueType _valueType,
const _PLYReader_::ValueType _listIndexType)
const;
254OPENMESHDLLEXPORT _PLYReader_& PLYReader();
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
_PLYReader_ __PLYReaderInstance
Declare the single entity of the PLY reader.
Definition: PLYReader.cc:73
Base class for importer modules.
Definition: BaseImporter.hh:84
Set options for reader/writer modules.
Definition: Options.hh:92
Base class for reader modules.
Definition: BaseReader.hh:87
Implementation of the PLY format reader.
Definition: PLYReader.hh:96
std::string get_description() const override
Returns a brief description of the file type that can be parsed.
Definition: PLYReader.hh:101
std::string get_magic() const override
Return magic bits used to determine file format.
Definition: PLYReader.hh:103
std::string get_extensions() const override
Returns a string with the accepted file extensions separated by a whitespace and in small caps.
Definition: PLYReader.hh:102