polygon_types.h
Go to the documentation of this file.
00001 
00059 #ifndef POLYGON_TYPES_H_
00060 #define POLYGON_TYPES_H_
00061 
00062 #include <vector>
00063 
00064 namespace cob_3d_segmentation
00065 {
00066   class PolygonPoint
00067   {
00068   public:
00069     PolygonPoint() : x(0), y(0) { }
00070     PolygonPoint(int ctor_x, int ctor_y) : x(ctor_x), y(ctor_y) { }
00071 
00072     virtual ~PolygonPoint() { };
00073 
00074     inline bool operator<(const PolygonPoint& rhs) const
00075     {
00076       if(y==rhs.y) { return x<rhs.x; }
00077       return y<rhs.y;
00078     }
00079 
00080     static int getInd(const int x, const int y) { return x + y * 640; }
00081 
00082   public:
00083     int x,y;
00084   };
00085 
00086 
00087   template <typename TPoint>
00088   class PolygonContours
00089   {
00090   public:
00091     virtual ~PolygonContours() { };
00092 
00093     void addPolygon() { polys_.push_back(std::vector<TPoint>()); }
00094     void removePolygon() { polys_.erase(polys_.end()-1); }
00095     void addPoint(int x, int y) { polys_.back().push_back(TPoint(x,y)); }
00096     /*void removeLastPoints(typename std::vector<TPoint>::size_type n)
00097     {
00098       if(polys_.back().size() > n) { polys_.back().resize(polys_.back().size() - n); }
00099       }*/
00100     void removeLastPoints(int n)
00101     {
00102       if(n && polys_.back().size() > n)
00103       {
00104         polys_.back().erase( polys_.back().begin()+(polys_.back().size()-n), polys_.back().end() );
00105       }
00106     }
00107 
00108   public:
00109     std::vector<std::vector<TPoint> > polys_;
00110   };
00111 }
00112 
00113 #endif


cob_3d_segmentation
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:03:03