rasdaman complete source
|
#include <polygon.hh>
Public Types | |
enum | r_Polygon_Type { UNKNOWN, CONCAVE, CONVEX } |
enum used to clasify one polygon More... | |
Public Member Functions | |
r_Polygon (const char *init) throw (r_Error) | |
constructor to initialize polygon from a string More... | |
r_Polygon (r_Range x, r_Range y) | |
constructor getting x and y of the first point in the polygon. More... | |
r_Polygon (const r_Polygon &) | |
copy constructor More... | |
r_Polygon () | |
default constructor. More... | |
r_Polygon & | operator= (const r_Polygon &) |
asignment opertor More... | |
void | addPoint (const r_Point &newPoint) throw (r_Error) |
add a point to the polygon. More... | |
void | addPointXY (r_Range x, r_Range y) throw (r_Error) |
add a point to the polygon specifying x and y. More... | |
void | close () |
close a polygon after creation with addPointXY. More... | |
const std::vector< r_Edge > & | getEdges () const throw (r_Error) |
retrieve the set of all edges of the polygon. More... | |
r_Polygon::r_Polygon_Type | detectPolygonType () const throw (r_Error) |
determine the polygon type for an polygon in 2D More... | |
std::vector< r_Point > | getPoints () const throw (r_Error) |
retrieve a vector of all points in the polygon. More... | |
void | print_status (std::ostream &s=std::cout) const |
print all edges of the polygon. More... | |
void | fillMArray (r_GMarray &myArray, bool fillInside=false, const std::string &bgr="") const throw (r_Error) |
Fill the 2-D array myArray according to the polygon. More... | |
r_Minterval | getBoundingBox () const throw (r_Error) |
retrieve the bounding box of the polygon. More... | |
void | clip (const r_Minterval &clipDom) throw (r_Error) |
clip the polygon according to the bounding box specified in clipDom. More... | |
void | scale (const r_Point &origin, const r_Minterval &mddDom, const r_Minterval &clipDom, const double &scaleFactor) throw (r_Error) |
scale the points of the polygon according to scaleFactor. More... | |
void | scale (const r_Point &origin, const double &scaleFactor) throw (r_Error) |
scale the points of the polygon according to scaleFactor. More... | |
void | mirror (const r_Minterval &mddDom) throw (r_Error) |
mirrors a polygon along the y-axes point by point. More... | |
r_Point | getMiddle () const throw (r_Error) |
get "middle" point by averaging all x and y values. More... | |
void | shrinkPoly (int pixelCount) throw (r_Error) |
"shrink" polygon by moving all points towards the middle by pixelCount pixels. More... | |
int | countEdges () const |
returns the number of edges More... | |
int | countHorizontalEdges () const |
returns the number of horizontal edges (used by polygon cut out) More... | |
Static Public Attributes | |
static const r_Dimension | polyPointDim |
FIXME current we support only 2 dimensional polygon. More... | |
r_Polygon::r_Polygon | ( | const char * | init | ) | |
throw | ( | r_Error | |||
) |
constructor to initialize polygon from a string
constructor getting x and y of the first point in the polygon.
r_Polygon::r_Polygon | ( | const r_Polygon & | ) |
copy constructor
r_Polygon::r_Polygon | ( | ) |
default constructor.
add a point to the polygon specifying x and y.
void r_Polygon::clip | ( | const r_Minterval & | clipDom | ) | |
throw | ( | r_Error | |||
) |
clip the polygon according to the bounding box specified in clipDom.
void r_Polygon::close | ( | ) |
close a polygon after creation with addPointXY.
int r_Polygon::countEdges | ( | ) | const |
returns the number of edges
int r_Polygon::countHorizontalEdges | ( | ) | const |
returns the number of horizontal edges (used by polygon cut out)
r_Polygon::r_Polygon_Type r_Polygon::detectPolygonType | ( | ) | const | |
throw | ( | r_Error | ||
) |
determine the polygon type for an polygon in 2D
void r_Polygon::fillMArray | ( | r_GMarray & | myArray, |
bool | fillInside = false , |
||
const std::string & | bgr = "" |
||
) | const | ||
throw | ( | r_Error | |
) |
Fill the 2-D array myArray according to the polygon.
r_Minterval r_Polygon::getBoundingBox | ( | ) | const | |
throw | ( | r_Error | ||
) |
retrieve the bounding box of the polygon.
The polygon has to be completely in the domain of the array. Should this not be the case, then the polygon must be clipped according to the domain of the array. Filling is done so that the data in the array is overwritten byte by byte with 0 which is not inside the polygon.
retrieve the set of all edges of the polygon.
get "middle" point by averaging all x and y values.
The mirroring is done along the middle of mddDom. It is done like that to be coherent with the mirroring commonly done when inserting TIFF image, e.g. in insertlva.cc.
retrieve a vector of all points in the polygon.
It is assumed that the polygon is simple (does not intersect itself or have holes) Returns UNKNOWN for incomputables eg: polygon with colinear points, polygon with less then 3 points
void r_Polygon::mirror | ( | const r_Minterval & | mddDom | ) | |
throw | ( | r_Error | |||
) |
mirrors a polygon along the y-axes point by point.
This function is used used when we scale a polygon to extract part of an image retrieved with r_Fast_Scale. The scaling is done like in r_Fast_Base_Scale::get_scaled_domain(). origin is the point of origin for the scaling. scaleFactor is the scale factor used.
void r_Polygon::print_status | ( | std::ostream & | s = std::cout | ) | const |
print all edges of the polygon.
Each point is connected with its successor. The last point is connected to the first one.
void r_Polygon::scale | ( | const r_Point & | origin, |
const r_Minterval & | mddDom, | ||
const r_Minterval & | clipDom, | ||
const double & | scaleFactor | ||
) | |||
throw | ( | r_Error | |
) |
scale the points of the polygon according to scaleFactor.
Note that the r_Polygon object is modified! So after calling clip you will generally have a different polygon represented by your object.
scale the points of the polygon according to scaleFactor.
This function is used when using a polygon to extract part of an image retrieved with r_Fast_Scale. The scaling is done like in r_Fast_Base_Scale::get_scaled_domain(). origin is the point of origin for the scaling. mddDom is the domain of the MDD which will later be filled with the polygon. Problem is, that the domain of this MDD is currently not created by simply scaling the domain of the original MDD. Instead it is made sure that the origin of the scaled domain stays the same. clipDom is used to do the same when scaling the polygon, it contains the scaled domain of the MDD without shifting it to origin of the domain of the MDD before scaling. It is a bit complicated, I know. scaleFactor is trivially the scaleFactor used.
void r_Polygon::shrinkPoly | ( | int | pixelCount | ) | |
throw | ( | r_Error | |||
) |
"shrink" polygon by moving all points towards the middle by pixelCount pixels.
|
static |
FIXME current we support only 2 dimensional polygon.