VolumeSet Manual

About

A VolumeSet is a BaseObject that stores a collection of volume objects (VolumeObject).

A VolumeSet object is an instance of Ovolumeset.

Creation

A VolumeSet object is created as usual (see Entity Creation and Destruction Manual (Classic)):

// This example creates a VolumeSet object
// and inserts it into the given BaseDocument.
VolumeSet* const volumeSet = VolumeSet::Alloc();
if (volumeSet == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
doc->InsertObject(volumeSet, nullptr, nullptr);

Handling Volumes

A VolumeSet contains multiple VolumeObject elements. These elements are edited with:

// This example reads the grids stored in the given vdb file.
// A VolumeSet object is created and the grid with a given name
// is inserted as a VolumeObject.
// get grid names
const maxon::Int gridCnt = gridNames.GetCount();
if (gridCnt == 0)
return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION);
// create volume set
VolumeSet* const volumeSet = VolumeSet::Alloc();
if (volumeSet == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
doc->InsertObject(volumeSet, nullptr, nullptr);
// check all grids
for (maxon::Int gridIndex = 0; gridIndex < gridCnt; ++gridIndex)
{
// get grid name
const maxon::String& gridName = gridNames[gridIndex];
// check grid name
if (gridName == "cube_volume"_s)
{
// load volume data
const maxon::Volume volume = maxon::VolumeInterface::CreateFromFile(volumeUrl, 1.0, gridIndex) iferr_return;
// make volume object
VolumeObject* const volumeObject = VolumeObject::Alloc();
if (volumeObject == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
volumeObject->SetName(gridName);
// store volume data
volumeObject->SetVolume(volume);
// insert
volumeSet->AddVolume(volumeObject);
}
}

Further Reading

maxon::VolumeToolsInterface::GetGridNamesFromFile
static MAXON_METHOD Result< BaseArray< String > > GetGridNamesFromFile(const Url &filename)
VolumeObject
Definition: lib_volumeobject.h:40
BaseDocument::InsertObject
void InsertObject(BaseObject *op, BaseObject *parent, BaseObject *pred, Bool checknames=false)
maxon::String
Definition: string.h:1213
VolumeObject::Alloc
static VolumeObject * Alloc()
Definition: lib_volumeobject.h:53
iferr_return
#define iferr_return
Definition: resultbase.h:1465
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:66
maxon::BaseArray< maxon::String >
VolumeSet::Alloc
static VolumeSet * Alloc()
Definition: lib_volumeset.h:91
maxon::BaseArray::GetCount
MAXON_ATTRIBUTE_FORCE_INLINE Int GetCount() const
Definition: basearray.h:527
VolumeSet::AddVolume
void AddVolume(VolumeObject *volumeObj)
Definition: lib_volumeset.h:122
maxon::Int
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:186
BaseList2D::SetName
void SetName(const maxon::String &name)
Definition: c4d_baselist.h:2353
VolumeSet
Definition: lib_volumeset.h:78
maxon::VolumeInterface::CreateFromFile
static MAXON_METHOD Result< Volume > CreateFromFile(const Url &url, Float scale, Int gridIndex)
VolumeObject::SetVolume
void SetVolume(const maxon::VolumeInterface *volumeObj)