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