OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::graphics::PiecewiseFunction< T > Class Template Reference

#include <colormaps.h>

+ Inheritance diagram for olb::graphics::PiecewiseFunction< T >:
+ Collaboration diagram for olb::graphics::PiecewiseFunction< T >:

Public Member Functions

 PiecewiseFunction ()
 
 ~PiecewiseFunction () override
 
 PiecewiseFunction (PiecewiseFunction< T > const &rhs)
 
PiecewiseFunction< T > & operator= (PiecewiseFunction< T > const &rhs)
 
void swap (PiecewiseFunction< T > &rhs)
 
void addPiece (Piece< T > piece, ScalarFunction< T > *f)
 
operator() (T x) const override
 
PiecewiseFunction< T > * clone () const override
 
- Public Member Functions inherited from olb::graphics::ScalarFunction< T >
virtual ~ScalarFunction ()
 

Detailed Description

template<typename T>
class olb::graphics::PiecewiseFunction< T >

Definition at line 71 of file colormaps.h.

Constructor & Destructor Documentation

◆ PiecewiseFunction() [1/2]

template<typename T >
olb::graphics::PiecewiseFunction< T >::PiecewiseFunction ( )
inline

Definition at line 73 of file colormaps.h.

73{ }

◆ ~PiecewiseFunction()

template<typename T >
olb::graphics::PiecewiseFunction< T >::~PiecewiseFunction ( )
override

Definition at line 87 of file colormaps.hh.

88{
89 for (unsigned iF=0; iF<functions.size(); ++iF) {
90 delete functions[iF];
91 }
92}

◆ PiecewiseFunction() [2/2]

template<typename T >
olb::graphics::PiecewiseFunction< T >::PiecewiseFunction ( PiecewiseFunction< T > const & rhs)

Definition at line 70 of file colormaps.hh.

71 : pieces(rhs.pieces),
72 functions(rhs.functions.size())
73{
74 for (unsigned iF=0; iF<functions.size(); ++iF) {
75 functions[iF] = rhs.functions[iF]->clone();
76 }
77}

Member Function Documentation

◆ addPiece()

template<typename T >
void olb::graphics::PiecewiseFunction< T >::addPiece ( Piece< T > piece,
ScalarFunction< T > * f )

Definition at line 102 of file colormaps.hh.

103{
104 typename std::vector<Piece<T> >::iterator pieceIt = pieces.begin();
105 typename std::vector<ScalarFunction<T>*>::iterator fIt = functions.begin();
106 while (pieceIt != pieces.end() && piece.closedBegin >= pieceIt->closedBegin) {
107 ++pieceIt;
108 ++fIt;
109 }
110 pieces.insert(pieceIt, piece);
111 functions.insert(fIt, f);
112}

References olb::graphics::Piece< T >::closedBegin.

+ Here is the caller graph for this function:

◆ clone()

template<typename T >
PiecewiseFunction< T > * olb::graphics::PiecewiseFunction< T >::clone ( ) const
overridevirtual

Implements olb::graphics::ScalarFunction< T >.

Definition at line 131 of file colormaps.hh.

132{
133 return new PiecewiseFunction(*this);
134}

◆ operator()()

template<typename T >
T olb::graphics::PiecewiseFunction< T >::operator() ( T x) const
overridevirtual

Implements olb::graphics::ScalarFunction< T >.

Definition at line 115 of file colormaps.hh.

116{
117 if (pieces.empty() || x<pieces[0].closedBegin) {
118 return T();
119 }
120 unsigned iPiece=0;
121 while (iPiece != pieces.size() && x >= pieces[iPiece].openEnd) {
122 ++iPiece;
123 }
124 if (iPiece == pieces.size() || x < pieces[iPiece].closedBegin) {
125 return T();
126 }
127 return (*functions[iPiece])(x);
128}

◆ operator=()

template<typename T >
PiecewiseFunction< T > & olb::graphics::PiecewiseFunction< T >::operator= ( PiecewiseFunction< T > const & rhs)

Definition at line 80 of file colormaps.hh.

81{
82 PiecewiseFunction<T>(rhs).swap(*this);
83 return *this;
84}

References olb::graphics::PiecewiseFunction< T >::swap().

+ Here is the call graph for this function:

◆ swap()

template<typename T >
void olb::graphics::PiecewiseFunction< T >::swap ( PiecewiseFunction< T > & rhs)

Definition at line 95 of file colormaps.hh.

96{
97 pieces.swap(rhs.pieces);
98 functions.swap(rhs.functions);
99}
+ Here is the caller graph for this function:

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