#include <Grid.hpp>
Public Types | |
enum | neighborhood_t { FOUR, EIGHT, SIX } |
Public Member Functions | |
Grid (neighborhood_t neighborhood) | |
You have to call Init() before actually using the Grid instance, otherwise you'll get segfaults. | |
Grid (ssize_t xbegin, ssize_t xend, ssize_t ybegin, ssize_t yend, neighborhood_t neighborhood, double meta) | |
Also calls Init(), see the comments there. | |
void | Init (ssize_t xbegin, ssize_t xend, ssize_t ybegin, ssize_t yend, double meta) |
Allocate memory for the grid and initialize it (set its meta, connect to neighbors). | |
size_t | AddRange (ssize_t xbegin, ssize_t xend, ssize_t ybegin, ssize_t yend, double meta, Algorithm &algo, Kernel const &kernel) |
Makes sure that the required range of indices is available, where (xend, yend) is the ONE-PAST-end marker for the X- and Y- directions. | |
bool | AddNode (ssize_t ix, ssize_t iy, double meta, Algorithm &algo, Kernel const &kernel) |
If (ix, iy) is already in the grid, simply call Algorithm::SetMeta(). | |
ssize_t | GetXBegin () const |
ssize_t | GetXEnd () const |
ssize_t | GetYBegin () const |
ssize_t | GetYEnd () const |
boost::shared_ptr< GridNode const > | GetNode (ssize_t ix, ssize_t iy) const |
A direct but slightly unsafe way of accessing a GridNode. | |
boost::shared_ptr< GridCSpace const > | GetCSpace () const |
boost::shared_ptr< GridCSpace > | GetCSpace () |
int | ComputeGradient (ssize_t ix, ssize_t iy, double &gradx, double &grady) const |
| |
bool | ComputeGradient (boost::shared_ptr< GridNode const > node, double &gradx, double &grady) const |
| |
int | ComputeStableScaledGradient (ssize_t ix, ssize_t iy, double stepsize, double &gx, double &gy, double &dx, double &dy) const |
| |
int | ComputeStableScaledGradient (boost::shared_ptr< GridNode const > node, double stepsize, double &gx, double &gy, double &dx, double &dy) const |
| |
neighborhood_t | GetNeighborhood () const |
Private Types | |
typedef GridCSpace::vertex_data_t | vertex_data_t |
typedef flexgrid< vertex_data_t > | flexgrid_t |
typedef std::vector< offset > | nbor_offset_t |
Private Member Functions | |
vertex_data_t | DoAddNode (ssize_t ix, ssize_t iy, double meta) |
Blindly allocate a new node and add it to the flexgrid, hooking it up with its neighbors and initializing its meta. | |
void | InitNborStuff () |
Private Attributes | |
neighborhood_t const | m_neighborhood |
nbor_offset_t | m_nbor_offset |
boost::shared_ptr< flexgrid_t > | m_flexgrid |
boost::shared_ptr< GridCSpace > | m_cspace |
Classes | |
struct | offset |
typedef GridCSpace::vertex_data_t estar::Grid::vertex_data_t [private] |
typedef flexgrid<vertex_data_t> estar::Grid::flexgrid_t [private] |
typedef std::vector<offset> estar::Grid::nbor_offset_t [private] |
estar::Grid::Grid | ( | neighborhood_t | neighborhood | ) | [explicit] |
estar::Grid::Grid | ( | ssize_t | xbegin, | |
ssize_t | xend, | |||
ssize_t | ybegin, | |||
ssize_t | yend, | |||
neighborhood_t | neighborhood, | |||
double | meta | |||
) |
Also calls Init(), see the comments there.
Allocate memory for the grid and initialize it (set its meta, connect to neighbors).
This is not intended for ranges that do not include 0, so all bets are off if you use it that way.
size_t estar::Grid::AddRange | ( | ssize_t | xbegin, | |
ssize_t | xend, | |||
ssize_t | ybegin, | |||
ssize_t | yend, | |||
double | meta, | |||
Algorithm & | algo, | |||
Kernel const & | kernel | |||
) |
Makes sure that the required range of indices is available, where (xend, yend) is the ONE-PAST-end marker for the X- and Y- directions.
That is to say, after this call there is guaranteed to be a GridNode at [xend-1, yend-1] but not beyond that.
All newly created GridNode instances are initialized by calling AddNode(). The method does not modify any prior existing nodes in the given range of indices, except for adding neighborhood edges where appropriate.
bool estar::Grid::AddNode | ( | ssize_t | ix, | |
ssize_t | iy, | |||
double | meta, | |||
Algorithm & | algo, | |||
Kernel const & | kernel | |||
) |
If (ix, iy) is already in the grid, simply call Algorithm::SetMeta().
Otherwise, add a new GridNode instance, hook it up via edges to its neighbors, initialize its meta, and call Algorithm::AddVertex().
ssize_t estar::Grid::GetXBegin | ( | ) | const |
ssize_t estar::Grid::GetXEnd | ( | ) | const |
ssize_t estar::Grid::GetYBegin | ( | ) | const |
ssize_t estar::Grid::GetYEnd | ( | ) | const |
A direct but slightly unsafe way of accessing a GridNode.
If you want to iterate over all nodes, you should call GetCSpace() and use BaseCSpace::begin() which is much more decoupled from the grid implementation.
boost::shared_ptr<GridCSpace const> estar::Grid::GetCSpace | ( | ) | const [inline] |
boost::shared_ptr<GridCSpace> estar::Grid::GetCSpace | ( | ) | [inline] |
0: success. 1: (partially) incomplete information.
bool estar::Grid::ComputeGradient | ( | boost::shared_ptr< GridNode const > | node, | |
double & | gradx, | |||
double & | grady | |||
) | const |
int estar::Grid::ComputeStableScaledGradient | ( | ssize_t | ix, | |
ssize_t | iy, | |||
double | stepsize, | |||
double & | gx, | |||
double & | gy, | |||
double & | dx, | |||
double & | dy | |||
) | const |
0: success. 1: (partially) incomplete information. 2: gradient was too small, replaced with heuristic.
stepsize | wanted length of (dx, dy) |
gx | only valid if return 0 |
gy | only valid if return 0 |
dx | always valid |
dy | always valid |
int estar::Grid::ComputeStableScaledGradient | ( | boost::shared_ptr< GridNode const > | node, | |
double | stepsize, | |||
double & | gx, | |||
double & | gy, | |||
double & | dx, | |||
double & | dy | |||
) | const |
1: (partially) incomplete information. 2: gradient was too small, replaced with heuristic.
neighborhood_t estar::Grid::GetNeighborhood | ( | ) | const [inline] |
Grid::vertex_data_t estar::Grid::DoAddNode | ( | ssize_t | ix, | |
ssize_t | iy, | |||
double | meta | |||
) | [private] |
Blindly allocate a new node and add it to the flexgrid, hooking it up with its neighbors and initializing its meta.
void estar::Grid::InitNborStuff | ( | ) | [private] |
neighborhood_t const estar::Grid::m_neighborhood [private] |
nbor_offset_t estar::Grid::m_nbor_offset [private] |
boost::shared_ptr<flexgrid_t> estar::Grid::m_flexgrid [private] |
boost::shared_ptr<GridCSpace> estar::Grid::m_cspace [private] |