MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ write_vertex_sample()

bool MayaFlux::IO::SpatialCache::write_vertex_sample ( const std::string &  stream_name,
const SpatialSample sample 
)
private

Definition at line 242 of file SpatialCache.cpp.

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");
278 "SpatialCache::write: '{}': {}", stream_name, get_last_error());
279 return false;
280 }
281 }
282
283 return true;
284}
#define MF_ERROR(comp, ctx,...)
Core::GlobalStreamInfo stream
Definition Config.cpp:36
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.

References MayaFlux::IO::SpatialSample::attributes, MayaFlux::Journal::FileIO, get_last_error(), MayaFlux::IO::SpatialSample::ids, MayaFlux::Journal::IO, m_impl, MF_ERROR, MayaFlux::IO::SpatialSample::positions, set_error(), stream, and MayaFlux::IO::SpatialSample::velocities.

Referenced by write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: