Dune-Fufem 2.11-git
Loading...
Searching...
No Matches

Class wrapping a portable pixmap (acquired from PPM files) providing it as a piecewise bi-linear GridFunction. More...

#include <dune/fufem/functions/portablepixelmap.hh>

Public Types

enum  IODataFormat { ASCII , Bin }
 
typedef Dune::YaspGrid< 2 > GridType
 
typedef GridType::Codim< 0 >::Geometry::LocalCoordinate LocalDomainType
 
typedef GridType::Codim< 0 >::Entity Element
 
using DomainType = typename GridType::template Codim< 0 >::Geometry::GlobalCoordinate
 
using RangeType = Dune::FieldVector< double, 1 >
 
using Basis = Dune::Functions::LagrangeBasis< GridType::LeafGridView, 1 >
 
using CoeffType = Dune::BlockVector< RangeType >
 
using FunctionType = Dune::Functions::DiscreteGlobalBasisFunction< Basis, CoeffType, Dune::Functions::HierarchicNodeToRangeMap, RangeType >
 
using LocalFunction = typename FunctionType::LocalFunction
 
using EntitySet = typename FunctionType::EntitySet
 

Public Member Functions

 PortablePixelMap (const DomainType::field_type xDomainMin, const DomainType::field_type xDomainMax, const DomainType::field_type yDomainMin, const DomainType::field_type yDomainMax, const RangeType fRangeMin, const RangeType fRangeMax, const ColorMap colormap)
 Constructor.
 
 PortablePixelMap (const RangeType fRangeMin, const RangeType fRangeMax, const ColorMap colormap)
 Constructor.
 
void readPixelMap (const char *filename, const int width=-1, const int height=-1, const int xoffset=0, const int yoffset=0)
 reads the specified rectangular section of a pixelmap (PPM)
 
RangeType operator() (const DomainType &x) const
 
const EntitySetentitySet () const
 
const CoeffTypegetCoeffs () const
 
const GridTypegetGrid () const
 
unsigned int getWidth () const
 
unsigned int getHeight () const
 
unsigned int getImgWidth () const
 
unsigned int getImgHeight () const
 
unsigned int getWhiteValue () const
 
void exportColormapGraphic (const std::string filename="colormap.ppm") const
 
 ~PortablePixelMap ()
 

Static Public Member Functions

template<typename FType >
static void exportPixelMap (const char *filename, const FType &function, RangeFieldTypeFor< FType > fRangeMin, RangeFieldTypeFor< FType > fRangeMax, const DomainFieldType xDomainMin, const DomainFieldType xDomainMax, const DomainFieldType yDomainMin, const DomainFieldType yDomainMax, const unsigned int width, const unsigned int height, const std::string info, const ColorMap colormap, IODataFormat df=Bin)
 creates a PPM (P3) file from a given scalar function
 

Friends

LocalFunction localFunction (const PortablePixelMap &ppm)
 

Detailed Description

Class wrapping a portable pixmap (acquired from PPM files) providing it as a piecewise bi-linear GridFunction.

A static function is provided to write ppm graphics from some function

A rectangular domain \( \Omega=[xDomainMin,xDomainMax]\times[yDomainMin,yDomainMax] \) is assumed.

Member Typedef Documentation

◆ Basis

◆ CoeffType

◆ DomainType

using PortablePixelMap::DomainType = typename GridType::template Codim<0>::Geometry::GlobalCoordinate

◆ Element

typedef GridType::Codim<0>::Entity PortablePixelMap::Element

◆ EntitySet

◆ FunctionType

◆ GridType

◆ LocalDomainType

typedef GridType::Codim<0>::Geometry::LocalCoordinate PortablePixelMap::LocalDomainType

◆ LocalFunction

◆ RangeType

Member Enumeration Documentation

◆ IODataFormat

An enum for the data format of exported grafix files

Enumerator
ASCII 
Bin 

Constructor & Destructor Documentation

◆ PortablePixelMap() [1/2]

PortablePixelMap::PortablePixelMap ( const DomainType::field_type  xDomainMin,
const DomainType::field_type  xDomainMax,
const DomainType::field_type  yDomainMin,
const DomainType::field_type  yDomainMax,
const RangeType  fRangeMin,
const RangeType  fRangeMax,
const ColorMap  colormap 
)
inline

Constructor.

Parameters
xDomainMinlower x-interval boundary of computational domain
xDomainMaxupper x-interval boundary of computational domain
yDomainMinlower y-interval boundary of computational domain
yDomainMaxupper y-interval boundary of computational domain
fRangeMinlowest function value that shall be mapped to a color value; DEFAULT = 0
fRangeMaxlargest function value that shall be mapped to a color value; DEFAULT = 1
colormapthe employed PortablePixelMap::ColorMap; DEFAULT = DEFAULT

◆ PortablePixelMap() [2/2]

PortablePixelMap::PortablePixelMap ( const RangeType  fRangeMin,
const RangeType  fRangeMax,
const ColorMap  colormap 
)
inline

Constructor.

Parameters
fRangeMinlowest function value that shall be mapped to a color value; DEFAULT = 0
fRangeMaxlargest function value that shall be mapped to a color value; DEFAULT = 1
colormapthe employed PortablePixelMap::ColorMap; DEFAULT = DEFAULT

◆ ~PortablePixelMap()

PortablePixelMap::~PortablePixelMap ( )
inline

Member Function Documentation

◆ entitySet()

const EntitySet & PortablePixelMap::entitySet ( ) const
inline

◆ exportColormapGraphic()

void PortablePixelMap::exportColormapGraphic ( const std::string  filename = "colormap.ppm") const
inline

◆ exportPixelMap()

template<typename FType >
static void PortablePixelMap::exportPixelMap ( const char *  filename,
const FType &  function,
RangeFieldTypeFor< FType >  fRangeMin,
RangeFieldTypeFor< FType >  fRangeMax,
const DomainFieldType  xDomainMin,
const DomainFieldType  xDomainMax,
const DomainFieldType  yDomainMin,
const DomainFieldType  yDomainMax,
const unsigned int  width,
const unsigned int  height,
const std::string  info,
const ColorMap  colormap,
IODataFormat  df = Bin 
)
inlinestatic

creates a PPM (P3) file from a given scalar function

Method creates a pixelmap (PPM P3) with width times height pixels whose color values correspond to the given function's domain, range, and values.

Parameters
filenamethe name of the PPM file to be read
functionthe function to be converted to a pixelmap
fRangeMinlower range interval boundary (function value that will correspond to black (white)); lower function values will be "cut off"
fRangeMaxupper range interval boundary (function value that will correspond to white (black)); larger function values will be "cut off"
xDomainMinlower x-interval boundary of function's domain (or rather the part of it to be exported as PixelMap)
xDomainMaxupper x-interval boundary of function's domain (or rather the part of it to be exported as PixelMap)
yDomainMinlower y-interval boundary of function's domain (or rather the part of it to be exported as PixelMap)
yDomainMaxupper y-interval boundary of function's domain (or rather the part of it to be exported as PixelMap)
widththe horizontal resolution (absolute number of pixels) of the pixelmap to be created
heightthe vertical resolution (absolute number of pixels) of the pixelmap to be created
infosome information concerning the function;
colormapthe employed PortablePixelMap::ColorMap;
dfthe employed output data format (Bin or ASCII);

◆ getCoeffs()

const CoeffType & PortablePixelMap::getCoeffs ( ) const
inline

◆ getGrid()

const GridType & PortablePixelMap::getGrid ( ) const
inline

◆ getHeight()

unsigned int PortablePixelMap::getHeight ( ) const
inline

◆ getImgHeight()

unsigned int PortablePixelMap::getImgHeight ( ) const
inline

◆ getImgWidth()

unsigned int PortablePixelMap::getImgWidth ( ) const
inline

◆ getWhiteValue()

unsigned int PortablePixelMap::getWhiteValue ( ) const
inline

◆ getWidth()

unsigned int PortablePixelMap::getWidth ( ) const
inline

◆ operator()()

RangeType PortablePixelMap::operator() ( const DomainType x) const
inline

◆ readPixelMap()

void PortablePixelMap::readPixelMap ( const char *  filename,
const int  width = -1,
const int  height = -1,
const int  xoffset = 0,
const int  yoffset = 0 
)
inline

reads the specified rectangular section of a pixelmap (PPM)

Method creates a YaspGrid<2> (structured rectangular grid) with width times height nodes. The colorvalues of the corresponding pixels are taken to be the nodal values of a Q1Function on this grid. Thus we get a pixel centered linear interpolation of the pixelmap section.

Parameters
filenamethe name of the PPM file to be read
widththe width (pixels) of the section to be imported (for negative values the width of the imported image is assumed); DEFAULT=-1
heightthe height (pixels) of the section to be imported (for negative values the height of the imported image is assumed); DEFAULT=-1
xoffsetthe x-position (in pixels) of the upper left corner of the importsection in the pixelmap counted from upper left; DEFAULT=0
yoffsetthe y-position (in pixels) of the upper left corner of the importsection in the pixelmap counted from upper left; DEFAULT=0

Friends And Related Symbol Documentation

◆ localFunction

LocalFunction localFunction ( const PortablePixelMap ppm)
friend

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