zoneminder/src/zm_poly.h

82 lines
2.1 KiB
C
Raw Normal View History

//
// ZoneMinder Polygon Class Interfaces, $Date$, $Revision$
// Copyright (C) 2003, 2004, 2005 Philip Coombes
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef ZM_POLY_H
#define ZM_POLY_H
#include "zm.h"
#include "zm_coord.h"
#include "zm_box.h"
#include <math.h>
//
// Class used for storing a box, which is defined as a region
// defined by two coordinates
//
class Polygon
{
protected:
int n_coords;
Coord *coords;
Box extent;
int area;
Coord centre;
protected:
void calcArea();
void calcCentre();
public:
inline Polygon() : n_coords( 0 ), coords( 0 ), area( 0 )
{
}
Polygon( int p_n_coords, const Coord *p_coords );
Polygon( const Polygon &p_polygon );
~Polygon()
{
delete[] coords;
}
Polygon &operator=( const Polygon &p_polygon );
inline int getNumCoords() const { return( n_coords ); }
inline const Coord &getCoord( int index ) const
{
return( coords[index] );
}
inline const Box &Extent() const { return( extent ); }
inline int LoX() const { return( extent.LoX() ); }
inline int HiX() const { return( extent.HiX() ); }
inline int LoY() const { return( extent.LoY() ); }
inline int HiY() const { return( extent.HiY() ); }
inline int Width() const { return( extent.Width() ); }
inline int Height() const { return( extent.Height() ); }
inline int Area() const { return( area ); }
inline const Coord &Centre() const
{
return( centre );
}
bool isInside( const Coord &coord ) const;
};
#endif // ZM_POLY_H