243{
244 auto it =
m_impl->vertex_streams.find(stream_name);
245 if (it ==
m_impl->vertex_streams.end()) {
246 MetaData md;
247 auto mit =
m_impl->pending_metadata.find(stream_name);
248 if (mit !=
m_impl->pending_metadata.end()) {
249 md = mit->second;
250 m_impl->pending_metadata.erase(mit);
251 }
252 auto stream = std::make_unique<VertexStream>();
253 stream->object = OPoints(
m_impl->archive->getTop(), stream_name, md);
254 it =
m_impl->vertex_streams.emplace(stream_name, std::move(
stream)).first;
255 }
256 auto&
stream = *it->second;
257 auto& schema =
stream.object.getSchema();
258
259 const P3fArraySample pos_sample(
260 reinterpret_cast<const V3f*>(sample.positions.data()), sample.positions.size());
261 const V3fArraySample vel_sample = sample.velocities.empty()
262 ? V3fArraySample()
263 : V3fArraySample(reinterpret_cast<const V3f*>(sample.velocities.data()), sample.velocities.size());
264
265 if (sample.ids.empty()) {
266 schema.set(OPointsSchema::Sample(pos_sample, vel_sample));
267 } else {
268 const UInt64ArraySample id_sample(sample.ids.data(), sample.ids.size());
269 schema.set(OPointsSchema::Sample(pos_sample, id_sample, vel_sample));
270 }
271
272 for (const auto& attr : sample.attributes) {
273 const size_t expected = vertex_attribute_count(attr.scope, sample.positions.size());
274 if (!set_attribute(
stream.geom_params, schema.getArbGeomParams(), attr, expected)) {
275 set_error(
"write: attribute '" + attr.name +
"' has an unsupported type, wrong "
276 + "element count, or was redeclared with a different type");
279 return false;
280 }
281 }
282
283 return true;
284}
#define MF_ERROR(comp, ctx,...)
Core::GlobalStreamInfo stream
std::unique_ptr< Impl > m_impl
std::string get_last_error() const
void set_error(std::string msg) const
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.