Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::LayerRAM Class Referenceabstract
Inheritance diagram for inviwo::LayerRAM:

Public Member Functions

LayerRAM * clone () const override=0
virtual bool copyRepresentationsTo (LayerRepresentation *) const override
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
virtual double getAsDouble (const size2_t &pos) const =0
virtual dvec2 getAsDVec2 (const size2_t &pos) const =0
virtual dvec3 getAsDVec3 (const size2_t &pos) const =0
virtual dvec4 getAsDVec4 (const size2_t &pos) const =0
virtual double getAsNormalizedDouble (const size2_t &pos) const =0
virtual dvec2 getAsNormalizedDVec2 (const size2_t &pos) const =0
virtual dvec3 getAsNormalizedDVec3 (const size2_t &pos) const =0
virtual dvec4 getAsNormalizedDVec4 (const size2_t &pos) const =0
virtual const void * getData () const =0
virtual void * getData ()=0
virtual std::type_index getTypeIndex () const override final
virtual void setData (void *data, size2_t dimensions)=0
virtual void setFromDouble (const size2_t &pos, double val)=0
virtual void setFromDVec2 (const size2_t &pos, dvec2 val)=0
virtual void setFromDVec3 (const size2_t &pos, dvec3 val)=0
virtual void setFromDVec4 (const size2_t &pos, dvec4 val)=0
virtual void setFromNormalizedDouble (const size2_t &pos, double val)=0
virtual void setFromNormalizedDVec2 (const size2_t &pos, dvec2 val)=0
virtual void setFromNormalizedDVec3 (const size2_t &pos, dvec3 val)=0
virtual void setFromNormalizedDVec4 (const size2_t &pos, dvec4 val)=0
Public Member Functions inherited from inviwo::LayerRepresentation
LayerReprConfig config () const
virtual const DataFormatBasegetDataFormat () const =0
DataFormatId getDataFormatId () const
std::string_view getDataFormatString () const
virtual const size2_t & getDimensions () const =0
virtual InterpolationType getInterpolation () const =0
LayerType getLayerType () const
virtual SwizzleMask getSwizzleMask () const =0
virtual Wrapping2D getWrapping () const =0
virtual void setDimensions (size2_t dimensions)=0
virtual void setInterpolation (InterpolationType interpolation)=0
 update the interpolation for sampling layer Needs to be overloaded by child classes.
virtual void setSwizzleMask (const SwizzleMask &mask)=0
 update the swizzle mask of the channels for sampling color layers Needs to be overloaded by child classes.
virtual void setWrapping (const Wrapping2D &wrapping)=0
 Update the wrapping type of the layer Needs to be overloaded by child classes.
Public Member Functions inherited from inviwo::DataRepresentation< Layer >
const LayergetOwner () const
bool isValid () const
void setOwner (const Layer *owner)
void setValid (bool valid)
virtual void updateResource (const ResourceMeta &) const

Static Public Member Functions

static size_t posToIndex (const size2_t &pos, const size2_t &dim)

Protected Member Functions

 LayerRAM (const LayerRAM &rhs)=default
 LayerRAM (LayerType type=LayerType::Color)
LayerRAM & operator= (const LayerRAM &that)=default
Protected Member Functions inherited from inviwo::LayerRepresentation
 LayerRepresentation (const LayerRepresentation &rhs)=default
 LayerRepresentation (LayerType type=LayerType::Color)
LayerRepresentation & operator= (const LayerRepresentation &that)=default
Protected Member Functions inherited from inviwo::DataRepresentation< Layer >
DataRepresentation & operator= (const DataRepresentation &that)=default

Additional Inherited Members

Public Types inherited from inviwo::DataRepresentation< Layer >
using ReprOwner
Protected Attributes inherited from inviwo::LayerRepresentation
LayerType layerType_
Protected Attributes inherited from inviwo::DataRepresentation< Layer >
bool isValid_
const Layerowner_

Member Function Documentation

◆ clone()

LayerRAM * inviwo::LayerRAM::clone ( ) const
overridepure virtual

◆ copyRepresentationsTo()

virtual bool inviwo::LayerRAM::copyRepresentationsTo ( LayerRepresentation * ) const
overridevirtual

Copy and resize the representations of this onto the target.

Implements inviwo::LayerRepresentation.

◆ dispatch() [1/2]

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

Dispatch functionality to retrieve the actual underlaying LayerRamPrecision. 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:

LayerRam* layerram = ...; // of some glm vector type.
auto count = layerram->dispatch<size_t, dispatching::filter::Vecs>([](auto lrprecision) {
using LayerType = util::PrecisionType<decltype(lrprecision)>;
using ValueType = util::PrecisionValueType<decltype(lrprecision)>;
ValueType* data = lrprecision->getDataTyped();
auto dim = lrprecision->getDimensions();
return std::count_if(data, data + dim.x * dim.y,
[](auto x){return x > ValueType{0};});
});
typename PrecisionType< T >::type PrecisionValueType
Definition formatdispatching.h:500
typename std::remove_pointer< typename std::remove_const< T >::type >::type PrecisionType
Definition formatdispatching.h:482
Definition formatdispatching.h:382

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 LayerRAMPrecision<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::LayerRAM::dispatch ( Callable && callable,
Args &&... args ) const->Result

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

◆ getTypeIndex()

virtual std::type_index inviwo::LayerRAM::getTypeIndex ( ) const
finaloverridevirtual

The documentation for this class was generated from the following file:
  • include/inviwo/core/datastructures/image/layerram.h