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

◆ write()

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

Append one sample to a named stream.

Creates the stream's underlying Alembic object on first call for this stream_name (applying any tags queued by write_metadata) and declares each attribute's OGeomParam at that point. Subsequent calls for the same stream_name must keep passing the same topology and the same attributes (same names, types, scopes, same order): declaration is one-time, only values change per sample.

Parameters
stream_nameName this stream is written under.
sampleThis sample's data. See SpatialSample's own doc for which fields apply to which topology.
Returns
True on success. On failure call get_last_error().

Definition at line 335 of file SpatialCache.cpp.

336{
337 std::lock_guard lock(m_impl->mutex);
338
339 if (!m_impl->archive) {
340 set_error("write: archive not open");
341 return false;
342 }
343 if (sample.positions.empty()) {
344 set_error("write: no positions");
345 return false;
346 }
347
348 if (uses_curve_schema(sample.topology)) {
349 if (!sample.ids.empty() || !sample.velocities.empty()) {
350 set_error("write: ids/velocities must be empty for a curve topology");
351 return false;
352 }
353 if (sample.vertex_counts_per_curve.empty()) {
354 set_error("write: vertex_counts_per_curve is required for a curve topology");
355 return false;
356 }
357 return write_curves_sample(stream_name, sample);
358 }
359
360 if (sample.topology == PrimitiveTopology::POINT_LIST) {
361 if (!sample.vertex_counts_per_curve.empty()) {
362 set_error("write: vertex_counts_per_curve must be empty for POINT_LIST");
363 return false;
364 }
365 return write_vertex_sample(stream_name, sample);
366 }
367
368 set_error("write: unsupported topology; SpatialCache only writes "
369 "POINT_LIST, LINE_LIST, LINE_STRIP");
371 return false;
372}
#define MF_ERROR(comp, ctx,...)
std::unique_ptr< Impl > m_impl
bool write_curves_sample(const std::string &stream_name, const SpatialSample &sample)
bool write_vertex_sample(const std::string &stream_name, const SpatialSample &sample)
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::Journal::FileIO, get_last_error(), MayaFlux::IO::SpatialSample::ids, MayaFlux::Journal::IO, m_impl, MF_ERROR, MayaFlux::IO::SpatialSample::positions, set_error(), MayaFlux::IO::SpatialSample::topology, MayaFlux::IO::SpatialSample::velocities, MayaFlux::IO::SpatialSample::vertex_counts_per_curve, write_curves_sample(), and write_vertex_sample().

Referenced by MayaFlux::IO::write_operator_sample().

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