Polygon.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*!
  2. * \file Polygon.cpp
  3. * \brief
  4. * \author Gapchich Vladislav
  5. * \date 23/10/11
  6. */
  7. #include "vislearning/cbaselib/Polygon.h"
  8. using namespace OBJREC;
  9. using namespace std;
  10. using namespace NICE;
  11. //! A constructor
  12. Polygon::Polygon()
  13. {
  14. points_.clear();
  15. id_ = -1;
  16. }
  17. // A copy-constructor
  18. Polygon::Polygon(const Polygon &copy)
  19. {
  20. points_ = PointsList(*(copy.points()));
  21. id_ = copy.id();
  22. }
  23. //! A desctructor
  24. Polygon::~Polygon()
  25. {
  26. }
  27. //! appends aPoint coordinate to the end of the point list
  28. void
  29. Polygon::push(const CoordT< int > &aPoint)
  30. {
  31. if (aPoint.x < 0 || aPoint.y < 0) {
  32. return;
  33. /* NOTREACHED */
  34. }
  35. points_.push_back(aPoint);
  36. }
  37. //! overloaded
  38. /*!
  39. * \see push(const CoordT< int > &aPoint)
  40. */
  41. void
  42. Polygon::push(const int &x, const int &y)
  43. {
  44. if (x < 0 || y < 0) {
  45. return;
  46. /* NOTREACHED */
  47. }
  48. CoordT< int > point;
  49. point.x = x;
  50. point.y = y;
  51. points_.push_back(point);
  52. }
  53. //! Sets a category ID(label ID) for the polygon
  54. /*!
  55. * /param[in] anID should not be less than zero
  56. */
  57. void
  58. Polygon::setID(const int &anID)
  59. {
  60. if (anID < 0) {
  61. return;
  62. /* NOTREACHED */
  63. }
  64. }
  65. //! returns a constant pointer to the list of polygon points(coordinates)
  66. const PointsList *
  67. Polygon::points() const
  68. {
  69. return &points_;
  70. }
  71. //! deletes last added point of the polygon and returns it
  72. CoordT< int >
  73. Polygon::pop()
  74. {
  75. CoordT< int > ret = points_.back();
  76. points_.pop_back();
  77. return ret;
  78. }
  79. //! returns a category ID of the polygon
  80. int
  81. Polygon::id() const
  82. {
  83. return id_;
  84. }
  85. /*
  86. *
  87. */