Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::TemporalVolume Class Reference

Data structure for time-dependent volumetric data. More...

#include <inviwo/core/datastructures/volume/temporalvolume.h>

Classes

struct  Frame
 Two frames bracketing a requested time together with a blend factor. More...
 

Public Member Functions

size_t cacheSize () const
 The maximum number of decoded frames kept in memory.
 
void clearCache ()
 
const DataMapper & dataMap () const
 
bool empty () const
 Whether there are no frames.
 
std::shared_ptr< const Volume > get (Seconds time, std::stop_token stop={}) const
 Frame nearest to the given time value. Blocks if not cached.
 
std::shared_ptr< const Volume > get (size_t index, std::stop_token stop={}) const
 
Frame interpolate (Seconds time, std::stop_token stop={}) const
 
size_t nearestIndex (Seconds time) const
 Index of the frame whose time is closest to time.
 
size_t numCached () const
 Number of frames currently held in the cache.
 
TemporalVolume & operator= (const TemporalVolume &)=delete
 
TemporalVolume & operator= (TemporalVolume &&)=delete
 
void prefetch (size_t index, const std::function< void(std::shared_ptr< Volume >)> &callback=nullptr) const
 
const VolumeConfig & prototype () const
 A prototype VolumeConfig describing dimensions, format, basis, and the DataMapper.
 
void setCacheSize (size_t n)
 Set the maximum number of decoded frames to keep in memory (clamped to >= 2).
 
size_t size () const
 Number of frames.
 
 TemporalVolume (const TemporalVolume &)=delete
 
 TemporalVolume (std::unique_ptr< TemporalVolumeLoader > loader, size_t cacheSize=8)
 
 TemporalVolume (TemporalVolume &&)=delete
 
std::pair< Seconds, Seconds > timeRange () const
 The time value of the first and last frame, or {0, 0} if empty.
 
auto times () const
 The physical time value of each frame (size equals size()).
 

Friends

template<typename T >
struct TFDataTraits
 

Detailed Description

Data structure for time-dependent volumetric data.

TemporalVolume provides access to a sequence of time steps (frames) where only a bounded sliding window of frames is kept in memory at any time. It owns a VolumeLoader, a bounded LRU cache of decoded volumes, and a set of in-flight (prefetch) load futures.

Metadata (number of frames, time values, and a prototype volume describing dimensions, format, and the DataMapper) is always available without triggering any I/O. Individual frames are loaded on demand via get() or interpolate(), and can be loaded ahead of time in the background via prefetch().

TemporalVolume is the object that flows through Inviwo ports, see TemporalVolumeInport and TemporalVolumeOutport. It is non-copyable and shared via std::shared_ptr.

See also
VolumeLoader

Constructor & Destructor Documentation

◆ TemporalVolume()

inviwo::TemporalVolume::TemporalVolume ( std::unique_ptr< TemporalVolumeLoader > loader,
size_t cacheSize = 8 )
explicit
Parameters
loaderthe loader providing frames, times, and prototype, must not be null
cacheSizemaximum number of decoded frames to keep in memory (clamped to >= 2)

Member Function Documentation

◆ clearCache()

void inviwo::TemporalVolume::clearCache ( )

Drop all cached frames and request cancellation of all in-flight prefetches. Does not block waiting for them to finish.

◆ get()

std::shared_ptr< const Volume > inviwo::TemporalVolume::get ( size_t index,
std::stop_token stop = {} ) const

Frame by index. Blocks if not cached. Returns nullptr if index is out of bounds, or if stop is requested while waiting for or performing the load.

◆ interpolate()

Frame inviwo::TemporalVolume::interpolate ( Seconds time,
std::stop_token stop = {} ) const

Return the two frames bracketing time together with a blend factor in [0, 1]. Both frames are synchronously loaded if not cached. If time is outside the time range, the nearest frame is returned in both a and b with a blend factor of 0.

◆ prefetch()

void inviwo::TemporalVolume::prefetch ( size_t index,
const std::function< void(std::shared_ptr< Volume >)> & callback = nullptr ) const

Schedule a background load (non-blocking) of the frame at index. No-op if already cached or pending. The callback is not invoked if the load is cancelled.


The documentation for this class was generated from the following file: