Polygon.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * \file Polygon.cpp
  3. * \brief a polygon class
  4. * \author Gapchich Vladislav, Sven Sickert
  5. * \date 23/10/2011 (07/10/2015)
  6. */
  7. #ifndef __POLYGON_H__
  8. #define __POLYGON_H__
  9. #include "core/image/CoordT.h"
  10. #include <list>
  11. typedef std::list< NICE::CoordT< int > > PointsList;
  12. namespace OBJREC
  13. {
  14. //! \brief Contains category ID and point list of the polygon
  15. class Polygon
  16. {
  17. public:
  18. Polygon();
  19. Polygon ( const Polygon &copy );
  20. ~Polygon();
  21. void push ( const NICE::CoordT< int > &aPoint );
  22. void push ( const int &x, const int &y );
  23. void setID ( const int &anID );
  24. const PointsList * points() const;
  25. NICE::CoordT< int > pop();
  26. int id() const;
  27. // check whether point is inside polygon or not
  28. bool insidePolygon ( const NICE::CoordT< int > &aPoint );
  29. bool insidePolygon ( const int &px, const int &py );
  30. private:
  31. PointsList points_;
  32. /// id interpreted as a class label
  33. int id_;
  34. // helper function for point in polygon test
  35. bool handleEdge ( const int px, const int py,
  36. const int x1, const int y1,
  37. const int x2, const int y2,
  38. int & lastdir, int & c );
  39. public:
  40. /// unique id that distinguishs this particular bounding box object from all others
  41. int unique_id_;
  42. };
  43. } //namespace
  44. #endif /* __POLYGON_H__ */