Incomplete polygon mods.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1710 e3e1d417-86f3-4887-817a-d78f3d33393f
pull/27/merge
stan 2005-12-21 00:13:23 +00:00
parent cd5ae52788
commit b467ec84ce
2 changed files with 45 additions and 0 deletions

View File

@ -246,6 +246,7 @@ public:
void Annotate( const char *p_text, const Coord &coord, const Rgb colour );
void Annotate( const char *p_text, const Coord &coord );
Image *HighlightEdges( Rgb colour, const Box *limits=0 );
//Image *HighlightEdges( Rgb colour, const Polygon &polygon );
void Timestamp( const char *label, const time_t when, const Coord &coord );
void Colourise();
void DeColourise();

View File

@ -32,14 +32,58 @@
//
class Polygon
{
protected:
struct Edge
{
int min_y;
int max_y;
double min_x;
double _1_m;
static int CompareYX( const void *p1, const void *p2 )
{
const Edge *e1 = (const Edge *)p1, *e2 = (const Edge *)p2;
if ( e1->min_y == e2->min_y )
return( int(e1->min_x - e2->min_x) );
else
return( int(e1->min_y - e2->min_y) );
}
static int CompareX( const void *p1, const void *p2 )
{
const Edge *e1 = (const Edge *)p1, *e2 = (const Edge *)p2;
return( int(e1->min_x - e2->min_x) );
}
};
struct Slice
{
int min_x;
int max_x;
int n_edges;
int *edges;
Slice()
{
n_edges = 0;
edges = 0;
}
~Slice()
{
delete edges;
}
};
protected:
int n_coords;
Coord *coords;
Box extent;
int area;
Coord centre;
Edge *edges;
Slice *slices;
protected:
void initialiseEdges();
void calcArea();
void calcCentre();