27#ifndef EASY3D_FILEIO_PLY_READER_WRITER_H
28#define EASY3D_FILEIO_PLY_READER_WRITER_H
34#include <easy3d/core/types.h>
49 template <
typename VT>
52 explicit GenericProperty(
const std::string &prop_name =
"",
const std::vector<VT> &values = std::vector<VT>())
53 : std::vector<VT>(values), name(prop_name) {}
67 explicit Element(
const std::string &elem_name, std::size_t n_instances = 0) : name(elem_name),
68 num_instances(n_instances) {}
71 std::size_t num_instances;
73 std::vector<Vec3Property> vec3_properties;
74 std::vector<Vec2Property> vec2_properties;
75 std::vector<FloatProperty> float_properties;
76 std::vector<IntProperty> int_properties;
77 std::vector<FloatListProperty> float_list_properties;
78 std::vector<IntListProperty> int_list_properties;
80 std::string property_statistics()
const;
100 bool read(
const std::string& file_name, std::vector<Element>& elements);
111 static std::size_t
num_instances(
const std::string& file_name,
const std::string& element_name);
116 void collect_elements(std::vector<Element>& elements)
const;
126 struct ListProperty : PlyProperty,
GenericProperty< std::vector<double> > {
127 ListProperty(
const std::string &elem_name,
const std::string &prop_name)
128 :
GenericProperty<std::vector<double> >(prop_name), element_name(elem_name) {}
129 std::string element_name;
132 struct ValueProperty : PlyProperty, GenericProperty< double > {
133 ValueProperty(
const std::string &elem_name,
const std::string &prop_name)
134 : GenericProperty<double>(prop_name), element_name(elem_name) {}
135 std::string element_name;
138 std::vector< ListProperty* > list_properties_;
139 std::vector< ValueProperty* > value_properties_;
157 const std::string &file_name,
158 const std::vector<Element> &elements,
159 const std::string &comment =
"",
Generic property.
Definition: ply_reader_writer.h:50
A general purpose PLY file reader.
Definition: ply_reader_writer.h:89
bool read(const std::string &file_name, std::vector< Element > &elements)
Reads a PLY file and stores the model as a set of elements.
static std::size_t num_instances(const std::string &file_name, const std::string &element_name)
A quick check of the number of instances of a type of element. The typical use is to determine if a P...
A general purpose PLY file writer.
Definition: ply_reader_writer.h:147
static bool write(const std::string &file_name, const std::vector< Element > &elements, const std::string &comment="", bool binary=false)
Saves a model stored as a set of elements to file file_name.
bool is_big_endian()
returns endianness of the system.
Definition: ply_reader_writer.cpp:694
Definition: collider.cpp:182
Model element (e.g., faces, vertices, edges) with optional properties.
Definition: ply_reader_writer.h:66