DGtal  0.9.4.1
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
DGtal::SimpleDistanceColorMap< TValue > Class Template Reference

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

Public Types

typedef TValue Value
 

Public Member Functions

 SimpleDistanceColorMap (const SimpleDistanceColorMap &other)
 
SimpleDistanceColorMapoperator= (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 Valuemin () const
 
const Valuemax () const
 

Protected Member Functions

 SimpleDistanceColorMap ()
 

Protected Attributes

Value myMin
 
Value myMax
 
bool myTick
 

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

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.

◆ 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  :
98  myMin(amin), myMax(amax), myTick(withTick)
99  {}
bool myTick
Boolean to activate/desactivate ticks.

◆ 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.

References DGtal::SimpleDistanceColorMap< TValue >::myMax.

169  {
170  return myMax;
171  }

◆ 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.

References DGtal::SimpleDistanceColorMap< TValue >::myMin.

159  {
160  return myMin;
161  }

◆ 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.

References DGtal::NumberTraits< T >::castToDouble(), DGtal::SimpleDistanceColorMap< TValue >::myMax, DGtal::SimpleDistanceColorMap< TValue >::myMin, and DGtal::SimpleDistanceColorMap< TValue >::myTick.

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  }
static double castToDouble(const T &aT)
Definition: NumberTraits.h:154
bool myTick
Boolean to activate/desactivate ticks.

◆ 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.

◆ 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

◆ myMin

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

◆ myTick

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

Boolean to activate/desactivate ticks.

Definition at line 183 of file SimpleDistanceColorMap.h.

Referenced by DGtal::SimpleDistanceColorMap< TValue >::operator()().


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