Grid. More...
#include <rgrid.h>
Public Member Functions | |
RGrid (const RSize &limits) | |
void | Clear (void) |
void | Assign (RRect &rect, RPoint &pos, size_t id) |
bool | IsFree (tCoord x, tCoord y) const |
bool | IsOcc (tCoord x, tCoord y) const |
bool | IsOcc (const RRect &rect) const |
size_t | GetMaxX (void) const |
size_t | GetMaxY (void) const |
size_t | GetObjId (tCoord x, tCoord y) const |
tCoord | LookLeft (const RPoint &pt) const |
tCoord | LookRight (const RPoint &pt) const |
tCoord | LookUp (const RPoint &pt) const |
tCoord | LookDown (const RPoint &pt) const |
tCoord | SkirtLeft (const RPoint &pt, const RRect &bound) const |
tCoord | SkirtRight (const RPoint &pt, const RRect &bound) const |
tCoord | SkirtUp (const RPoint &pt, const RRect &bound) const |
tCoord | SkirtDown (const RPoint &pt, const RRect &bound) const |
bool | CalculateFreePolygon (tCoord X, tCoord Y, tDirection from, const RRect &bound, RPolygon &poly) const |
void | AddFreePolygons (RGeoInfo *ins, RFreePolygons *free, const RRect &bound) |
~RGrid (void) | |
Private Attributes | |
RSize | Limits |
RSize | InternalLimits |
size_t ** | OccupiedX |
size_t ** | OccupiedY |
Detailed Description
Grid.
The RGrid class provides some functions to manipulate a grid of geometric points.
Constructor & Destructor Documentation
Construct the grid.
- Parameters
-
limits Representing the maximal limits for the grid. In fact, internally, the grid is allocate 2x the size to be used by the "center" heuristic.
~RGrid | ( | void | ) |
Destruct the Grid.
Member Function Documentation
void Clear | ( | void | ) |
Clear the Grid.
Assign a rectangle to the grid.
- Parameters
-
rect The rectangle to assign. pos The position. id The identifier to put.
This function returns true if the position (x,y) is free or if it is out of the limits.
- Parameters
-
x X position. y Y position.
- Returns
- The function return true if the point is out of the limits or if the position is free.
This function returns true if the position (x,y) is occupied.
- Parameters
-
x X position. y Y position.
- Returns
- The function returns true if the position is occupied, false else (also if the point is out of the limits).
bool IsOcc | ( | const RRect & | rect | ) | const |
This function returns true if at least one position corresponding to a given rectangle is occupied.
- Parameters
-
rect Rectangle.
- Returns
- The function returns true if the position is occupied, false else (also if the point is out of the limits).
size_t GetMaxX | ( | void | ) | const |
Get the maximal X size allocated.
- Returns
- size_t
size_t GetMaxY | ( | void | ) | const |
Get the maximal Y size allocated.
- Returns
- size_t
This function returns the identifier of the object placed at position (x,y) or cNoRef if no object is placed there.
- Parameters
-
x X position. y Y position.
Find the left most x coordinates that is free of a reference.
- Parameters
-
pt Point used as reference.
Find the right most x coordinates that is free of a reference.
- Parameters
-
pt Point used as reference.
Find the up most x coordinates that is free of a reference.
- Parameters
-
pt Point used as reference.
Find the down most x coordinates that is free of a reference.
- Parameters
-
pt Point used as reference.
Find the left most x coordinates that is free and that skirt an edge.
- Parameters
-
pt Point used as reference. bound The rectangle which limits the research.
Find the right most x coordinates that is free and that skirt an edge.
- Parameters
-
pt Point used as reference. bound The rectangle which limits the research.
Find the up most x coordinates that is free and that skirt an edge.
- Parameters
-
pt Point used as reference. bound The rectangle which limits the research.
Find the down most x coordinates that is free and that skirt an edge.
- Parameters
-
pt Point used as reference. bound The rectangle which limits the research.
bool CalculateFreePolygon | ( | tCoord | X, |
tCoord | Y, | ||
tDirection | from, | ||
const RRect & | bound, | ||
RPolygon & | poly | ||
) | const |
Calculate a free polygon from a given position and a given direction.
- Parameters
-
X X-Coordinate of the position. Y Y-Coordinate of the position. from The direction from where "it" is coming. bound The bound rectangle. poly The polygon to calculated (modified.
- Returns
- The function returns true if a close polygon has been calculated or false if not.
void AddFreePolygons | ( | RGeoInfo * | ins, |
RFreePolygons * | free, | ||
const RRect & | bound | ||
) |
Add all the polygons representing free spaces that are closed and resulting of the placement of an object.
- Parameters
-
ins The geometric information representing the last inserted object. free The container of polygons where all the free spaces calculated must be add. bound The bounding rectangle of the objects already placed.
Member Data Documentation
|
private |
Limits for the construction.
|
private |
Internal Limits.
|
private |
Grid with X as entry.
|
private |
Grid with Y as entry.