Contour.hpp

Go to the documentation of this file.
00001 #ifndef LOPER_CONTOUR
00002 #define LOPER_CONTOUR
00003 
00014 #include <Vector.hpp>
00015 #include <Matrix.hpp>
00016 
00017 
00018 
00019 class Contour
00020 {
00021 public:
00022 
00023     int size() const { return corners.size(); }
00024     void resize(int newSize) { corners.resize (newSize); }
00025     void push_back (const IntVec & v) { corners.push_back (v); }
00026     bool empty() { return corners.empty(); }
00027 
00028     IntVec & operator[](unsigned int index) 
00029     { 
00030         assert (index < corners.size());
00031         return corners[index]; 
00032     }
00033     IntVec & at (unsigned int index) 
00034     {
00035         assert (index < corners.size());
00036         return corners[index]; 
00037     }
00038 
00039     IntVec operator[] (unsigned int index)  const
00040     { 
00041         assert (index < corners.size());
00042         return corners[index]; 
00043     }
00044     IntVec at  (unsigned int index)  const
00045     {
00046         assert (index < corners.size());
00047         return corners[index]; 
00048     }
00049 
00050     IntVec getCentroid() const
00051     {
00052         IntVec result(2);
00053 
00054         int itemsToAverage = corners.size();
00055         for (int i = 0; i < itemsToAverage; i++)
00056             result += corners[i];
00057 
00058         result /= itemsToAverage;
00059 
00060         return result;
00061     }
00062 
00063     bool simplifyToQuadrangle();
00064 
00065     std::vector< IntVec > corners;
00066 };
00067 
00068 
00069 #endif // LOPER_CONTOUR

Generated on Mon May 26 11:19:28 2003 for CamChecker by doxygen1.3