00001
00002 #ifndef INCLUDED_SketchSpace_h
00003 #define INCLUDED_SketchSpace_h
00004
00005 #include "Shared/newmat/newmat.h"
00006
00007 #include "Macrodefs.h"
00008 #include "SketchTypes.h"
00009 #include "ShapeTypes.h"
00010 #include "SketchPool.h"
00011 #include "SketchIndices.h"
00012
00013 namespace DualCoding {
00014
00015 class BoundingBox;
00016 class ShapeSpace;
00017 template<typename T> class Sketch;
00018 class ViewerConnection;
00019
00020
00021
00022
00023
00024
00025
00026
00027 class SketchSpace {
00028 public:
00029 std::string name;
00030
00031 private:
00032 size_t width;
00033 size_t height;
00034 size_t numPixels;
00035 NEWMAT::Matrix Tmat;
00036 NEWMAT::Matrix Tmatinv;
00037
00038 int idCounter;
00039 int refreshCounter;
00040
00041 ShapeSpace* dualSpace;
00042
00043
00044
00045 SketchPool<bool> boolPool;
00046 SketchPool<uchar> ucharPool;
00047 SketchPool<uint> uintPool;
00048 SketchPool<float> floatPool;
00049
00050
00051 public:
00052
00053 int dummy;
00054
00055
00056
00057 Sketch<uint> *idx;
00058 Sketch<uint> *idxN;
00059 Sketch<uint> *idxS;
00060 Sketch<uint> *idxE;
00061 Sketch<uint> *idxW;
00062 Sketch<uint> *idxNE;
00063 Sketch<uint> *idxNW;
00064 Sketch<uint> *idxSE;
00065 Sketch<uint> *idxSW;
00066
00067
00068 SketchSpace(std::string const _name, ReferenceFrameType_t _refFrameType,
00069 int const init_id, size_t const _width, size_t const _height);
00070
00071 ~SketchSpace();
00072
00073 ShapeSpace& getDualSpace() const { return *dualSpace; }
00074
00075
00076 void dumpSpace() const;
00077
00078
00079 void clear();
00080
00081
00082 size_t getWidth() const { return width; }
00083
00084 size_t getHeight() const { return height; }
00085
00086 size_t getNumPixels() const { return numPixels; }
00087
00088 int getRefreshCounter() const { return refreshCounter; }
00089 void bumpRefreshCounter() { ++refreshCounter; }
00090
00091
00092 void requireIdx();
00093
00094
00095 void requireIdx4way();
00096
00097
00098 void requireIdx8way();
00099
00100
00101 void freeIndexes();
00102
00103
00104 void resize(const size_t new_width, const size_t new_height);
00105
00106
00107 NEWMAT::Matrix& getTmat() { return Tmat; }
00108
00109
00110 NEWMAT::Matrix& getTmatinv() { return Tmatinv; }
00111
00112
00113 void setTmat(const NEWMAT::Matrix &mat);
00114
00115 void setTmat(float scale=1, float tx=0, float ty=0);
00116
00117 void setTmat(const BoundingBox &b);
00118
00119
00120 void applyTmat(NEWMAT::ColumnVector &vec);
00121
00122
00123 void applyTmatinv(NEWMAT::ColumnVector &vec);
00124
00125
00126
00127 SketchPool<bool>& get_pool(const Sketch<bool>&) { return boolPool; }
00128 SketchPool<uchar>& get_pool(const Sketch<uchar>&) { return ucharPool; }
00129 SketchPool<uint>& get_pool(const Sketch<uint>&) { return uintPool; }
00130 SketchPool<float>& get_pool(const Sketch<float>&) { return floatPool; }
00131
00132
00133
00134
00135
00136
00137
00138 ViewerConnection *viewer;
00139
00140
00141 std::string getTmatForGUI();
00142
00143
00144 std::string getSketchListForGUI();
00145
00146
00147 SketchDataRoot* retrieveSketch(int const id);
00148
00149
00150 protected:
00151
00152 void setIdx(Sketch<uint>& indices, int const x, int const y, int const indexval);
00153
00154
00155 SketchSpace(const SketchSpace&);
00156 SketchSpace& operator= (const SketchSpace&);
00157 };
00158
00159 }
00160
00161 #endif