Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

BrickData.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef _BRICKDATA_H_
00003 #define _BRICKDATA_H_
00004 
00005 #include <vector>
00006 #include <iostream>
00007 
00008 #include "BaseData.h"    // superclass
00009 #include "Point.h"       // Point data members
00010 #include "ShapeTypes.h"  // brickDataType
00011 
00012 #include "LineData.h"
00013 #include "ShapeLine.h"
00014 #include "ShapeBlob.h"
00015 
00016 namespace DualCoding {
00017 
00018 class ShapeRoot;
00019 class SketchSpace;
00020 template<typename T> class Sketch;
00021 
00022 class BrickData : public BaseData {
00023 protected:
00024   // T=Top, G=Ground, F=front, B=back, L=left, R=right
00025   EndPoint GFL;
00026   EndPoint GFR;
00027   EndPoint GBL;
00028   EndPoint GBR;
00029   EndPoint TFL;
00030   EndPoint TFR;
00031   EndPoint TBL;
00032   EndPoint TBR;
00033 
00034   Point centroid;
00035   fmat::Quaternion orientation;
00036 
00037 public:
00038 
00039   //! Constructor, with points
00040   BrickData(ShapeSpace& _space,
00041             const EndPoint &GFL, const EndPoint &GBL, const EndPoint &GFR, const EndPoint &GBR, 
00042             const EndPoint &TFL, const EndPoint &TBL, const EndPoint &TFR, const EndPoint &TBR,
00043             const fmat::Quaternion &orient = fmat::Quaternion::IDENTITY);
00044   
00045   //! Constructor, with center, half-extents, and orientation
00046   BrickData(ShapeSpace& _space,
00047             const fmat::SubVector<3,const fmat::fmatReal>& _centroid,
00048             fmat::Column<3> extents,
00049             const fmat::SubMatrix<3,3,const fmat::fmatReal>& o);
00050 
00051   //! Copy constructor
00052   //BrickData(BrickData& otherBrick);
00053 
00054   static ShapeType_t getStaticType() { return brickDataType; }
00055   DATASTUFF_H(BrickData);
00056   
00057   //! Centroid. (Virtual in BaseData.)
00058   Point getCentroid() const { return centroid; }
00059   const fmat::Quaternion& getOrientation() const { return orientation; }
00060   
00061   EndPoint getGFL() const {return GFL;}
00062   EndPoint getGFR() const {return GFR;}
00063   EndPoint getGBL() const {return GBL;}
00064   EndPoint getGBR() const {return GBR;}
00065   EndPoint getTFL() const {return TFL;}
00066   EndPoint getTFR() const {return TFR;}
00067   EndPoint getTBL() const {return TBL;}
00068   EndPoint getTBR() const {return TBR;}
00069   
00070   //! Get bounding box in the plane
00071   BoundingBox2D getBoundingBox() const;
00072 
00073   //! Match bricks based on their parameters.  (Virtual in BaseData.)
00074   virtual bool isMatchFor(const ShapeRoot& other) const;
00075 
00076   virtual void mergeWith(const ShapeRoot& other);
00077 
00078   virtual bool isAdmissible() const { return true; }
00079 
00080   virtual bool updateParams(const ShapeRoot& other, bool force=false);
00081 
00082   //! Print information about this shape. (Virtual in BaseData.)
00083   virtual void printParams() const;
00084   
00085   //! Transformations. (Virtual in BaseData.)
00086   void applyTransform(const fmat::Transform& Tmat, const ReferenceFrameType_t newref=unspecified);
00087   
00088   //! Project to ground
00089   virtual void projectToGround(const fmat::Transform& camToBase, const PlaneEquation& groundplane);
00090 
00091   virtual unsigned short getDimension() const { return 3; }
00092 
00093   //! Extraction.
00094   static std::vector<Shape<BrickData> > findBricks(ShapeSpace& ShS, std::vector<Shape<LineData> > lines);
00095 
00096   static std::vector<Shape<BrickData> > findBricksFromBlobs(ShapeSpace& ShS, 
00097                   std::vector<Shape<BlobData> > blobs1,
00098                   std::vector<Shape<BlobData> > blobs2,
00099                   std::vector<Shape<BlobData> > blobs3);
00100 
00101   static Shape<BrickData> extractBrick(ShapeSpace& space, std::vector<Shape<BlobData> > &blobs);
00102     
00103   static std::vector<Point> findOrthogonalBoundingBox(ShapeSpace& space, Shape<BlobData> blob, Point centroid, Shape<LineData> parallel);
00104 private:
00105   //! Render into a sketch space and return reference. (Private.)
00106   Sketch<bool>* render() const;
00107 
00108 
00109   static int addBrickWithTwoSides(ShapeSpace& ShS,
00110           std::vector<Point>& corners1, 
00111           std::vector<Point>& corners2, 
00112           std::vector<std::vector<Point> >& blobs3, 
00113           std::vector<Shape<BrickData> >& result, 
00114           float distanceThresh);
00115 
00116   //@}
00117 
00118   BrickData& operator=(const BrickData&); //!< don't call
00119 };
00120 
00121 } // namespace
00122 
00123 #endif

DualCoding 5.1CVS
Generated Mon May 9 04:56:25 2016 by Doxygen 1.6.3