52 const std::vector<PlyProperty> &properties = element_.
properties();
55 if (property.isList())
58 listOffsets_.push_back(detail::align(bytesPerElement_,
alignof(std::vector<int>)));
59 bytesPerElement_ = listOffsets_.back() +
sizeof(std::vector<int>);
60 alignment_ = std::max(alignment_,
alignof(std::vector<int>));
64 bytesPerElement_ = detail::align(bytesPerElement_, property.type()) + detail::sizeOf(property.type());
65 switch (property.type())
67 case PlyDataType::Short:
68 alignment_ = std::max(alignment_,
alignof(
short));
70 case PlyDataType::UShort:
71 alignment_ = std::max(alignment_,
alignof(
unsigned short));
73 case PlyDataType::Int:
74 alignment_ = std::max(alignment_,
alignof(
int));
76 case PlyDataType::UInt:
77 alignment_ = std::max(alignment_,
alignof(
unsigned int));
79 case PlyDataType::Float:
80 alignment_ = std::max(alignment_,
alignof(
float));
82 case PlyDataType::Double:
83 alignment_ = std::max(alignment_,
alignof(
double));
95 bytesPerElement_ = detail::align(bytesPerElement_, alignment_);
99 data_ = std::unique_ptr<std::uint8_t[]>(
new std::uint8_t[element_.
size() * bytesPerElement_]);
103 auto listOffset = listOffsets_.begin();
106 if (property.isList())
109 std::uint8_t *ptr = data_.get() + *listOffset++;
110 for (std::size_t i = 0; i < element_.
size(); ++i, ptr += bytesPerElement_)
112 switch (property.type())
114 case PlyDataType::Char:
115 new (ptr) std::vector<char>();
117 case PlyDataType::UChar:
118 new (ptr) std::vector<unsigned char>();
120 case PlyDataType::Short:
121 new (ptr) std::vector<short>();
123 case PlyDataType::UShort:
124 new (ptr) std::vector<unsigned short>();
126 case PlyDataType::Int:
127 new (ptr) std::vector<int>();
129 case PlyDataType::UInt:
130 new (ptr) std::vector<unsigned int>();
132 case PlyDataType::Float:
133 new (ptr) std::vector<float>();
135 case PlyDataType::Double:
136 new (ptr) std::vector<double>();
147 auto listOffset = listOffsets_.begin();
150 if (property.isList())
153 std::uint8_t *ptr = data_.get() + *listOffset++;
154 for (std::size_t i = 0; i < element_.
size(); ++i, ptr += bytesPerElement_)
156 switch (property.type())
158 case PlyDataType::Char:
159 reinterpret_cast<std::vector<char> *
>(ptr)->~vector<char>();
161 case PlyDataType::UChar:
162 reinterpret_cast<std::vector<unsigned char> *
>(ptr)->~vector<unsigned char>();
164 case PlyDataType::Short:
165 reinterpret_cast<std::vector<short> *
>(ptr)->~vector<short>();
167 case PlyDataType::UShort:
168 reinterpret_cast<std::vector<unsigned short> *
>(ptr)->~vector<unsigned short>();
170 case PlyDataType::Int:
171 reinterpret_cast<std::vector<int> *
>(ptr)->~vector<int>();
173 case PlyDataType::UInt:
174 reinterpret_cast<std::vector<unsigned int> *
>(ptr)->~vector<unsigned int>();
176 case PlyDataType::Float:
177 reinterpret_cast<std::vector<float> *
>(ptr)->~vector<float>();
179 case PlyDataType::Double:
180 reinterpret_cast<std::vector<double> *
>(ptr)->~vector<double>();