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

data structure for holding 1D transfer function data More...

#include <transferfunction.h>

+ Inheritance diagram for inviwo::TransferFunction:

Public Member Functions

 TransferFunction (const std::vector< TFPrimitiveData > &values)
 
 TransferFunction (const std::vector< TFPrimitiveData > &values, TFPrimitiveSetType type)
 
 TransferFunction (const TransferFunction &rhs)=default
 
 TransferFunction (TransferFunction &&rhs) noexcept=default
 
TransferFunctionoperator= (const TransferFunction &rhs)=default
 
TransferFunctionoperator= (TransferFunction &&rhs) noexcept=default
 
void setMask (dvec2 mask)
 
dvec2 getMask () const
 
void setMaskMin (double maskMin)
 
double getMaskMin () const
 
void setMaskMax (double maskMax)
 
double getMaskMax () const
 
void clearMask ()
 
virtual void serialize (Serializer &s) const override
 
virtual void deserialize (Deserializer &d) override
 
vec4 sample (double v) const
 
vec4 sample (float v) const
 
virtual void interpolateAndStoreColors (std::span< vec4 > data) const override
 
- Public Member Functions inherited from inviwo::TFPrimitiveSet
 TFPrimitiveSet (const std::vector< TFPrimitiveData > &values={}, TFPrimitiveSetType type=TFPrimitiveSetType::Relative)
 
 TFPrimitiveSet (const TFPrimitiveSet &rhs)
 
 TFPrimitiveSet (TFPrimitiveSet &&rhs) noexcept=default
 
TFPrimitiveSetoperator= (const TFPrimitiveSet &rhs)
 
TFPrimitiveSetoperator= (TFPrimitiveSet &&rhs) noexcept
 
void setType (TFPrimitiveSetType type)
 
TFPrimitiveSetType getType () const
 
dvec2 getRange () const
 
size_t size () const
 
bool empty () const
 
TFPrimitiveoperator[] (size_t i)
 
const TFPrimitiveoperator[] (size_t i) const
 
TFPrimitiveget (size_t i)
 
const TFPrimitiveget (size_t i) const
 
TFPrimitivefront ()
 
const TFPrimitivefront () const
 
TFPrimitiveback ()
 
const TFPrimitiveback () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
std::vector< TFPrimitiveDataget () const
 
std::vector< TFPrimitiveDatagetUnsorted () const
 
void set (const_iterator begin, const_iterator end)
 
std::pair< std::vector< double >, std::vector< vec4 > > getVectors () const
 
std::pair< std::vector< float >, std::vector< vec4 > > getVectorsf () const
 
std::vector< double > getPositions () const
 
std::vector< float > getPositionsf () const
 
std::vector< vec4 > getColors () const
 
TFPrimitiveadd (const TFPrimitive &primitive)
 
TFPrimitiveadd (double pos, const vec4 &color)
 
TFPrimitiveadd (double pos, double alpha)
 
TFPrimitiveadd (const dvec2 &pos)
 
TFPrimitiveadd (const TFPrimitiveData &data)
 
void add (const std::vector< TFPrimitiveData > &primitives)
 
bool remove (const TFPrimitive &primitive)
 
void clear ()
 
void setPosition (std::span< TFPrimitive * > primitives, double pos)
 
virtual void onTFPrimitiveChange (const TFPrimitive &p) override
 
bool contains (const TFPrimitive *primitive) const
 
- Public Member Functions inherited from inviwo::Serializable
- Public Member Functions inherited from inviwo::Observable< TFPrimitiveSetObserver >
 Observable (const Observable< TFPrimitiveSetObserver > &other)
 
 Observable (Observable< TFPrimitiveSetObserver > &&other) noexcept
 
Observable< TFPrimitiveSetObserver > & operator= (const Observable< TFPrimitiveSetObserver > &other)
 
Observable< TFPrimitiveSetObserver > & operator= (Observable< TFPrimitiveSetObserver > &&other) noexcept
 
void addObserver (TFPrimitiveSetObserver *observer)
 
void removeObserver (TFPrimitiveSetObserver *observer)
 
virtual void startBlockingNotifications () override final
 
virtual void stopBlockingNotifications () override final
 
- Public Member Functions inherited from inviwo::ObservableInterface
- Public Member Functions inherited from inviwo::TFPrimitiveObserver
- Public Member Functions inherited from inviwo::Observer
 Observer (const Observer &other)
 
 Observer (Observer &&other)
 
Observeroperator= (Observer &&other)
 
Observeroperator= (const Observer &other)
 
virtual ~Observer ()
 
void removeObservation (ObservableInterface *observable)
 
void removeObservations ()
 

Static Public Member Functions

static std::vector< TFPrimitiveDatasimplify (const std::vector< TFPrimitiveData > &points, double delta=0.01)
 
static TransferFunction load (const std::filesystem::path &path)
 
static void save (const TransferFunction &tf, const std::filesystem::path &path)
 

Protected Member Functions

virtual std::string_view serializationKey () const override
 
virtual std::string_view serializationItemKey () const override
 
- Protected Member Functions inherited from inviwo::TFPrimitiveSet
TFPrimitiveadd (std::unique_ptr< TFPrimitive > primitive)
 
bool remove (std::vector< std::unique_ptr< TFPrimitive > >::iterator it)
 
void sort ()
 
vec4 interpolateColor (double t) const
 
- Protected Member Functions inherited from inviwo::TFPrimitiveSetObservable
void notifyTFPrimitiveAdded (const TFPrimitiveSet &set, TFPrimitive &p)
 
void notifyTFPrimitiveRemoved (const TFPrimitiveSet &set, TFPrimitive &p)
 
void notifyTFPrimitiveChanged (const TFPrimitiveSet &set, const TFPrimitive &p)
 
void notifyTFTypeChanged (const TFPrimitiveSet &set, TFPrimitiveSetType type)
 
void notifyTFMaskChanged (const TFPrimitiveSet &set, dvec2 mask)
 
- Protected Member Functions inherited from inviwo::Observable< TFPrimitiveSetObserver >
void forEachObserver (C callback)
 
- Protected Member Functions inherited from inviwo::ObservableInterface
void addObservationHelper (Observer *observer)
 
void removeObservationHelper (Observer *observer)
 
- Protected Member Functions inherited from inviwo::Observer
void addObservation (ObservableInterface *observable)
 

Friends

IVW_CORE_API bool operator== (const TransferFunction &lhs, const TransferFunction &rhs)
 
IVW_CORE_API bool operator!= (const TransferFunction &lhs, const TransferFunction &rhs)
 

Additional Inherited Members

- Public Types inherited from inviwo::TFPrimitiveSet
using transform_t = TFPrimitive& (*)(TFPrimitive*)
 
using const_transform_t = const TFPrimitive& (*)(const TFPrimitive*)
 
using iterator
 
using const_iterator
 
- Protected Attributes inherited from inviwo::TFPrimitiveSet
std::vector< std::unique_ptr< TFPrimitive > > values_
 
std::vector< TFPrimitive * > sorted_
 
- Protected Attributes inherited from inviwo::Observer
std::unordered_set< ObservableInterface * > observables_
 

Detailed Description

data structure for holding 1D transfer function data

Member Function Documentation

◆ deserialize()

virtual void inviwo::TransferFunction::deserialize ( Deserializer & d)
overridevirtual

Reimplemented from inviwo::TFPrimitiveSet.

◆ interpolateAndStoreColors()

virtual void inviwo::TransferFunction::interpolateAndStoreColors ( std::span< vec4 > data) const
overridevirtual

Interpolate the color between all neighboring pairs of TFPrimitives and write the result to dataArray. The range of all TFPrimitives is [0,1] when TF type is relative

Parameters
datawrite interpolated colors into data

Reimplemented from inviwo::TFPrimitiveSet.

◆ sample() [1/2]

vec4 inviwo::TransferFunction::sample ( double v) const

Sample the transfer function at position v and return the respective color and opacity (rgba). The range of the transfer function is [0,1].

Parameters
vsampling position, if v is outside the range [0,1] it is clamped to [0,1]
Returns
color and opacity at position v

◆ sample() [2/2]

vec4 inviwo::TransferFunction::sample ( float v) const

Sample the transfer function at position v and return the respective color and opacity (rgba). The range of the transfer function is [0,1].

Parameters
vsampling position, if v is outside the range [0,1] it is clamped to [0,1]
Returns
color and opacity at position v

◆ serializationItemKey()

virtual std::string_view inviwo::TransferFunction::serializationItemKey ( ) const
overrideprotectedvirtual

Reimplemented from inviwo::TFPrimitiveSet.

◆ serializationKey()

virtual std::string_view inviwo::TransferFunction::serializationKey ( ) const
overrideprotectedvirtual

Reimplemented from inviwo::TFPrimitiveSet.

◆ serialize()

virtual void inviwo::TransferFunction::serialize ( Serializer & s) const
overridevirtual

Reimplemented from inviwo::TFPrimitiveSet.

◆ simplify()

static std::vector< TFPrimitiveData > inviwo::TransferFunction::simplify ( const std::vector< TFPrimitiveData > & points,
double delta = 0.01 )
static

Simplify a vector of TF points by removing points that can be replaced by interpolating between the previous and the next point, as long as the resulting error is less then delta. the error is the absolute maximal component wise error at the point to be removed.


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