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

Class wrapping a greymap (acquired from PGM ASCII (P2)-files) providing it as a piecewise bi-linear GridFunction. More...

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

Public Types

enum  ColorScheme { DEFAULT , REVERSE }
 
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 = typename Dune::Functions::LagrangeBasis< GridType::LeafGridView, 1 >
 
using CoeffType = typename Dune::BlockVector< RangeType >
 
using FunctionType = Dune::Functions::DiscreteGlobalBasisFunction< Basis, CoeffType, Dune::Functions::HierarchicNodeToRangeMap, RangeType >
 
using EntitySet = typename FunctionType::EntitySet
 

Public Member Functions

 PortableGreyMap (const DomainType::field_type xDomainMin, const DomainType::field_type xDomainMax, const DomainType::field_type yDomainMin, const DomainType::field_type yDomainMax, const RangeType fRangeMin=0, const RangeType fRangeMax=1, const ColorScheme colorscheme=DEFAULT)
 Constructor.
 
 PortableGreyMap (const RangeType fRangeMin=0, const RangeType fRangeMax=1, const ColorScheme colorscheme=DEFAULT)
 Constructor.
 
void readGreyMap (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 greymap (PGM-ASCII)
 
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
 
 ~PortableGreyMap ()
 

Static Public Member Functions

template<typename FType >
static void exportGreyMap (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 unsigned int maxGreyVal=255, const ColorScheme colorscheme=DEFAULT)
 creates a PGM (P2) file from a given scalar function
 

Friends

auto localFunction (const PortableGreyMap &pgm)
 

Detailed Description

Class wrapping a greymap (acquired from PGM ASCII (P2)-files) providing it as a piecewise bi-linear GridFunction.

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

  • add support for binary read/write
  • unify PPM,PGM -> PAM

Member Typedef Documentation

◆ Basis

◆ CoeffType

◆ DomainType

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

◆ Element

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

◆ EntitySet

◆ FunctionType

◆ GridType

◆ LocalDomainType

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

◆ RangeType

Member Enumeration Documentation

◆ ColorScheme

An enum identifying the employed color scheme.

Enumerator
DEFAULT 

The default scheme is BLACK <=> fRangeMin, WHITE <=> fRangeMax

REVERSE 

The reverse scheme is BLACK <=> fRangeMax, WHITE <=> fRangeMin

Constructor & Destructor Documentation

◆ PortableGreyMap() [1/2]

PortableGreyMap::PortableGreyMap ( const DomainType::field_type  xDomainMin,
const DomainType::field_type  xDomainMax,
const DomainType::field_type  yDomainMin,
const DomainType::field_type  yDomainMax,
const RangeType  fRangeMin = 0,
const RangeType  fRangeMax = 1,
const ColorScheme  colorscheme = DEFAULT 
)
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 grey value; DEFAULT = 0
fRangeMaxlargest function value that shall be mapped to a grey value; DEFAULT = 1
colorschemethe employed PortableGreyMap::ColorScheme; DEFAULT = DEFAULT

◆ PortableGreyMap() [2/2]

PortableGreyMap::PortableGreyMap ( const RangeType  fRangeMin = 0,
const RangeType  fRangeMax = 1,
const ColorScheme  colorscheme = DEFAULT 
)
inline

Constructor.

Parameters
fRangeMinlowest function value that shall be mapped to a grey value; DEFAULT = 0
fRangeMaxlargest function value that shall be mapped to a grey value; DEFAULT = 1
colorschemethe employed PortableGreyMap::ColorScheme; DEFAULT = DEFAULT

◆ ~PortableGreyMap()

PortableGreyMap::~PortableGreyMap ( )
inline

Member Function Documentation

◆ entitySet()

const EntitySet & PortableGreyMap::entitySet ( ) const
inline

◆ exportGreyMap()

template<typename FType >
static void PortableGreyMap::exportGreyMap ( 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 unsigned int  maxGreyVal = 255,
const ColorScheme  colorscheme = DEFAULT 
)
inlinestatic

creates a PGM (P2) file from a given scalar function

Method creates a greymap (PGM P2) with width times height pixels whose grey values correspond to the given function's domain, range, and values.

Parameters
filenamethe name of the PGM file to be read
functionthe function to be converted to a greymap
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 GreyMap)
xDomainMaxupper x-interval boundary of function's domain (or rather the part of it to be exported as GreyMap)
yDomainMinlower y-interval boundary of function's domain (or rather the part of it to be exported as GreyMap)
yDomainMaxupper y-interval boundary of function's domain (or rather the part of it to be exported as GreyMap)
widththe horizontal resolution (absolute number of pixels) of the greymap to be created
heightthe vertical resolution (absolute number of pixels) of the greymap to be created
infosome information concerning the function; DEFAULT=""
maxGreyValthe value that shall correspond to white in the PGM (0 is black), has to satisfy 0 < maxGreyVal < 65536; determines the number of greyshades used for the greymap; DEFAULT = 255
colorschemethe employed PortableGreyMap::ColorScheme; DEFAULT = DEFAULT

◆ getCoeffs()

const CoeffType & PortableGreyMap::getCoeffs ( ) const
inline

◆ getGrid()

const GridType & PortableGreyMap::getGrid ( ) const
inline

◆ getHeight()

unsigned int PortableGreyMap::getHeight ( ) const
inline

◆ getImgHeight()

unsigned int PortableGreyMap::getImgHeight ( ) const
inline

◆ getImgWidth()

unsigned int PortableGreyMap::getImgWidth ( ) const
inline

◆ getWhiteValue()

unsigned int PortableGreyMap::getWhiteValue ( ) const
inline

◆ getWidth()

unsigned int PortableGreyMap::getWidth ( ) const
inline

◆ operator()()

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

◆ readGreyMap()

void PortableGreyMap::readGreyMap ( 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 greymap (PGM-ASCII)

Method creates a YaspGrid<2> (structured rectangular grid) with width times height nodes. The greyvalues 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 greymap section.

Parameters
filenamethe name of the PGM 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 greymap counted from upper left; DEFAULT=0
yoffsetthe y-position (in pixels) of the upper left corner of the importsection in the greymap counted from upper left; DEFAULT=0

Friends And Related Symbol Documentation

◆ localFunction

auto localFunction ( const PortableGreyMap pgm)
friend

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