Acceleration data structure used to compute distance to various banks and determine potential values at banks. More...
#include <HydroFlowTile.h>
Classes | |
struct | DistCell |
Contains distances to each bank and river axis at a given coordinate in this HydroFlowTile. More... | |
Public Types | |
enum | riverType { OBSTACLE = -1, RIVER = 0, INVISIBLE = 1, BANK = 2 } |
Predefined type for rivers. More... | |
Public Member Functions | |
HydroFlowTile (float ox, float oy, float size, float inter_power, int cacheSize, float searchRadiusFactor) | |
Creates a new HydroFlowTile. | |
virtual | ~HydroFlowTile () |
Deletes this HydroFlowTile. | |
void | addBanks (vector< ptr< HydroCurve > > &curves, float maxWidth) |
Adds a bank to this FlowTile. | |
virtual void | getVelocity (vec2d &pos, vec2d &velocity, int &type) |
Returns the velocity at a given point, depending on the data contained in this FlowTile. | |
bool | equals (unsigned int version, float inter_power, int cacheSize, float searchRadiusFactor) const |
Checks if a given tile has the corresponding parameters. | |
void | print () |
Debug print method. | |
Private Member Functions | |
bool | isInRiver (vec2d &pos, DistCell *distCell, int &riverId) |
Returns true if a given point is inside a river. | |
void | getLinkedEdges (vec2d &pos, DistCell *distCell, int riverId, set< int > &bankIds) |
Returns the list of banks linked to a given river axis around a given point. | |
void | getDistancesToBanks (vec2d &pos, DistCell *distCell, set< int > &bankIds, map< int, float > &distances) |
Returns the distances of a given point to the various curves. | |
void | getPotential (vec2d &pos, map< int, float > &distances, float &potential, int &type) |
Returns the potential value at a given point, depending on the distances to each banks. | |
void | getFourPotentials (vec2d &pos, vec4f &potentials, int &type) |
Returns the potential value at a given point. | |
Private Attributes | |
map< CurveId, int > | rivers |
Maps a CurveId to a River axis. | |
map< CurveId, vector< int > > | riversToBanks |
Maps a river axis to its associated banks. | |
vector< ptr< HydroCurve > > | banks |
The whole Curves list. | |
DistCell * | distCells |
Distance Table. | |
float * | DISTANCES |
Temporary array used to compute distances to a point at each frame. | |
int * | CLOSESTEDGESIDS |
Temporary array used to compute closest edges to a point at each frame. | |
float | maxWidth |
Largest River's width. | |
int | numDistCells |
Actual number of dist cells. | |
float | searchRadiusFactor |
Determines the radius of a DistCell coverage. | |
float | maxSearchDist |
See searchRadiusFactor. | |
float | inter_power |
Determines the slip conditions. | |
float * | potentials |
Cache storing every potentials already computed. | |
int | cacheSize |
Size of the potentials cache. | |
unsigned int | version |
Version of the Graph used to create this FlowTile. |
Acceleration data structure used to compute distance to various banks and determine potential values at banks.
Provides informations on banks, obstacles, etc... for a given Tile.
proland::HydroFlowTile::HydroFlowTile | ( | float | ox, | |
float | oy, | |||
float | size, | |||
float | inter_power, | |||
int | cacheSize, | |||
float | searchRadiusFactor | |||
) |
Creates a new HydroFlowTile.
ox | the x coordinate of the lower left corner of this Tile. | |
oy | the y coordinate of the lower left corner of this Tile. | |
size | width of this tile. | |
inter_power | determines the slip conditions. | |
cacheSize | size of the potentials cache. | |
searchRadiusFactor | determines the radius of a DistCell coverage. |
virtual proland::HydroFlowTile::~HydroFlowTile | ( | ) | [virtual] |
Deletes this HydroFlowTile.
void proland::HydroFlowTile::addBanks | ( | vector< ptr< HydroCurve > > & | curves, | |
float | maxWidth | |||
) |
Adds a bank to this FlowTile.
curves | a set of HydroCurves | |
maxWidth | width of the largest Curve. |
bool proland::HydroFlowTile::equals | ( | unsigned int | version, | |
float | inter_power, | |||
int | cacheSize, | |||
float | searchRadiusFactor | |||
) | const [inline] |
Checks if a given tile has the corresponding parameters.
Returns false if the tile has any of its fields different from those parameters. The tile will then have to be recomputed.
void proland::HydroFlowTile::getDistancesToBanks | ( | vec2d & | pos, | |
DistCell * | distCell, | |||
set< int > & | bankIds, | |||
map< int, float > & | distances | |||
) | [private] |
Returns the distances of a given point to the various curves.
Only distances to the rivers which id is provided in riverIds will be computed.
pos | coordinates of the point. | |
distCell | DistCell containing the point. | |
[out] | distances | distances to each borders. |
riverIds | the rivers containing pos. |
void proland::HydroFlowTile::getFourPotentials | ( | vec2d & | pos, | |
vec4f & | potentials, | |||
int & | type | |||
) | [private] |
Returns the potential value at a given point.
This computes 4 potentials, which will then be interpolated in getVelocity() to determine the speed at a given coordinate.
pos | coordinates of the point; | |
[out] | potentials | the 4 resulting potential values. |
type | type of data at point pos. |
void proland::HydroFlowTile::getLinkedEdges | ( | vec2d & | pos, | |
DistCell * | distCell, | |||
int | riverId, | |||
set< int > & | bankIds | |||
) | [private] |
Returns the list of banks linked to a given river axis around a given point.
This allows to retrieve quickly the banks that we need.
pos | coordinates of the point | |
distCell | DistCell contianing the point. | |
riverId | a river containing pos. | |
[out] | bankIds | the ids of the banks linked to the river. |
void proland::HydroFlowTile::getPotential | ( | vec2d & | pos, | |
map< int, float > & | distances, | |||
float & | potential, | |||
int & | type | |||
) | [private] |
Returns the potential value at a given point, depending on the distances to each banks.
pos | coordinates of the point. | |
distances | distances to each banks. | |
[out] | potential | resulting potential value. |
[out] | type | resulting type. If everything was fine, should be FlowTile::INSIDE. |
virtual void proland::HydroFlowTile::getVelocity | ( | vec2d & | pos, | |
vec2d & | velocity, | |||
int & | type | |||
) | [virtual] |
Returns the velocity at a given point, depending on the data contained in this FlowTile.
pos | a XY position inside the viewport of this FlowTile. | |
[out] | velocity | a vec2d containing the 2D velocity at given coordinates. |
[out] | type | type of data at given coordinates. See dataType |
bool proland::HydroFlowTile::isInRiver | ( | vec2d & | pos, | |
DistCell * | distCell, | |||
int & | riverId | |||
) | [private] |
Returns true if a given point is inside a river.
A point is considered inside a river if it's distance to at least 1 river axis is lower that this river's width.
pos | coordinates of the point. | |
distCell | DistCell containing the point. | |
[out] | riverId | a river containing pos, if any. |
void proland::HydroFlowTile::print | ( | ) |
Debug print method.
vector<ptr<HydroCurve> > proland::HydroFlowTile::banks [private] |
The whole Curves list.
int proland::HydroFlowTile::cacheSize [private] |
Size of the potentials cache.
int* proland::HydroFlowTile::CLOSESTEDGESIDS [private] |
Temporary array used to compute closest edges to a point at each frame.
Stored here for performance issues.
float* proland::HydroFlowTile::DISTANCES [private] |
Temporary array used to compute distances to a point at each frame.
Stored here for performance issues.
DistCell* proland::HydroFlowTile::distCells [private] |
Distance Table.
See DistCell.
float proland::HydroFlowTile::inter_power [private] |
Determines the slip conditions.
float proland::HydroFlowTile::maxSearchDist [private] |
See searchRadiusFactor.
float proland::HydroFlowTile::maxWidth [private] |
Largest River's width.
int proland::HydroFlowTile::numDistCells [private] |
Actual number of dist cells.
float* proland::HydroFlowTile::potentials [private] |
Cache storing every potentials already computed.
map<CurveId, int> proland::HydroFlowTile::rivers [private] |
Maps a CurveId to a River axis.
map<CurveId, vector<int> > proland::HydroFlowTile::riversToBanks [private] |
Maps a river axis to its associated banks.
Each bank is associated to 1 river, and each river should have at least 2 banks (one on each side). riversToBanks::iterator.second.size should always be at least 2.
float proland::HydroFlowTile::searchRadiusFactor [private] |
Determines the radius of a DistCell coverage.
unsigned int proland::HydroFlowTile::version [private] |
Version of the Graph used to create this FlowTile.
If the Graph changes, we need to update this FlowTile.