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

◆ seed() [1/2]

void MayaFlux::Buffers::VolumeGridBuffer::seed ( const std::string &  name,
const Kinesis::SpatialField field 
)

Write initial values into a scalar field from a Kinesis field.

Parameters
nameField name. Must have stride sizeof(float).
fieldSampled at each cell centre in world space.

Definition at line 459 of file VolumeGridBuffer.cpp.

460{
461 const auto* decl = find_field(name, "seed");
462 if (!decl) {
463 return;
464 }
465
466 if (decl->stride_bytes != sizeof(float)) {
468 "VolumeGridBuffer::seed: field '{}' has stride {}, SpatialField requires {}",
469 name, decl->stride_bytes, sizeof(float));
470 return;
471 }
472
473 const glm::uvec3 res = m_lattice.resolution;
474 std::vector<float> values(m_lattice.cell_count());
475
476 size_t i = 0;
477 for (uint32_t z = 0; z < res.z; ++z) {
478 for (uint32_t y = 0; y < res.y; ++y) {
479 for (uint32_t x = 0; x < res.x; ++x) {
480 values[i++] = field(m_lattice.cell_center({ x, y, z }));
481 }
482 }
483 }
484
485 seed_raw(name, values.data(), values.size() * sizeof(float));
486}
#define MF_ERROR(comp, ctx,...)
const Field * find_field(const std::string &name, const char *context) const
Resolve a field by name.
void seed_raw(const std::string &name, const void *data, size_t size)
Write initial values into a field from raw host memory.
@ BufferManagement
Buffer Management (Buffers::BufferManager, creating buffers)
@ Buffers
Buffers, Managers, processors and processing chains.
size_t cell_count() const noexcept
Total cell count.
Definition Lattice.hpp:36
glm::uvec3 resolution
Cell count per axis. Zero on any axis is invalid.
Definition Lattice.hpp:26
glm::vec3 cell_center(const glm::uvec3 &c) const noexcept
World position of a cell's centre.
Definition Lattice.hpp:70

References MayaFlux::Journal::BufferManagement, MayaFlux::Journal::Buffers, MayaFlux::Kinesis::Lattice3D::cell_center(), MayaFlux::Kinesis::Lattice3D::cell_count(), find_field(), m_lattice, MF_ERROR, MayaFlux::Kinesis::Lattice3D::resolution, and seed_raw().

+ Here is the call graph for this function: