00001 #ifndef LOPER_CHESSSQUAREMESH
00002 #define LOPER_CHESSSQUAREMESH
00003
00014 #include "Contour.hpp"
00015 #include "ImageCalibrator.hpp"
00016 #include <set>
00017 using std::set;
00018
00019 class ChessCorner;
00020 class ChessSquare;
00021 class ChessSquareMesh;
00022
00025 class ChessCorner {
00026 public:
00027 ChessCorner()
00028 {
00029 link = NULL;
00030 pos.resize(2);
00031 }
00032 FloatVec pos;
00033 void *link;
00034 };
00035
00036
00037
00039 class ChessSquare
00040 {
00041 public:
00042 ChessSquare (Contour &c);
00043 bool isFullyConnected() const;
00044 float getSummedDistanceFromPoint(FloatVec point);
00045 PointCorrespondence getPointCorrespondence(int whichCorner, int orientation, int curX, int curY);
00046 FloatVec getCenter();
00047
00048 ChessCorner corners[4];
00049 };
00050
00051
00052
00054 class ChessSquareMesh
00055 {
00056 public:
00057 void addPotentialSquare (const Contour &c);
00058 std::vector< ChessSquare *> getConnectedSquares();
00059 bool hasFullyConnectedNeighbors(unsigned int index);
00060 int findClosestSquareIndex(const FloatVec & center);
00061 void connectPotentialSquares();
00062
00063 void surfNeighbors (int curX, int curY, int orientation, set< ChessSquare *> & squaresDone, std::vector< PointCorrespondence > & points, int indexToSurf);
00064 std::vector< ChessSquare > squares;
00065 private:
00066 void findClosest (int curSquare1, int curCorner1, int *curSquare2, int *curCorner2);
00067 };
00068
00069
00070
00071 #endif // LOPER_CHESSSQUAREMESH