33#include <unordered_map>
43 enum class Type : uint8_t
59 PropertyInfo(
int stride, std::string str)
60 : stride(stride), str(str) {}
65 static std::map<Type, PropertyInfo> PropertyTable
67 { Type::INT8, PropertyInfo(1, std::string(
"char")) },
68 { Type::UINT8, PropertyInfo(1, std::string(
"uchar")) },
69 { Type::INT16, PropertyInfo(2, std::string(
"short")) },
70 { Type::UINT16, PropertyInfo(2, std::string(
"ushort")) },
71 { Type::INT32, PropertyInfo(4, std::string(
"int")) },
72 { Type::UINT32, PropertyInfo(4, std::string(
"uint")) },
73 { Type::FLOAT32, PropertyInfo(4, std::string(
"float")) },
74 { Type::FLOAT64, PropertyInfo(8, std::string(
"double")) },
75 { Type::INVALID, PropertyInfo(0, std::string(
"INVALID"))}
80 uint8_t * alias{
nullptr };
81 struct delete_array {
void operator()(uint8_t * p) {
delete[] p; } };
82 std::unique_ptr<uint8_t,
decltype(Buffer::delete_array())> data;
86 Buffer(
const size_t size) : data(new uint8_t[size], delete_array()), size(size) { alias = data.get(); }
87 Buffer(uint8_t * ptr): alias(ptr) { }
88 uint8_t * get() {
return alias; }
89 size_t size_bytes()
const {
return size; }
102 PlyProperty(std::istream & is);
103 PlyProperty(Type type, std::string & _name) : name(_name), propertyType(type) {}
104 PlyProperty(Type list_type, Type prop_type, std::string & _name,
size_t list_count)
105 : name(_name), propertyType(prop_type), isList(true), listType(list_type), listCount(list_count) {}
107 Type propertyType{ Type::INVALID };
108 bool isList{
false };
109 Type listType{ Type::INVALID };
110 size_t listCount {0};
115 PlyElement(std::istream & istream);
116 PlyElement(
const std::string & _name,
size_t count) : name(_name), size(
count) {}
119 std::vector<PlyProperty> properties;
125 std::unique_ptr<PlyFileImpl> impl;
136 bool parse_header(std::istream & is);
142 void read(std::istream & is);
148 void write(std::ostream & os,
bool isBinary);
154 std::vector<PlyElement> get_elements()
const;
155 std::vector<std::string> get_info()
const;
156 std::vector<std::string> & get_comments();
157 bool is_binary_file()
const;
166 std::shared_ptr<PlyData> request_properties_from_element(
const std::string & elementKey,
167 const std::vector<std::string> propertyKeys,
const uint32_t list_size_hint = 0);
169 void add_properties_to_element(
const std::string & elementKey,
170 const std::vector<std::string> propertyKeys,
175 const size_t listCount);
181#ifndef IGL_STATIC_LIBRARY
183# 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.