VolumeInterface Manual


A maxon::VolumeInterface is used to store and handle volume data. It is typically obtained from a VolumeObject, see VolumeObject Manual.


Volume information can be stored in a file:

The grid settings are accessed with:

// This example prints some data on the volumes grid.
// get volume
const maxon::VolumeRef volume = volumeObject->GetVolume();
// check grid
if (volume.HasGrid())
const maxon::String gridName = volume.GetGridName();
const GRIDCLASS gridClass = volume.GetGridClass();
DiagnosticOutput("@ (@)", gridName, gridClass);


The data stored in a volume is accessed with the maxon::GridIteratorInterface iterator:

// This example iterates over the active cells of the given volume.
// get volume
const maxon::VolumeRef volume = volumeObject->GetVolume();
// get matrix
const maxon::Matrix transform = volume.GetGridTransform();
// create iterator
iterator.Init(volume) iferr_return;
// iterate
for (; iterator.IsNotAtEnd(); iterator.StepNext())
// get value
const Float32 value = iterator.GetValue();
// get coordinates
const maxon::IntVector32 coord = iterator.GetCoords();
DiagnosticOutput("@: @", coord, value);
// get world space coordinates
Vector pos;
pos.x = coord.x;
pos.y = coord.y;
pos.z = coord.z;
pos = transform * pos;
DiagnosticOutput("World space coordinates: @", pos);


The grid accessor can be used to both retrieve and set the volume data:

Volume data is accessed with:

// This example creates a new VolumeObject and a new volume.
// It uses the GridAccessor to set values of the volume.
// create VolumeObject
VolumeObject* const volumeObj = VolumeObject::Alloc();
if (volumeObj == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
doc->InsertObject(volumeObj, nullptr, nullptr);
// create volume
volume.SetGridName("Example Grid"_s);
const Vector scaleFactor { 10.0 };
const maxon::Matrix scaleMatrix = MatrixScale(scaleFactor);
// create accessor
access.Init(volume, maxon::VOLUMESAMPLER::NEAREST) iferr_return;
// set values in the shape of a helix
Float offset = 0.0;
const Float scale = 100.0;
const Float scaleY = 10.0;
while (offset < 50.0)
Float64 sin;
Float64 cos;
maxon::SinCos(offset, sin, cos);
pos.x = maxon::Int32(sin * scale);
pos.z = maxon::Int32(cos * scale);
pos.y = maxon::Int32(offset * scaleY);
// set value
access.SetValue(pos, 10.0) iferr_return;
offset = offset + 0.01;
// insert volume

Further Reading