00001
00002 #ifndef _BRICKDATA_H_
00003 #define _BRICKDATA_H_
00004
00005 #include <vector>
00006 #include <iostream>
00007 #include <string>
00008
00009 #include "Shared/newmat/newmat.h"
00010
00011 #include "BaseData.h"
00012 #include "Point.h"
00013 #include "ShapeTypes.h"
00014
00015 #include "LineData.h"
00016 #include "ShapeLine.h"
00017 #include "ShapeBlob.h"
00018
00019 namespace DualCoding {
00020
00021 class ShapeRoot;
00022 class SketchSpace;
00023 template<typename T> class Sketch;
00024
00025 class BrickData : public BaseData {
00026 private:
00027
00028 EndPoint GFL;
00029 EndPoint GFR;
00030 EndPoint GBL;
00031 EndPoint GBR;
00032 EndPoint TFL;
00033 EndPoint TFR;
00034 EndPoint TBL;
00035 EndPoint TBR;
00036
00037 Point centroid;
00038
00039 public:
00040
00041
00042 BrickData(ShapeSpace& _space,
00043 const EndPoint &GFL, const EndPoint &GFR, const EndPoint &GBL, const EndPoint &GBR,
00044 const EndPoint &TFL, const EndPoint &TFR, const EndPoint &TBL, const EndPoint &TBR);
00045
00046
00047
00048
00049 static ShapeType_t getStaticType() { return brickDataType; }
00050 DATASTUFF_H(BrickData);
00051
00052
00053 Point getCentroid() const { return centroid; }
00054
00055 EndPoint getGFL() {return GFL;}
00056 EndPoint getGFR() {return GFR;}
00057 EndPoint getGBL() {return GBL;}
00058 EndPoint getGBR() {return GBR;}
00059 EndPoint getTFL() {return TFL;}
00060 EndPoint getTFR() {return TFR;}
00061 EndPoint getTBL() {return TBL;}
00062 EndPoint getTBR() {return TBR;}
00063
00064
00065 virtual bool isMatchFor(const ShapeRoot& other) const;
00066
00067 virtual void mergeWith(const ShapeRoot& other);
00068
00069 virtual bool isAdmissible() const { return true; }
00070
00071 virtual bool updateParams(const ShapeRoot& other, bool force=false);
00072
00073
00074 virtual void printParams() const;
00075
00076
00077 void applyTransform(const NEWMAT::Matrix& Tmat);
00078
00079
00080 virtual void projectToGround(const NEWMAT::Matrix& camToBase,
00081 const NEWMAT::ColumnVector& groundplane);
00082
00083 virtual unsigned short getDimension() const { return 3; }
00084
00085
00086 static std::vector<Shape<BrickData> > findBricks(ShapeSpace& ShS, std::vector<Shape<LineData> > lines);
00087
00088 static std::vector<Shape<BrickData> > findBricksFromBlobs(ShapeSpace& ShS,
00089 std::vector<Shape<BlobData> > blobs1,
00090 std::vector<Shape<BlobData> > blobs2,
00091 std::vector<Shape<BlobData> > blobs3);
00092
00093 static Shape<BrickData> extractBrick(ShapeSpace& space, vector<Shape<BlobData> > &blobs);
00094
00095 static vector<Point> findOrthogonalBoundingBox(ShapeSpace& space, Shape<BlobData> blob, Point centroid, Shape<LineData> parallel);
00096 private:
00097
00098 Sketch<bool>* render() const;
00099
00100
00101 static int addBrickWithTwoSides(ShapeSpace& ShS,
00102 std::vector<Point>& corners1,
00103 std::vector<Point>& corners2,
00104 std::vector<std::vector<Point> >& blobs3,
00105 std::vector<Shape<BrickData> >& result,
00106 float distanceThresh);
00107
00108
00109
00110 BrickData& operator=(const BrickData&);
00111 };
00112
00113 }
00114
00115 #endif