DP3
Public Types | Public Member Functions | List of all members
dp3::parmdb::Grid Class Reference

The envelope class for a 2-D grid with regular or irregular axes. -. More...

#include <Grid.h>

Public Types

using Location = std::pair< size_t, size_t >
 Define Location: A location on a 2-D grid. More...
 

Public Member Functions

 Grid ()
 Default constructor creates empty axes. More...
 
 Grid (Axis::ShPtr first, Axis::ShPtr second)
 Create a grid using the given axes. More...
 
 Grid (const std::vector< Box > &domains, bool sort=false)
 
 Grid (const std::vector< Grid > &grids, bool sort=false)
 
bool checkIntervals (const Grid &that) const
 Check if the corresponding intervals in this and that grid are the same. More...
 
Box getBoundingBox () const
 Get the bounding box of the grid. More...
 
Box getBoundingBox (const Location &start, const Location &end) const
 Get the bounding box of part of the grid. More...
 
Point getCellCenter (const Location &location) const
 Get the coordinates of the center of the given cell. More...
 
unsigned int getCellId (const Location &location) const
 Get the cell id from an (x,y) location. More...
 
Location getCellLocation (unsigned int id) const
 Get the (x,y) location from a cell id. More...
 
bool isDefault () const
 Is it the default grid? More...
 
Location locate (const Point &point, bool biasRight=true) const
 
std::pair< size_t, size_t > shape () const
 Get the grid shape (nx,ny). More...
 
size_t size () const
 Get the total number of cells. More...
 
void toDomains (std::vector< Box > &domains) const
 Convert the grid to domain boxes and append them to the vector. More...
 
const Axis::ShPtrgetAxis (size_t n) const
 
const Axis::ShPtroperator[] (size_t n) const
 
size_t nx () const
 
size_t ny () const
 
Box getCell (const Location &location) const
 
Box getCell (unsigned int id) const
 
Grid subset (const Box &) const
 
Grid subset (const Box &, Location &index) const
 
Grid subset (const Location &start, const Location &end) const
 
bool operator< (const Grid &that) const
 
bool operator> (const Grid &that) const
 

Detailed Description

The envelope class for a 2-D grid with regular or irregular axes. -.

Member Typedef Documentation

◆ Location

using dp3::parmdb::Grid::Location = std::pair<size_t, size_t>

Define Location: A location on a 2-D grid.

Constructor & Destructor Documentation

◆ Grid() [1/4]

dp3::parmdb::Grid::Grid ( )
inline

Default constructor creates empty axes.

◆ Grid() [2/4]

dp3::parmdb::Grid::Grid ( Axis::ShPtr  first,
Axis::ShPtr  second 
)
inline

Create a grid using the given axes.

◆ Grid() [3/4]

dp3::parmdb::Grid::Grid ( const std::vector< Grid > &  grids,
bool  sort = false 
)

Create a grid from a series of grids. They have to be in order of startY,startX. They are sorted if needed. The grids in the vector must span a rectangular grid, otherwise an exception is thrown. Its axes can be regular (RegularAxis) or irregular (OrderedAxis). The vector can be empty. In that case a default Grid is created.

◆ Grid() [4/4]

dp3::parmdb::Grid::Grid ( const std::vector< Box > &  domains,
bool  sort = false 
)
inline

Create a grid from a series of domains. They have to be in order of startY,startX. They are sorted if needed. The domains in the vector must span a rectangular grid, otherwise an exception is thrown. The vector can be empty. In that case a default Grid is created.

Member Function Documentation

◆ checkIntervals()

bool dp3::parmdb::Grid::checkIntervals ( const Grid that) const

Check if the corresponding intervals in this and that grid are the same.

◆ getAxis()

const Axis::ShPtr& dp3::parmdb::Grid::getAxis ( size_t  n) const
inline

Get the given axis.

◆ getBoundingBox() [1/2]

Box dp3::parmdb::Grid::getBoundingBox ( ) const
inline

Get the bounding box of the grid.

◆ getBoundingBox() [2/2]

Box dp3::parmdb::Grid::getBoundingBox ( const Location start,
const Location end 
) const
inline

Get the bounding box of part of the grid.

◆ getCell() [1/2]

Box dp3::parmdb::Grid::getCell ( const Location location) const
inline

Get the blc and trc coordinates of the given cell.

◆ getCell() [2/2]

Box dp3::parmdb::Grid::getCell ( unsigned int  id) const
inline

◆ getCellCenter()

Point dp3::parmdb::Grid::getCellCenter ( const Location location) const
inline

Get the coordinates of the center of the given cell.

◆ getCellId()

unsigned int dp3::parmdb::Grid::getCellId ( const Location location) const
inline

Get the cell id from an (x,y) location.

◆ getCellLocation()

Location dp3::parmdb::Grid::getCellLocation ( unsigned int  id) const
inline

Get the (x,y) location from a cell id.

◆ isDefault()

bool dp3::parmdb::Grid::isDefault ( ) const
inline

Is it the default grid?

◆ locate()

Location dp3::parmdb::Grid::locate ( const Point point,
bool  biasRight = true 
) const
inline

Give the (x,y) location of the cell containing the given point. If the point is on the edge, the left or right cell is chosen depending on the value of biasRight.

◆ nx()

size_t dp3::parmdb::Grid::nx ( ) const
inline

Get the sizes of the axes.

◆ ny()

size_t dp3::parmdb::Grid::ny ( ) const
inline

◆ operator<()

bool dp3::parmdb::Grid::operator< ( const Grid that) const
inline

Define an ordering functions to be able to sort grids. The ordering is on startY,startX.

◆ operator>()

bool dp3::parmdb::Grid::operator> ( const Grid that) const
inline

◆ operator[]()

const Axis::ShPtr& dp3::parmdb::Grid::operator[] ( size_t  n) const
inline

◆ shape()

std::pair<size_t, size_t> dp3::parmdb::Grid::shape ( ) const
inline

Get the grid shape (nx,ny).

◆ size()

size_t dp3::parmdb::Grid::size ( ) const
inline

Get the total number of cells.

◆ subset() [1/3]

Grid dp3::parmdb::Grid::subset ( const Box ) const

Apply the given domain to this grid. It means that the subset of this grid is returned which is covered by that domain. Optionally the location of the start point in this grid is filled.

◆ subset() [2/3]

Grid dp3::parmdb::Grid::subset ( const Box ,
Location index 
) const

◆ subset() [3/3]

Grid dp3::parmdb::Grid::subset ( const Location start,
const Location end 
) const

◆ toDomains()

void dp3::parmdb::Grid::toDomains ( std::vector< Box > &  domains) const

Convert the grid to domain boxes and append them to the vector.


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