DGtal 2.2.0
Loading...
Searching...
No Matches
DGtal::SimpleDistanceColorMap< TValue > Class Template Reference

Aim: simple blue to red colormap for distance information for instance. More...

#include <DGtal/io/colormaps/SimpleDistanceColorMap.h>

Public Types

typedef TValue Value
 Value type.

Public Member Functions

 SimpleDistanceColorMap (const SimpleDistanceColorMap &other)
SimpleDistanceColorMap & operator= (const SimpleDistanceColorMap &anOther)
 SimpleDistanceColorMap (const Value &amin, const Value &amax, const bool withTick=true)
Color operator() (const Value &aValue) const
void selfDisplay (std::ostream &out) const
bool isValid () const
const Value & min () const
const Value & max () const

Protected Member Functions

 SimpleDistanceColorMap ()

Protected Attributes

Value myMin
 Min value.
Value myMax
 Max value.
bool myTick
 Boolean to activate/deactivate ticks.

Detailed Description

template<typename TValue>
class DGtal::SimpleDistanceColorMap< TValue >

Aim: simple blue to red colormap for distance information for instance.

Description of class 'SimpleDistanceColorMap'

Color formula from a fragment shader in https://github.com/dgpdec/course.

Template Parameters
TValuethe value type
Examples
geometry/volumes/fullConvexityShortestPaths3D.cpp.

Definition at line 64 of file SimpleDistanceColorMap.h.

Member Typedef Documentation

◆ Value

template<typename TValue>
typedef TValue DGtal::SimpleDistanceColorMap< TValue >::Value

Value type.

Definition at line 70 of file SimpleDistanceColorMap.h.

Constructor & Destructor Documentation

◆ SimpleDistanceColorMap() [1/3]

template<typename TValue>
DGtal::SimpleDistanceColorMap< TValue >::SimpleDistanceColorMap ( const SimpleDistanceColorMap< TValue > & other)

Copy constructor.

Parameters
[in]otherthe object to clone. Forbidden by default.

References SimpleDistanceColorMap().

Referenced by operator=(), and SimpleDistanceColorMap().

◆ SimpleDistanceColorMap() [2/3]

template<typename TValue>
DGtal::SimpleDistanceColorMap< TValue >::SimpleDistanceColorMap ( const Value & amin,
const Value & amax,
const bool withTick = true )
inline

Constructor from two min and max values.

Parameters
[in]aminthe minimum value of the range.
[in]amaxthe maximum value of the range.
[in]withTickif true, white ticks are displayed (default true).

Definition at line 95 of file SimpleDistanceColorMap.h.

97 :
99 {}
Aim: simple blue to red colormap for distance information for instance.
bool myTick
Boolean to activate/deactivate ticks.

References myMax, myMin, and myTick.

◆ SimpleDistanceColorMap() [3/3]

template<typename TValue>
DGtal::SimpleDistanceColorMap< TValue >::SimpleDistanceColorMap ( )
protected

Constructor. Forbidden by default (protected to avoid g++ warnings).

Member Function Documentation

◆ isValid()

template<typename TValue>
bool DGtal::SimpleDistanceColorMap< TValue >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 151 of file SimpleDistanceColorMap.h.

151{ return true;}

◆ max()

template<typename TValue>
const Value & DGtal::SimpleDistanceColorMap< TValue >::max ( ) const
inline

Returns the upper bound of the value range.

Returns
The upper bound of the value range.

Definition at line 168 of file SimpleDistanceColorMap.h.

169 {
170 return myMax;
171 }

References myMax.

◆ min()

template<typename TValue>
const Value & DGtal::SimpleDistanceColorMap< TValue >::min ( ) const
inline

Returns the lower bound of the value range.

Returns
The lower bound of the value range.

Definition at line 158 of file SimpleDistanceColorMap.h.

159 {
160 return myMin;
161 }

References myMin.

◆ operator()()

template<typename TValue>
Color DGtal::SimpleDistanceColorMap< TValue >::operator() ( const Value & aValue) const
inline

Computes the color associated with a value.

Parameters
[in]aValueA value within the value range.
Returns
A color.

Definition at line 109 of file SimpleDistanceColorMap.h.

110 {
113 const double d = 1. - val;
114 double r = (1. - d*d) * .8;
115 double g = (1. - (2. * (d - .5)) * (2. * (d - .5))) * .7;
116 double b = (1. - (1. - d) * (1. - d));
117
118 // lines
119 if (myTick)
120 {
121 double h = val;
122 h = h * 30.;
123 h = h - floor( h );
124 h = (1. / (1. + exp(-100.*(h - .55)))) + (1. / (1. + exp(-100.*(-h + .45))));
125 h = 1. - h;
126 r = h + (1. -h)*r;
127 g = h + (1. - h)*g;
128 b = h + (1. - h)*b;
129 }
130
131 return Color(static_cast<unsigned char>(r*255),
132 static_cast<unsigned char>(g*255),
133 static_cast<unsigned char>(b*255));
134 }

References DGtal::NumberTraitsImpl< std::decay< T >::type >::castToDouble(), DGtal::Color::Color(), g(), myMax, myMin, and myTick.

◆ operator=()

template<typename TValue>
SimpleDistanceColorMap & DGtal::SimpleDistanceColorMap< TValue >::operator= ( const SimpleDistanceColorMap< TValue > & anOther)

Assignment.

Parameters
[in]anOtherthe object to copy.
Returns
a reference on 'this'. Forbidden by default.

References SimpleDistanceColorMap().

◆ selfDisplay()

template<typename TValue>
void DGtal::SimpleDistanceColorMap< TValue >::selfDisplay ( std::ostream & out) const

Writes/Displays the object on an output stream.

Parameters
[in,out]outthe output stream where the object is written.

Field Documentation

◆ myMax

template<typename TValue>
Value DGtal::SimpleDistanceColorMap< TValue >::myMax
protected

Max value.

Definition at line 180 of file SimpleDistanceColorMap.h.

Referenced by max(), operator()(), and SimpleDistanceColorMap().

◆ myMin

template<typename TValue>
Value DGtal::SimpleDistanceColorMap< TValue >::myMin
protected

Min value.

Definition at line 177 of file SimpleDistanceColorMap.h.

Referenced by min(), operator()(), and SimpleDistanceColorMap().

◆ myTick

template<typename TValue>
bool DGtal::SimpleDistanceColorMap< TValue >::myTick
protected

Boolean to activate/deactivate ticks.

Definition at line 183 of file SimpleDistanceColorMap.h.

Referenced by operator()(), and SimpleDistanceColorMap().


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