1 #ifndef MF_PLY_IMPORTER_H_
2 #define MF_PLY_IMPORTER_H_
16 #include "../utility/io.h"
26 const static std::size_t maximal_ascii_element_line_length_ = 256;
29 none, int8, uint8, int16, uint16, int32, uint32, float32, float64, list
33 property_type type = none;
34 std::ptrdiff_t offset;
37 explicit operator bool()
const {
return (type != none); }
42 std::ifstream::pos_type vertex_data_start_;
43 std::size_t number_of_vertices_;
44 enum { binary_big_endian, binary_little_endian, ascii } format_;
45 std::size_t vertex_length_;
46 std::size_t number_of_properties_;
50 property x_, y_, z_, r_, g_, b_, nx_, ny_, nz_, w_;
52 std::ptrdiff_t current_element_;
55 void skip_lines_(std::size_t n) {
56 while(n--)
skip_line(file_, line_delimitor_);
59 void read_line_(std::string& ln) {
63 bool is_host_endian_binary_()
const {
65 else return (format_ == binary_big_endian);
68 property* identify_property_(
const std::string& nm);
69 static property_type identify_property_type_(
const std::string& nm);
70 static std::size_t property_type_size_(property_type t);
73 template<
typename Po
int>
void read_ascii_(Point* buffer, std::size_t n);
74 template<
typename Po
int>
void read_binary_(Point* buffer, std::size_t n);
76 void read_ascii_point_(
point_xyz& out_point,
const char* props[])
const;
77 void read_ascii_point_(
point_full& out_point,
const char* props[])
const;
78 void read_binary_point_(
point_xyz& out_point,
char* data)
const;
79 void read_binary_point_(
point_full& out_point,
char* data)
const;
80 template<
typename T> T read_binary_property_(
const property& prop,
char* data)
const;
87 std::size_t
size()
const override;
91 std::ptrdiff_t
tell()
const override;
96 bool is_ascii()
const {
return format_ == ascii; }
void read(point_xyz *, std::size_t sz) override
const bool host_is_little_endian
Definition: io.cc:30
std::ptrdiff_t tell() const override
bool is_ascii() const
Definition: ply_importer.h:96
Point cloud point with only XYZ coordinates.
Definition: point.h:14
ply_importer(const char *filename, line_delimitor ld=line_delimitor::unknown)
Imports point cloud from PLY file.
Definition: ply_importer.h:24
Point cloud point with XYZ coordinates, normal vector, weight, and RGB color.
Definition: point.h:52
line_delimitor
Definition: io.h:11
bool all_valid() const override
ply_importer(const std::string &filename, line_delimitor ld=line_delimitor::unknown)
Definition: ply_importer.h:84
bool is_binary() const
Definition: ply_importer.h:95
void skip_line(std::istream &str, line_delimitor ld)
Definition: io.cc:68
std::size_t size() const override
void read_line(std::istream &str, std::string &line, line_delimitor ld)
Definition: io.cc:52