33#include <unordered_map>
44 enum class Type : uint8_t
60 PropertyInfo(
int stride, std::string str)
61 : stride(stride), str(str) {}
66 static std::map<Type, PropertyInfo> PropertyTable
68 { Type::INT8, PropertyInfo(1, std::string(
"char")) },
69 { Type::UINT8, PropertyInfo(1, std::string(
"uchar")) },
70 { Type::INT16, PropertyInfo(2, std::string(
"short")) },
71 { Type::UINT16, PropertyInfo(2, std::string(
"ushort")) },
72 { Type::INT32, PropertyInfo(4, std::string(
"int")) },
73 { Type::UINT32, PropertyInfo(4, std::string(
"uint")) },
74 { Type::FLOAT32, PropertyInfo(4, std::string(
"float")) },
75 { Type::FLOAT64, PropertyInfo(8, std::string(
"double")) },
76 { Type::INVALID, PropertyInfo(0, std::string(
"INVALID"))}
81 uint8_t * alias{
nullptr };
82 struct delete_array {
void operator()(uint8_t * p) {
delete[] p; } };
83 std::unique_ptr<uint8_t,
decltype(Buffer::delete_array())> data;
87 Buffer(
const size_t size) : data(new uint8_t[size], delete_array()), size(size) { alias = data.get(); }
88 Buffer(uint8_t * ptr): alias(ptr) { }
89 uint8_t * get() {
return alias; }
90 size_t size_bytes()
const {
return size; }
103 PlyProperty(std::istream & is);
104 PlyProperty(Type type, std::string & _name) : name(_name), propertyType(type) {}
105 PlyProperty(Type list_type, Type prop_type, std::string & _name,
size_t list_count)
106 : name(_name), propertyType(prop_type), isList(true), listType(list_type), listCount(list_count) {}
108 Type propertyType{ Type::INVALID };
109 bool isList{
false };
110 Type listType{ Type::INVALID };
111 size_t listCount {0};
116 PlyElement(std::istream & istream);
117 PlyElement(
const std::string & _name,
size_t count) : name(_name), size(
count) {}
120 std::vector<PlyProperty> properties;
126 std::unique_ptr<PlyFileImpl> impl;
137 bool parse_header(std::istream & is);
143 void read(std::istream & is);
149 void write(std::ostream & os,
bool isBinary);
155 std::vector<PlyElement> get_elements()
const;
156 std::vector<std::string> get_info()
const;
157 std::vector<std::string> & get_comments();
158 bool is_binary_file()
const;
167 std::shared_ptr<PlyData> request_properties_from_element(
const std::string & elementKey,
168 const std::vector<std::string> propertyKeys,
const uint32_t list_size_hint = 0);
170 void add_properties_to_element(
const std::string & elementKey,
171 const std::vector<std::string> propertyKeys,
176 const size_t listCount);
182#ifndef IGL_STATIC_LIBRARY
184# include "tinyply.cpp"
void count(const Eigen::SparseMatrix< XType > &X, const int dim, Eigen::SparseVector< SType > &S)
Count the number of non-zeros in the columns or rows of a sparse matrix.