Inviwo  0.9.10.1
Inviwo documentation
inviwo::VolumeRAM Class Referenceabstract
+ Inheritance diagram for inviwo::VolumeRAM:

Public Member Functions

 VolumeRAM (const DataFormatBase *format)
 
 VolumeRAM (const VolumeRAM &rhs)=default
 
VolumeRAMoperator= (const VolumeRAM &that)=default
 
virtual VolumeRAMclone () const override=0
 
virtual void * getData ()=0
 
virtual const void * getData () const =0
 
virtual void * getData (size_t)=0
 
virtual const void * getData (size_t) const =0
 
virtual void setData (void *data, size3_t dimensions)=0
 Takes ownership of data pointer. More...
 
virtual void removeDataOwnership ()=0
 
virtual bool hasHistograms () const =0
 
virtual HistogramContainergetHistograms (size_t bins=2048u, size3_t sampleRate=size3_t(1))=0
 
virtual const HistogramContainergetHistograms (size_t bins=2048u, size3_t sampleRate=size3_t(1)) const =0
 
virtual void calculateHistograms (size_t bins, size3_t sampleRate, const bool &stop) const =0
 
virtual double getAsDouble (const size3_t &pos) const =0
 
virtual dvec2 getAsDVec2 (const size3_t &pos) const =0
 
virtual dvec3 getAsDVec3 (const size3_t &pos) const =0
 
virtual dvec4 getAsDVec4 (const size3_t &pos) const =0
 
virtual void setFromDouble (const size3_t &pos, double val)=0
 
virtual void setFromDVec2 (const size3_t &pos, dvec2 val)=0
 
virtual void setFromDVec3 (const size3_t &pos, dvec3 val)=0
 
virtual void setFromDVec4 (const size3_t &pos, dvec4 val)=0
 
virtual double getAsNormalizedDouble (const size3_t &pos) const =0
 
virtual dvec2 getAsNormalizedDVec2 (const size3_t &pos) const =0
 
virtual dvec3 getAsNormalizedDVec3 (const size3_t &pos) const =0
 
virtual dvec4 getAsNormalizedDVec4 (const size3_t &pos) const =0
 
virtual void setFromNormalizedDouble (const size3_t &pos, double val)=0
 
virtual void setFromNormalizedDVec2 (const size3_t &pos, dvec2 val)=0
 
virtual void setFromNormalizedDVec3 (const size3_t &pos, dvec3 val)=0
 
virtual void setFromNormalizedDVec4 (const size3_t &pos, dvec4 val)=0
 
virtual void setValuesFromVolume (const VolumeRAM *src, const size3_t &dstOffset, const size3_t &subSize, const size3_t &subOffset)=0
 
void setValuesFromVolume (const VolumeRAM *src, const size3_t &dstOffset=size3_t(0))
 
virtual size_t getNumberOfBytes () const =0
 
virtual std::type_index getTypeIndex () const override final
 
template<typename Result , template< class > class Predicate = dispatching::filter::All, typename Callable , typename... Args>
auto dispatch (Callable &&callable, Args &&... args) -> Result
 
template<typename Result , template< class > class Predicate = dispatching::filter::All, typename Callable , typename... Args>
auto dispatch (Callable &&callable, Args &&... args) const -> Result
 
- Public Member Functions inherited from inviwo::VolumeRepresentation
virtual void setDimensions (size3_t dimensions)=0
 
virtual const size3_t & getDimensions () const =0
 
virtual void setSwizzleMask (const SwizzleMask &mask)=0
 update the swizzle mask of the color channels when sampling the volume More...
 
virtual SwizzleMask getSwizzleMask () const =0
 
- Public Member Functions inherited from inviwo::DataRepresentation< Volume >
const DataFormatBasegetDataFormat () const
 
std::string getDataFormatString () const
 
DataFormatId getDataFormatId () const
 
void setOwner (Volume *owner)
 
VolumegetOwner ()
 
const VolumegetOwner () const
 
bool isValid () const
 
void setValid (bool valid)
 

Static Public Member Functions

template<typename T >
static T posToIndex (const glm::tvec3< T, glm::defaultp > &pos, const glm::tvec3< T, glm::defaultp > &dim)
 
template<typename T >
static T periodicPosToIndex (const glm::tvec3< T, glm::defaultp > &posIn, const glm::tvec3< T, glm::defaultp > &dim)
 

Additional Inherited Members

- Public Types inherited from inviwo::DataRepresentation< Volume >
using ReprOwner = Volume
 
- Protected Member Functions inherited from inviwo::VolumeRepresentation
 VolumeRepresentation (const DataFormatBase *format)
 
 VolumeRepresentation (const VolumeRepresentation &rhs)=default
 
VolumeRepresentationoperator= (const VolumeRepresentation &that)=default
 
- Protected Member Functions inherited from inviwo::DataRepresentation< Volume >
 DataRepresentation (const DataFormatBase *format)
 
 DataRepresentation (const DataRepresentation &rhs)=default
 
DataRepresentationoperator= (const DataRepresentation &that)=default
 
void setDataFormat (const DataFormatBase *format)
 
- Protected Attributes inherited from inviwo::DataRepresentation< Volume >
bool isValid_
 
const DataFormatBasedataFormatBase_
 
Volumeowner_
 

Member Function Documentation

◆ dispatch() [1/2]

template<typename Result , template< class > class Predicate, typename Callable , typename... Args>
auto inviwo::VolumeRAM::dispatch ( Callable &&  callable,
Args &&...  args 
) -> Result

Dispatch functionality to retrieve the actual underlaying VolumeRamPrecision. The dispatcher takes a generic lambda as argument. Code will be instantiated for all the DataFormat types by default. But by suppling the template Predicate argument the list of formats to instantiate can be filtered. Hence if one knows that only Vector types are applicable there is no need to write generic code that also works for scalars.

Example of counting the number of elements larger then 0:

VolumeRam* volumeram = ...; // of some glm vector type.
auto count = volumeram->dispatch<size_t, dispatching::filter::Vecs>([](auto vrprecision) {
using VolumeType = util::PrecisionType<decltype(vrprecision)>;
using ValueType = util::PrecisionValueType<decltype(vrprecision)>;
T* data = vrprecision->getDataTyped();
auto dim = vrprecision->getDimensions();
return std::count_if(data, data + dim.x * dim.y * dim.z,
[](auto x){return x > ValueType{0};});
});

Template arguments:

  • Result the return type of the lambda.
  • Predicate A type that is used to filter the list of types to consider in the dispatching. The dispatching::filter namespace have a few standard ones predefined.

Predicates:

  • All Matches all formats, default.
  • Floats Matches all floating point types. float, double, half, vec2, dvec3,...
  • Integers Matches all integer types, i.e. int, ivec2, uvec3...
  • Scalars Matches all scalar types, i.e. int, char, long, float, ...
  • Vecs Matches all glm vector types, i.e. vec3, ivec3, uvec4,...
  • VecNs Matches all glm vector types of length N. N = 2,3,4.
  • FloatNs Matches all floating point glm vector types of length N. N = 2,3,4.
Parameters
callableThis should be a generic lambda or a struct with a generic call operator. it will be called with the specific VolumeRamPresision<T> as the first argument and any additional arguments (args) appended to that.
argsAny additional arguments that should be passed on to the lambda.
Exceptions
dispatching::DispatchExceptionin the case that the format of the buffer is not in the list of formats after the filtering.

◆ dispatch() [2/2]

template<typename Result , template< class > class Predicate, typename Callable , typename... Args>
auto inviwo::VolumeRAM::dispatch ( Callable &&  callable,
Args &&...  args 
) const -> Result

Const overload. Callable will be called with a const VolumeRamPresision<T> pointer.

◆ setData()

virtual void inviwo::VolumeRAM::setData ( void *  data,
size3_t  dimensions 
)
pure virtual

Takes ownership of data pointer.

Parameters
datais raw volume data pointer
dimensionsis the dimensions of the data.

Implemented in inviwo::VolumeRAMPrecision< T >.


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