MayaFlux 1.0.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 366 of file SpatialCache.cpp.

367{
368 std::lock_guard lock(m_impl->mutex);
369
370 if (!m_impl->archive) {
371 set_error("write: archive not open");
372 return false;
373 }
374 if (sample.positions.empty()) {
375 set_error("write: no positions");
376 return false;
377 }
378
379 if (uses_curve_schema(sample.topology)) {
380 if (!sample.ids.empty() || !sample.velocities.empty()) {
381 set_error("write: ids/velocities must be empty for a curve topology");
382 return false;
383 }
384 if (sample.vertex_counts_per_curve.empty()) {
385 set_error("write: vertex_counts_per_curve is required for a curve topology");
386 return false;
387 }
388 return write_curves_sample(stream_name, sample);
389 }
390
391 if (sample.topology == PrimitiveTopology::POINT_LIST) {
392 if (!sample.vertex_counts_per_curve.empty()) {
393 set_error("write: vertex_counts_per_curve must be empty for POINT_LIST");
394 return false;
395 }
396 return write_vertex_sample(stream_name, sample);
397 }
398
399 set_error("write: unsupported topology; SpatialCache only writes "
400 "POINT_LIST, LINE_LIST, LINE_STRIP");
402 return false;
403}
#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 operator=(), and MayaFlux::IO::write_operator_sample().

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