1 #ifndef LICORNEA_PLY_IMPORTER_H_ 2 #define LICORNEA_PLY_IMPORTER_H_ 25 using std::runtime_error::runtime_error;
35 const static std::size_t maximal_ascii_element_line_length_ = 256;
38 none, int8, uint8, int16, uint16, int32, uint32, float32, float64, list
42 property_type type = none;
43 std::ptrdiff_t offset;
46 explicit operator bool()
const {
return (type != none); }
51 std::ifstream::pos_type vertex_data_start_;
52 std::size_t number_of_vertices_;
53 enum { binary_big_endian, binary_little_endian, ascii } format_;
54 std::size_t vertex_length_;
55 std::size_t number_of_properties_;
59 property x_, y_, z_, r_, g_, b_, nx_, ny_, nz_, w_;
61 std::ptrdiff_t current_element_;
64 void skip_lines_(std::size_t n) {
65 while(n--)
skip_line(file_, line_delimitor_);
68 void read_line_(std::string& ln) {
72 bool is_host_endian_binary_()
const {
74 else return (format_ == binary_big_endian);
77 property* identify_property_(
const std::string& nm);
78 static property_type identify_property_type_(
const std::string& nm);
79 static std::size_t property_type_size_(property_type t);
82 template<
typename Po
int>
void read_ascii_(Point* buffer, std::size_t n);
83 template<
typename Po
int>
void read_binary_(Point* buffer, std::size_t n);
85 void read_ascii_point_(
point_xyz& out_point,
const char* props[])
const;
86 void read_ascii_point_(
point_full& out_point,
const char* props[])
const;
87 void read_binary_point_(
point_xyz& out_point,
byte* data)
const;
89 template<
typename T> T read_binary_property_(
const property& prop,
byte* data)
const;
94 std::size_t size()
const;
97 std::ptrdiff_t tell()
const;
const bool host_is_little_endian
void skip_line(std::istream &str, line_delimitor ld)
void read_line(std::istream &str, std::string &line, line_delimitor ld)
Imports point cloud from PLY file.