Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

EllipseData.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef _ELLIPSEDATA_H_
00003 #define _ELLIPSEDATA_H_
00004 
00005 #include <vector>
00006 #include <iostream>
00007 
00008 #include "Shared/newmat/newmat.h"
00009 
00010 #include "BaseData.h"    // superclass
00011 #include "Point.h"       // Point data member
00012 #include "Shared/Measures.h"    // coordinate_t; AngPi data member
00013 
00014 namespace DualCoding {
00015 
00016 class ShapeRoot;
00017 class SketchSpace;
00018 template<typename T> class Sketch;
00019 
00020 #define ELLIPSE_DATA_MOBILE false
00021 
00022 class EllipseData : public BaseData {
00023 private:
00024   Point center_pt;
00025   float semimajor;
00026   float semiminor;
00027   AngPi orientation;
00028 
00029 public:
00030 
00031   //! Constructor
00032   EllipseData(ShapeSpace& _space, const Point &c, const float _semimajor=25, const float _semiminor=15, const float _orientation=0);
00033 
00034   static ShapeType_t getStaticType() { return ellipseDataType; }
00035 
00036   DATASTUFF_H(EllipseData);
00037   
00038   //! Centroid. (Virtual in BaseData.)
00039   Point getCentroid() const { return center_pt; } 
00040   void setCentroidPt(const Point& other) { center_pt.setCoords(other); }
00041   
00042   //! finds points where semiminor or semimajor axis touchs the circumference of ellipse
00043   std::pair<Point,Point> findFeaturePoints() const;
00044 
00045   //! updates major/minor axis and orientation from feature points
00046   void updateProperties(const Point& minorPt, const Point& majorPt);
00047 
00048   BoundingBox getBoundingBox() const;
00049 
00050   //! Match ellipses based on their parameters.  (Virtual in BaseData.)
00051   virtual bool isMatchFor(const ShapeRoot& other) const;
00052 
00053   virtual bool isAdmissible() const {
00054     return (semimajor >= 9.0 );  // **DST Hack** minimum size for an ellipse to be added to local map
00055   }
00056 
00057   virtual bool updateParams(const ShapeRoot& other, bool force=false);
00058 
00059   //! Print information about this shape. (Virtual in BaseData.)
00060   virtual void printParams() const;
00061   
00062   //! Transformations. (Virtual in BaseData.)
00063   void applyTransform(const NEWMAT::Matrix& Tmat, const ReferenceFrameType_t newref=unspecified);
00064   
00065   //! Project to ground
00066   virtual void projectToGround(const NEWMAT::Matrix& camToBase,
00067              const NEWMAT::ColumnVector& groundplane);
00068 
00069   //! Center point access function.
00070   const Point& centerPt() const { return center_pt; }
00071   
00072   virtual unsigned short getDimension() const { return 2; }
00073   
00074   //! Properties functions.
00075   //@{
00076   AngPi getOrientation() const { return orientation; }
00077   float getSemimajor() const { return semimajor; }
00078   float getSemiminor() const { return semiminor; }
00079   //@}
00080   
00081   
00082   //! Set properties.
00083   //@{
00084   void setOrientation(const AngPi _orientation);
00085   void setSemimajor(float _semimajor);
00086   void setSemiminor(float _semiminor);
00087   //@}
00088 
00089   //! Extraction.
00090   static std::vector<Shape<EllipseData> > extractEllipses(const Sketch<bool>& sketch);
00091   
00092   
00093 private:
00094   //! Render into a sketch space and return reference. (Private.)
00095   virtual Sketch<bool>* render() const;
00096   //@}
00097 
00098   EllipseData& operator=(const EllipseData&); //!< don't call
00099 
00100 };
00101 
00102 
00103 } // namespace
00104 
00105 #endif

DualCoding 4.0
Generated Thu Nov 22 00:52:36 2007 by Doxygen 1.5.4