proland::Area Class Reference
[graph]

An Area is described by 1 or more curves. More...

#include <Area.h>

Inheritance diagram for proland::Area:
proland::LazyArea

List of all members.

Public Member Functions

 Area (Graph *owner)
 Creates a new Area.
virtual ~Area ()
 Deletes this Area.
void print () const
 Displays the content of the area.
virtual AreaId getId () const
 Returns this area's Id.
virtual AreaPtr getParent () const
 Returns the parent Area of this area.
virtual AreaId getParentId () const
 Returns the parent Area's id.
AreaPtr getAncestor ()
 Returns this area's Ancestor Area (The furthest parent).
int getInfo () const
 Returns the info of this Area.
virtual int getCurveCount () const
 Returns the number of curves forming this area.
virtual CurvePtr getCurve (int i) const
 Returns a curve.
virtual CurvePtr getCurve (int i, int &orientation) const
 Returns a curve.
GraphPtr getSubgraph () const
 Returns the Graph contained in this area if any.
box2d getBounds () const
 Returns the bounding box of this area.
bool isInside (const vec2d &p) const
 Returns true if the given point is inside this area.
Curve::position getRectanglePosition (const box2d &r) const
 Returns the position of the given rectangle relatively to this area.
Curve::position getTrianglePosition (const vec2d *t) const
 Returns the position of the given triangle relatively to this area.
bool equals (set< CurveId > curveList)
 Checks if the given curve list corresponds to this area.
bool equals (Area *a, set< CurveId > &visitedCurves, set< NodeId > &visitedNodes)
 Checks if two areas are equals.
virtual void setOrientation (int i, int orientation)
 Sets orientation for a given curve.
void setInfo (int info)
 Sets info.
virtual void invertCurve (CurveId cid)
 Inverts a given curve in this area.
void check ()
 Checks if this area is well defined.
virtual void setParent (AreaPtr a)
 Sets the parent area.
virtual void addCurve (CurveId id, int orientation)
 Adds a curve to this area.
virtual void setSubgraph (Graph *g)
 Sets this area's subgraph.
bool isDirect () const
 Returns true if the area is oriented in clockwise order.

Static Public Member Functions

static bool clip (vector< CurvePart * > &cpaths, const box2d &clip, vector< CurvePart * > &result)
 Clips an area given as a list of curve parts.
static bool isDirect (const vector< Vertex > &points, int start, int end)
 Returns true if the given list of points are oriented in clockwise order.

Private Member Functions

virtual void setParentId (AreaId id)
 Sets the parent Id.
virtual void switchCurves (int curve1, int curve2)
 Switch 2 curves of this area.
virtual void removeCurve (int index)
 Removes a curve from the curves list.
void resetBounds () const
 Resets the the value of the variable bounds.
void build ()
 If necessary, reorders the curves to order them counter-clockwise, consistently with their orientations.
bool build (const CurvePtr p, NodePtr start, NodePtr cur, const set< CurveId > &excludedCurves, set< CurvePtr > &visited, set< CurvePtr > &visitedr)
 Tries to create a valid area from a starting curve.

Private Attributes

AreaId id
 This area's ID (NULL_ID if it's a Basic Area, and a non-null positive int if this is a Lazy Area).
Graphowner
 The graph containing this area.
AreaPtr parent
 The parent area.
int info
 Info about this area.
vector< pair< CurvePtr, int > > curves
 The list of the curves forming this area.
GraphPtr subgraph
 Area's subgraph.
box2d * bounds
 Bounds of the area : x and y limits (max and min for each).

Detailed Description

An Area is described by 1 or more curves.

It may contain a subgraph. This is used to describe pastures, lakes...

Author:
Antoine Begault, Guillaume Piolat

Constructor & Destructor Documentation

proland::Area::Area ( Graph owner  ) 

Creates a new Area.

Parameters:
owner the Graph that contains this area.
virtual proland::Area::~Area (  )  [virtual]

Deletes this Area.


Member Function Documentation

virtual void proland::Area::addCurve ( CurveId  id,
int  orientation 
) [virtual]

Adds a curve to this area.

Parameters:
id the added curve's Id.
orientation the orientation to add the curve.

Reimplemented in proland::LazyArea.

bool proland::Area::build ( const CurvePtr  p,
NodePtr  start,
NodePtr  cur,
const set< CurveId > &  excludedCurves,
set< CurvePtr > &  visited,
set< CurvePtr > &  visitedr 
) [private]

Tries to create a valid area from a starting curve.

a "valid area" is a list of curves that forms a loop, counter-clockwise ordered.

Parameters:
p starting curve.
start starting node in P.
cur a second node. Will determine the orientation of the search.
excludedCurves curves we don't want to be part of the area. Can also contains curves that cannot form any area.
visited the curves that were added to this area with their orientation = 0.
visitedr the curves that were added to this area with their orientation = 1.
Returns:
true if a valid area was found.
void proland::Area::build (  )  [private]

If necessary, reorders the curves to order them counter-clockwise, consistently with their orientations.

void proland::Area::check (  ) 

Checks if this area is well defined.

In other words, it checks if the curves are oriented correctly, and in a correct order, forming a loop.

static bool proland::Area::clip ( vector< CurvePart * > &  cpaths,
const box2d &  clip,
vector< CurvePart * > &  result 
) [static]

Clips an area given as a list of curve parts.

The given curve parts must form a closed loop oriented in counter clockwise order, and their orientations must be consistent with this order. The result is a new area also described with a list of curve parts (it can be empty).

Parameters:
cpaths the area to be clipped.
clip the clip region. This region must be an infinite horizontal or vertical slab.
result where the clipped area must be stored.
bool proland::Area::equals ( Area a,
set< CurveId > &  visitedCurves,
set< NodeId > &  visitedNodes 
)

Checks if two areas are equals.

Used for unit tests when comparing graphs.

Parameters:
a another area
visitedCurves curves that were already checked (+ those checked in this function).
visitedNodes nodes that were already checked (+ those checked in this function).
Returns:
true if EVERY field correspond (Except info, which is generated randomly at area creation).
bool proland::Area::equals ( set< CurveId curveList  ) 

Checks if the given curve list corresponds to this area.

Parameters:
curveList a set of curveIds.
Returns:
true if all curves of this area are in the list and vice-versa.
AreaPtr proland::Area::getAncestor (  ) 

Returns this area's Ancestor Area (The furthest parent).

This corresponds to the area in the root graph. See getParent().

box2d proland::Area::getBounds (  )  const

Returns the bounding box of this area.

This box does NOT take the curve widths into account.

virtual CurvePtr proland::Area::getCurve ( int  i,
int &  orientation 
) const [virtual]

Returns a curve.

Parameters:
i the rank of the curve to be returned.
orientation will contain the orientation of the i'th curve in this area.
Returns:
the i'th curve describing this area, or NULL if i is out of range.

Reimplemented in proland::LazyArea.

virtual CurvePtr proland::Area::getCurve ( int  i  )  const [virtual]

Returns a curve.

Parameters:
i the rank of the curve to be returned.
Returns:
the i'th curve describing this area, or NULL if i is out of range.

Reimplemented in proland::LazyArea.

virtual int proland::Area::getCurveCount (  )  const [virtual]

Returns the number of curves forming this area.

Reimplemented in proland::LazyArea.

virtual AreaId proland::Area::getId (  )  const [virtual]

Returns this area's Id.

For Area, an AreaId is a direct reference to the Area, (in opposition to LazyAreas, for which Ids are a unique integer).

Reimplemented in proland::LazyArea.

int proland::Area::getInfo (  )  const

Returns the info of this Area.

Info is a randomly generated number.

virtual AreaPtr proland::Area::getParent (  )  const [virtual]

Returns the parent Area of this area.

The parent area is the area from which this area was created by clipping, or NULL is this area was not created by clipping (e.g. inside the root graph tile in a GraphProducer).

Reimplemented in proland::LazyArea.

virtual AreaId proland::Area::getParentId (  )  const [virtual]

Returns the parent Area's id.

See getParent() and getId().

Curve::position proland::Area::getRectanglePosition ( const box2d &  r  )  const

Returns the position of the given rectangle relatively to this area.

Note that this computation is NOT based on the limit curves, but on the polylines based on the control points of the curves that form this area. The curve widths are not taken into account.

Parameters:
r a rectangle.
GraphPtr proland::Area::getSubgraph (  )  const

Returns the Graph contained in this area if any.

Null otherwise.

Curve::position proland::Area::getTrianglePosition ( const vec2d *  t  )  const

Returns the position of the given triangle relatively to this area.

Note that this computation is NOT based on the limit curves, but on the polylines based on the control points of the curves that form this area. The curve widths are not taken into account.

Parameters:
t points the 3 summits of the triangle.
virtual void proland::Area::invertCurve ( CurveId  cid  )  [virtual]

Inverts a given curve in this area.

Parameters:
cid the curveId of the curve to invert.

Reimplemented in proland::LazyArea.

static bool proland::Area::isDirect ( const vector< Vertex > &  points,
int  start,
int  end 
) [static]

Returns true if the given list of points are oriented in clockwise order.

Parameters:
points a vector of points.
start rank of the starting point.
end rank of the end point.
bool proland::Area::isDirect (  )  const

Returns true if the area is oriented in clockwise order.

bool proland::Area::isInside ( const vec2d &  p  )  const

Returns true if the given point is inside this area.

Note that this computation is NOT based on the limit curves, but on the polylines based on the control points of the curves that form this area.

Parameters:
p a point. The curve widths are not taken into account.
void proland::Area::print (  )  const

Displays the content of the area.

Debug only.

virtual void proland::Area::removeCurve ( int  index  )  [private, virtual]

Removes a curve from the curves list.

Parameters:
the index of the curve to remove.

Reimplemented in proland::LazyArea.

void proland::Area::resetBounds (  )  const [private]

Resets the the value of the variable bounds.

void proland::Area::setInfo ( int  info  ) 

Sets info.

Parameters:
info the new info.
virtual void proland::Area::setOrientation ( int  i,
int  orientation 
) [virtual]

Sets orientation for a given curve.

Parameters:
i rank of the curve to modify.
orientation the new orientation of the curve.

Reimplemented in proland::LazyArea.

virtual void proland::Area::setParent ( AreaPtr  a  )  [virtual]

Sets the parent area.

The parent area is the area from which this area was created by clipping, or NULL is this area was not created by clipping (e.g. inside the root graph tile in a GraphProducer).

Parameters:
a the new parent Area.
virtual void proland::Area::setParentId ( AreaId  id  )  [private, virtual]

Sets the parent Id.

Basic Area version : only sets parent to id.ref. See setParent().

Parameters:
id the new parent's Id.

Reimplemented in proland::LazyArea.

virtual void proland::Area::setSubgraph ( Graph g  )  [virtual]

Sets this area's subgraph.

Parameters:
g a Graph.
virtual void proland::Area::switchCurves ( int  curve1,
int  curve2 
) [private, virtual]

Switch 2 curves of this area.

Parameters:
id1 the first curve's id.
id2 the second curve's id.

Reimplemented in proland::LazyArea.


Member Data Documentation

box2d* proland::Area::bounds [mutable, private]

Bounds of the area : x and y limits (max and min for each).

This helps to determine if the area will be clipped by a box or not. Caution : this is only updated & used for clipping. It needs to be recomputed before using it. See getBounds().

vector<pair<CurvePtr, int> > proland::Area::curves [mutable, private]

The list of the curves forming this area.

This area's ID (NULL_ID if it's a Basic Area, and a non-null positive int if this is a Lazy Area).

This is stored here because it allows to check whether the area is a lazy area or not during the delete call.

int proland::Area::info [private]

Info about this area.

The graph containing this area.

AreaPtr proland::Area::parent [private]

The parent area.

The parent area is the area from which this area was created by clipping, or NULL is this area was not created by clipping (e.g. inside the root graph tile in a GraphProducer).

GraphPtr proland::Area::subgraph [private]

Area's subgraph.

A BasicGraph, containing it's own nodes, curves and areas, and possibly other subgraphs.


Generated on Sat May 12 09:42:46 2012 for proland by  doxygen 1.6.1