NRLib::RegularSurface< A > Class Template Reference

#include <regularsurface.hpp>

Inheritance diagram for NRLib::RegularSurface< A >:
Inheritance graph

Public Types

typedef std::vector< A >::iterator iterator
 
typedef std::vector< A >::const_iterator const_iterator
 
typedef std::vector< A >::reference reference
 
typedef std::vector< A >::const_reference const_reference
 

Public Member Functions

 RegularSurface ()
 
 RegularSurface (double x0, double y0, double lx, double ly, size_t nx, size_t ny, const A &value=A())
 
 RegularSurface (double x0, double y0, double lx, double ly, Grid2D< A > grid)
 
 RegularSurface (const std::string &filename, SurfaceFileFormat format=SURF_UNKNOWN)
 Read surface file on given format. More...
 
Surface< A > * Clone () const
 Generate a copy of the underlying object. More...
 
GetZ (double x, double y) const
 
GetZInside (double x, double y) const
 
bool IsInsideSurface (double x, double y) const
 Checks if point is inside definition area for surface. More...
 
bool EnclosesRectangle (double x_min, double x_max, double y_min, double y_max) const
 
void Assign (A c)
 Sets all values on the surface to a constant value. More...
 
void Add (A c)
 
void Subtract (A c)
 
void Multiply (A c)
 
bool AddNonConform (const Surface< A > *s2)
 
bool SubtractNonConform (const Surface< A > *s2)
 
bool MultiplyNonConform (const Surface< A > *s2)
 
bool DivideNonConform (const Surface< A > *s2)
 
Min () const
 
MinNode (size_t &i, size_t &j) const
 
Max () const
 
MaxNode (size_t &i, size_t &j) const
 
Avg () const
 
Avg (int &n_nodes) const
 
void GetCorners (double x, double y, A corners[4]) const
 
bool CreateNeighbourAvg (size_t i, size_t j)
 
size_t FindI (double x) const
 
size_t FindJ (double y) const
 
void FindIndex (double x, double y, size_t &i, size_t &j) const
 
void FindContIndex (double x, double y, double &i, double &j) const
 
void FindGeneralIndex (double x, double y, int &i, int &j) const
 
void FindNearestNodeIndex (double x, double y, size_t &i, size_t &j) const
 
double GetX (size_t i) const
 
double GetY (size_t j) const
 
void GetXY (size_t i, size_t j, double &x, double &y) const
 
void GetXY (size_t index, double &x, double &y) const
 
void GetNode (size_t index, double &x, double &y, double &z) const
 
void GetNode (size_t i, size_t j, double &x, double &y, double &z) const
 
double GetXMin () const
 
double GetYMin () const
 
double GetXMax () const
 
double GetYMax () const
 
double GetDX () const
 
double GetDY () const
 
double GetLengthX () const
 
double GetLengthY () const
 
void SetDimensions (double x_min, double y_min, double lx, double ly)
 
void Resize (size_t ni, size_t nj, const A &val=A())
 Resize grid. Overrides Grid2D's resize. More...
 
bool IsMissing (A val) const
 Check if grid value is missing. More...
 
bool IsMissingAt (size_t i, size_t j) const
 Check if grid value is missing. More...
 
void SetMissing (size_t i, size_t j)
 Set missing. More...
 
GetMissingValue () const
 
void SetMissingValue (A missing_val)
 
const std::stringGetName () const
 
void SetName (const std::string &name)
 
void ReadFromFile (const std::string &filename, SurfaceFileFormat format=SURF_UNKNOWN)
 Read surface file on given format. More...
 
void WriteToFile (const std::string &filename, SurfaceFileFormat format=SURF_STORM_BINARY) const
 
void Swap (RegularSurface< A > &other)
 
reference operator() (size_t i, size_t j)
 
reference operator() (size_t index)
 
const_reference operator() (size_t i, size_t j) const
 
const_reference operator() (size_t index) const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
size_t GetNI () const
 
size_t GetNJ () const
 
size_t GetN () const
 
size_t GetIndex (size_t i, size_t j) const
 
void GetIJ (size_t index, size_t &i, size_t &j) const
 
bool IsValidIndex (int i, int j) const
 
void Swap (Grid2D< A > &other)
 
FindMin (A missingValue) const
 
FindMax (A missingValue) const
 

Detailed Description

template<class A>
class NRLib::RegularSurface< A >

Surface represented as a regular grid, where each of the grid cells are modelled as bilinear surfaces.

Member Typedef Documentation

◆ const_iterator

template<class A >
typedef std::vector<A>::const_iterator NRLib::Grid2D< A >::const_iterator
inherited

◆ const_reference

template<class A >
typedef std::vector<A>::const_reference NRLib::Grid2D< A >::const_reference
inherited

◆ iterator

template<class A >
typedef std::vector<A>::iterator NRLib::Grid2D< A >::iterator
inherited

◆ reference

template<class A >
typedef std::vector<A>::reference NRLib::Grid2D< A >::reference
inherited

Constructor & Destructor Documentation

◆ RegularSurface() [1/4]

template<class A >
NRLib::RegularSurface< A >::RegularSurface

◆ RegularSurface() [2/4]

template<class A >
NRLib::RegularSurface< A >::RegularSurface ( double  x0,
double  y0,
double  lx,
double  ly,
size_t  nx,
size_t  ny,
const A &  value = A() 
)

◆ RegularSurface() [3/4]

template<class A >
NRLib::RegularSurface< A >::RegularSurface ( double  x0,
double  y0,
double  lx,
double  ly,
Grid2D< A >  grid 
)

◆ RegularSurface() [4/4]

template<class A >
NRLib::RegularSurface< A >::RegularSurface ( const std::string filename,
SurfaceFileFormat  format = SURF_UNKNOWN 
)

Read surface file on given format.

Parameters
filenameFile name.
formatFile format. If SURF_UNKNOWN we try to determine the format.
Exceptions
IOErrorIf we failed to open the file
FileFormatErrorIf we can not determine the file format, or the contents of the file does not match the file format.

References format, and NRLib::RegularSurface< A >::ReadFromFile().

Member Function Documentation

◆ Add()

template<class A >
void NRLib::RegularSurface< A >::Add ( c)
inlinevirtual

◆ AddNonConform()

template<class A >
bool NRLib::RegularSurface< A >::AddNonConform ( const Surface< A > *  s2)

The following routines are for binary operations with non-conform grids. Missing areas will shrink. Also works for identical definitions without missing, but is inefficient.

References NRLib::Surface< A >::GetZ(), NRLib::Surface< A >::IsMissing(), exprtk::details::value(), and exprtk::details::x().

◆ Assign()

template<class A >
void NRLib::RegularSurface< A >::Assign ( c)
inline

Sets all values on the surface to a constant value.

References NRLib::Grid2D< A >::begin(), and NRLib::Grid2D< A >::end().

◆ Avg() [1/2]

template<class A >
A NRLib::RegularSurface< A >::Avg

◆ Avg() [2/2]

template<class A >
A NRLib::RegularSurface< A >::Avg ( int &  n_nodes) const

References Catch::begin, and count.

◆ begin() [1/2]

◆ begin() [2/2]

template<class A >
const_iterator NRLib::Grid2D< A >::begin ( ) const
inlineinherited

◆ Clone()

template<class A >
Surface< A > * NRLib::RegularSurface< A >::Clone ( ) const
inlinevirtual

Generate a copy of the underlying object.

Implements NRLib::Surface< A >.

◆ CreateNeighbourAvg()

template<class A >
bool NRLib::RegularSurface< A >::CreateNeighbourAvg ( size_t  i,
size_t  j 
)

Returns the arithmetic average of the up to 8 (non-missing)-values from neighbouring grid cells. If no neighborud cells have non-missing values, missing is returned.

◆ DivideNonConform()

template<class A >
bool NRLib::RegularSurface< A >::DivideNonConform ( const Surface< A > *  s2)

◆ EnclosesRectangle()

template<class A >
bool NRLib::RegularSurface< A >::EnclosesRectangle ( double  x_min,
double  x_max,
double  y_min,
double  y_max 
) const
virtual

Implements NRLib::Surface< A >.

◆ end() [1/2]

◆ end() [2/2]

template<class A >
const_iterator NRLib::Grid2D< A >::end ( ) const
inlineinherited

◆ FindContIndex()

template<class A >
void NRLib::RegularSurface< A >::FindContIndex ( double  x,
double  y,
double &  i,
double &  j 
) const

References exprtk::details::x().

◆ FindGeneralIndex()

template<class A >
void NRLib::RegularSurface< A >::FindGeneralIndex ( double  x,
double  y,
int &  i,
int &  j 
) const
inline

Gets the index for the nearest point up, and to the left of (x,y), the corner point with the lowest i and j values. May give values outside the grid. Fails if either ni or nj is greater than 2^31. The found index corresponds to the cell index.

References exprtk::details::x().

◆ FindI()

template<class A >
size_t NRLib::RegularSurface< A >::FindI ( double  x) const
inline

Gets the index to left of x. The found index corresponds to the cell index.

References exprtk::details::x().

◆ FindIndex()

template<class A >
void NRLib::RegularSurface< A >::FindIndex ( double  x,
double  y,
size_t &  i,
size_t &  j 
) const
inline

Gets the index for the nearest point up, and to the left of (x,y), the corner point with the lowest i and j values. The found index corresponds to the cell index.

References exprtk::details::x().

◆ FindJ()

template<class A >
size_t NRLib::RegularSurface< A >::FindJ ( double  y) const
inline

Gets the index to left of x. The found index corresponds to the cell index.

◆ FindMax()

template<class A >
A NRLib::Grid2D< A >::FindMax ( missingValue) const
inherited

References Catch::begin.

◆ FindMin()

template<class A >
A NRLib::Grid2D< A >::FindMin ( missingValue) const
inherited

References Catch::begin.

◆ FindNearestNodeIndex()

template<class A >
void NRLib::RegularSurface< A >::FindNearestNodeIndex ( double  x,
double  y,
size_t &  i,
size_t &  j 
) const
inline

Find nearest node. Similar to FindIndex, but finds index of nearest node instead of cell index.

References exprtk::details::x().

◆ GetCorners()

template<class A >
void NRLib::RegularSurface< A >::GetCorners ( double  x,
double  y,
corners[4] 
) const
inline

Returns vector with the four corners around the point (x,y). Fails if failOutside is false and either ni or nj is greater than 2^31.

Parameters
[out]cornersThe corners of the cell containing (x,y) or missing_val_ if the given corner is outside the grid, or does not have a valid value.

References exprtk::details::x().

◆ GetDX()

template<class A >
double NRLib::RegularSurface< A >::GetDX ( ) const
inline

◆ GetDY()

template<class A >
double NRLib::RegularSurface< A >::GetDY ( ) const
inline

◆ GetIJ()

template<class A >
void NRLib::Grid2D< A >::GetIJ ( size_t  index,
size_t &  i,
size_t &  j 
) const
inherited

References index.

Referenced by NRLib::RegularSurface< A >::GetNode().

◆ GetIndex()

template<class A >
size_t NRLib::Grid2D< A >::GetIndex ( size_t  i,
size_t  j 
) const
inlineinherited

◆ GetLengthX()

template<class A >
double NRLib::RegularSurface< A >::GetLengthX ( ) const
inline

◆ GetLengthY()

template<class A >
double NRLib::RegularSurface< A >::GetLengthY ( ) const
inline

◆ GetMissingValue()

template<class A >
A NRLib::RegularSurface< A >::GetMissingValue ( ) const
inline

◆ GetN()

◆ GetName()

template<class A >
const std::string & NRLib::RegularSurface< A >::GetName ( ) const
inline

◆ GetNI()

◆ GetNJ()

◆ GetNode() [1/2]

template<class A >
void NRLib::RegularSurface< A >::GetNode ( size_t  i,
size_t  j,
double &  x,
double &  y,
double &  z 
) const
inline

◆ GetNode() [2/2]

template<class A >
void NRLib::RegularSurface< A >::GetNode ( size_t  index,
double &  x,
double &  y,
double &  z 
) const
inline

◆ GetX()

template<class A >
double NRLib::RegularSurface< A >::GetX ( size_t  i) const
inline

◆ GetXMax()

template<class A >
double NRLib::RegularSurface< A >::GetXMax ( ) const
inlinevirtual

◆ GetXMin()

◆ GetXY() [1/2]

template<class A >
void NRLib::RegularSurface< A >::GetXY ( size_t  i,
size_t  j,
double &  x,
double &  y 
) const
inline

◆ GetXY() [2/2]

template<class A >
void NRLib::RegularSurface< A >::GetXY ( size_t  index,
double &  x,
double &  y 
) const
inline

◆ GetY()

template<class A >
double NRLib::RegularSurface< A >::GetY ( size_t  j) const
inline

◆ GetYMax()

template<class A >
double NRLib::RegularSurface< A >::GetYMax ( ) const
inlinevirtual

◆ GetYMin()

◆ GetZ()

template<class A >
A NRLib::RegularSurface< A >::GetZ ( double  x,
double  y 
) const
virtual

Return z. Returns missing if we are outside the grid. Returns also values when not all grid cell corners are present, e.g. when (x,y) is just outside the grid.

Implements NRLib::Surface< A >.

References exprtk::details::x().

◆ GetZInside()

template<class A >
A NRLib::RegularSurface< A >::GetZInside ( double  x,
double  y 
) const

Return z. Returns missing if not all grid cell corners are present, e.g. when (x,y) is just outside the grid.

References exprtk::details::x().

◆ IsInsideSurface()

template<class A >
bool NRLib::RegularSurface< A >::IsInsideSurface ( double  x,
double  y 
) const
virtual

Checks if point is inside definition area for surface.

Implements NRLib::Surface< A >.

References exprtk::details::x().

◆ IsMissing()

template<class A >
bool NRLib::RegularSurface< A >::IsMissing ( val) const
inlinevirtual

Check if grid value is missing.

Reimplemented from NRLib::Surface< A >.

Referenced by NRLib::WriteIrapClassicAsciiSurf().

◆ IsMissingAt()

template<class A >
bool NRLib::RegularSurface< A >::IsMissingAt ( size_t  i,
size_t  j 
) const
inline

Check if grid value is missing.

◆ IsValidIndex()

template<class A >
bool NRLib::Grid2D< A >::IsValidIndex ( int  i,
int  j 
) const
inherited

◆ Max()

template<class A >
A NRLib::RegularSurface< A >::Max
virtual

Implements NRLib::Surface< A >.

References Catch::begin.

◆ MaxNode()

template<class A >
A NRLib::RegularSurface< A >::MaxNode ( size_t &  i,
size_t &  j 
) const

References Catch::begin.

◆ Min()

template<class A >
A NRLib::RegularSurface< A >::Min
virtual

Implements NRLib::Surface< A >.

References Catch::begin.

◆ MinNode()

template<class A >
A NRLib::RegularSurface< A >::MinNode ( size_t &  i,
size_t &  j 
) const

References Catch::begin.

◆ Multiply()

template<class A >
void NRLib::RegularSurface< A >::Multiply ( c)
inlinevirtual

◆ MultiplyNonConform()

template<class A >
bool NRLib::RegularSurface< A >::MultiplyNonConform ( const Surface< A > *  s2)

◆ operator()() [1/4]

template<class A >
Grid2D< A >::reference NRLib::Grid2D< A >::operator() ( size_t  i,
size_t  j 
)
inlineinherited

◆ operator()() [2/4]

template<class A >
Grid2D< A >::const_reference NRLib::Grid2D< A >::operator() ( size_t  i,
size_t  j 
) const
inlineinherited

◆ operator()() [3/4]

template<class A >
Grid2D< A >::reference NRLib::Grid2D< A >::operator() ( size_t  index)
inlineinherited

References index.

◆ operator()() [4/4]

template<class A >
Grid2D< A >::const_reference NRLib::Grid2D< A >::operator() ( size_t  index) const
inlineinherited

References index.

◆ ReadFromFile()

template<class A >
void NRLib::RegularSurface< A >::ReadFromFile ( const std::string filename,
SurfaceFileFormat  format = SURF_UNKNOWN 
)

Read surface file on given format.

Parameters
filenameFile name.
formatFile format. If SURF_UNKNOWN we try to determine the format.
Exceptions
IOErrorIf we failed to open the file
FileFormatErrorIf we can not determine the file format, or the contents of the file does not match the file format.

References NRLib::FindSurfaceFileType(), format, NRLib::ReadIrapClassicAsciiSurf(), NRLib::ReadSgriSurf(), NRLib::ReadStormBinarySurf(), NRLib::SURF_IRAP_CLASSIC_ASCII, NRLib::SURF_SGRI, NRLib::SURF_STORM_BINARY, NRLib::SURF_UNKNOWN, and NRLib::ToString().

Referenced by NRLib::RegularSurface< A >::RegularSurface().

◆ Resize()

template<class A >
void NRLib::RegularSurface< A >::Resize ( size_t  ni,
size_t  nj,
const A &  val = A() 
)
virtual

◆ SetDimensions()

template<class A >
void NRLib::RegularSurface< A >::SetDimensions ( double  x_min,
double  y_min,
double  lx,
double  ly 
)

◆ SetMissing()

template<class A >
void NRLib::RegularSurface< A >::SetMissing ( size_t  i,
size_t  j 
)
inline

Set missing.

◆ SetMissingValue()

◆ SetName()

template<class A >
void NRLib::RegularSurface< A >::SetName ( const std::string name)
inline

◆ Subtract()

template<class A >
void NRLib::RegularSurface< A >::Subtract ( c)
inline

◆ SubtractNonConform()

template<class A >
bool NRLib::RegularSurface< A >::SubtractNonConform ( const Surface< A > *  s2)

◆ Swap() [1/2]

template<class A >
void NRLib::Grid2D< A >::Swap ( NRLib::Grid2D< A > &  other)
inherited

◆ Swap() [2/2]

template<class A >
void NRLib::RegularSurface< A >::Swap ( NRLib::RegularSurface< A > &  other)

◆ WriteToFile()


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