Produces the required graphs at a given tile and at a given level. More...
#include <GraphProducer.h>
Classes | |
class | GraphCache |
Cache that manages the precomputed Graphs (including root Graph). More... | |
class | GraphFactory |
Creates Graph objects. More... | |
class | LazyGraphFactory |
A GraphFactory that creates LazyGraph. More... | |
Public Member Functions | |
GraphProducer (string name, ptr< TileCache > cache, ptr< GraphCache > precomputedGraphs, set< int > precomputedLevels, bool doFlatten=false, float flatnessFactor=0.5f, bool storeParents=false, int maxNodes=0) | |
Creates a new GraphProducer. | |
GraphProducer (string name, ptr< TileCache > cache, ptr< GraphCache > precomputedGraphs, bool doFlatten=false, float flatnessFactor=0.5f, bool storeParents=false, int maxNodes=0) | |
Creates a new GraphProducer. | |
virtual | ~GraphProducer () |
Deletes this GraphProducer. | |
GraphPtr | getRoot () |
Returns the level 0 Graph. | |
void | setTileSize (int tileSize) |
Sets tileSize value. | |
virtual void | addMargin (Margin *m) |
Adds a margin to this graphProducer. | |
virtual void | removeMargin (Margin *m) |
Removes a given margin. | |
virtual void | graphChanged () |
Invalidates the root tile and thus forces to recompute changed tiles (and only changed tiles). | |
ptr< GraphCache > | getPrecomputedGraphs () |
Returns the precomputed graphs cache. | |
int | getFirstPrecomputedLevel () |
Returns the first precomputed level after level 0. | |
CurvePtr | getFlattenCurve (CurvePtr c) |
Returns the flattened Curve corresponding to a given Curve. | |
void | putFlattenCurve (CurveId id) |
Releases a given FlattenCurve. | |
string | getName () |
Returns the name of this Resource. | |
Protected Member Functions | |
GraphProducer () | |
Creates a new GraphProducer. | |
void | init (string name, ptr< TileCache > cache, ptr< GraphCache > precomputedGraphs, set< int > precomputedLevels, bool doFlatten=false, float flatnessFactor=0.5f, bool storeParents=false, int maxNodes=0) |
Initializes the fields of a GraphProducer. | |
Private Member Functions | |
void | updateFlattenCurve (const set< CurveId > &changedCurves) |
Updates the cache of flatten curves and their associated CurveDatas. | |
Private Attributes | |
string | name |
The name of this resource. | |
int | tileSize |
Root Tile size. | |
set< int > | precomputedLevels |
Levels at which we can directly load the graphs from the disk. | |
int | maxNodes |
Maximum amount of nodes allowed in a Graph. | |
ComposedMargin * | margins |
List of margins associated to this GraphProducer (added from each layer associated to this GraphProducer). | |
bool | doFlatten |
If true, the producer will call flatten() on each produced subgraph after clipping. | |
float | flatnessFactor |
Factor for flatten() method (square of the maximum allowed distance between a limit curve and its polyline approximation). | |
bool | storeParents |
If true, will store parent tiles when creating a new one (call to useTile()) so it won't be deleted if temporarily not used. | |
ptr< GraphCache > | precomputedGraphs |
The cache that manages the precomputed Graphs (including root Graph). | |
map< CurveId, CurvePtr > | flattenCurves |
lists of every used flattened Curves, mapped to their Id. | |
map< CurvePtr, int > | flattenCurveCount |
Reference counts for each flattened Curve. |
Produces the required graphs at a given tile and at a given level.
Produced tiles will be used in layers (elevation, normals, ortho...) to display corresponding elements (edit, road, rivers...).
proland::GraphProducer::GraphProducer | ( | string | name, | |
ptr< TileCache > | cache, | |||
ptr< GraphCache > | precomputedGraphs, | |||
set< int > | precomputedLevels, | |||
bool | doFlatten = false , |
|||
float | flatnessFactor = 0.5f , |
|||
bool | storeParents = false , |
|||
int | maxNodes = 0 | |||
) |
Creates a new GraphProducer.
name | the name of this resource. | |
cache | the tile cache that stores the tiles produced by this producer. | |
precomputedGraphs | the precomputed graphs cache. Manages the precomputed Graphs (including root Graph). | |
precomputedLevels | levels at which we can directly load the graphs from the disk. For each tile of those levels, the corresponding graph must be precomputed and stored in a directory with the name of the graph. If not existing, it will be computed from the root tile and stored in cache. level 1 -> l-1 will be computed from the root tile if required afterwards. | |
doFlatten | if true, the producer will call Graph::flatten() on each produced subgraph after clipping. Default = false. | |
flatnessFactor | factor for flatten() method (square of the maximum allowed distance between a limit curve and its polyline approximation). Default = 0.5f. | |
storeParents | if true, we keep each tile in the memory cache instead of deleting them when temporarily not used. Default = false. | |
maxNodes | maximum amount of nodes allowed in a Graph. If under that number, the graph is considered small enough to not have to be clipped, and will be used for all its children. If set to 0, the Graph will be clipped as usual. |
proland::GraphProducer::GraphProducer | ( | string | name, | |
ptr< TileCache > | cache, | |||
ptr< GraphCache > | precomputedGraphs, | |||
bool | doFlatten = false , |
|||
float | flatnessFactor = 0.5f , |
|||
bool | storeParents = false , |
|||
int | maxNodes = 0 | |||
) |
Creates a new GraphProducer.
No precomputed levels.
name | the name of this resource. | |
cache | the tile cache that stores the tiles produced by this producer. | |
precomputedGraphs | the precomputed graphs cache. Manages the precomputed Graphs (including root Graph). | |
doFlatten | if true, the producer will call Graph::flatten() on each produced subgraph after clipping. Default = false. | |
flatnessFactor | factor for flatten() method (square of the maximum allowed distance between a limit curve and its polyline approximation). Default = 0.5f. | |
storeParents | if true, we keep each tile in the memory cache instead of deleting them when temporarily not used. Default = false. | |
maxNodes | maximum amount of nodes allowed in a Graph. If under that number, the graph is considered small enough to not have to be clipped, and will be used for all its children. If set to 0, the Graph will be clipped as usual. |
virtual proland::GraphProducer::~GraphProducer | ( | ) | [virtual] |
Deletes this GraphProducer.
proland::GraphProducer::GraphProducer | ( | ) | [protected] |
Creates a new GraphProducer.
virtual void proland::GraphProducer::addMargin | ( | Margin * | m | ) | [virtual] |
Adds a margin to this graphProducer.
Each layer may have a different margin, and only the largest will be used for the Graph::clip() method.
int proland::GraphProducer::getFirstPrecomputedLevel | ( | ) | [inline] |
Returns the first precomputed level after level 0.
Returns level 0 if no other precomputed levels are specified. First Level at which we can directly load the graphs from the disk. For each tile of those levels, the corresponding graph must be precomputed and stored in a directory with the name of the graph. If not existing, it will be computed from the root tile and stored in cache. level 1 -> l-1 will be computed from the root tile if required afterwards.
CurvePtr proland::GraphProducer::getFlattenCurve | ( | CurvePtr | c | ) |
string proland::GraphProducer::getName | ( | ) |
Returns the name of this Resource.
ptr<GraphCache> proland::GraphProducer::getPrecomputedGraphs | ( | ) | [inline] |
Returns the precomputed graphs cache.
GraphPtr proland::GraphProducer::getRoot | ( | ) |
Returns the level 0 Graph.
virtual void proland::GraphProducer::graphChanged | ( | ) | [virtual] |
Invalidates the root tile and thus forces to recompute changed tiles (and only changed tiles).
Implements proland::GraphListener.
void proland::GraphProducer::init | ( | string | name, | |
ptr< TileCache > | cache, | |||
ptr< GraphCache > | precomputedGraphs, | |||
set< int > | precomputedLevels, | |||
bool | doFlatten = false , |
|||
float | flatnessFactor = 0.5f , |
|||
bool | storeParents = false , |
|||
int | maxNodes = 0 | |||
) | [protected] |
Initializes the fields of a GraphProducer.
See GraphProducer.
void proland::GraphProducer::putFlattenCurve | ( | CurveId | id | ) |
Releases a given FlattenCurve.
id | the id of the corresponding Curve. |
virtual void proland::GraphProducer::removeMargin | ( | Margin * | m | ) | [virtual] |
Removes a given margin.
m | a margin. |
void proland::GraphProducer::setTileSize | ( | int | tileSize | ) |
Sets tileSize value.
tileSize | the new tileSize. |
void proland::GraphProducer::updateFlattenCurve | ( | const set< CurveId > & | changedCurves | ) | [private] |
Updates the cache of flatten curves and their associated CurveDatas.
When a Curve is changed, it's data will need to be recomputed. To simply do that, it is just removed from the cache and will be rebuilt when required.
changes | list of curves that changed during last update and for which the CurveData is outdated. |
bool proland::GraphProducer::doFlatten [private] |
If true, the producer will call flatten() on each produced subgraph after clipping.
float proland::GraphProducer::flatnessFactor [private] |
Factor for flatten() method (square of the maximum allowed distance between a limit curve and its polyline approximation).
map<CurvePtr, int> proland::GraphProducer::flattenCurveCount [private] |
Reference counts for each flattened Curve.
map<CurveId, CurvePtr> proland::GraphProducer::flattenCurves [private] |
lists of every used flattened Curves, mapped to their Id.
ComposedMargin* proland::GraphProducer::margins [private] |
List of margins associated to this GraphProducer (added from each layer associated to this GraphProducer).
int proland::GraphProducer::maxNodes [private] |
string proland::GraphProducer::name [private] |
The name of this resource.
ptr<GraphCache> proland::GraphProducer::precomputedGraphs [private] |
The cache that manages the precomputed Graphs (including root Graph).
set<int> proland::GraphProducer::precomputedLevels [private] |
Levels at which we can directly load the graphs from the disk.
For each tile in those levels, the corresponding graph must be precomputed and stored in a directory with the name of the graph. If not existing, it will be computed from the root tile and stored in cache. level 1 -> l-1 will be computed from the root tile if required afterwards.
bool proland::GraphProducer::storeParents [private] |
If true, will store parent tiles when creating a new one (call to useTile()) so it won't be deleted if temporarily not used.
int proland::GraphProducer::tileSize [private] |
Root Tile size.