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 "BaseData.h"    // superclass
00009 #include "Point.h"       // Point data member
00010 #include "Shared/Measures.h"    // coordinate_t; AngPi data member
00011 
00012 #include "ShapeFuns.h"
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   //! returns the bounding box of the ellipse
00049   BoundingBox2D getBoundingBox() const;
00050 
00051   //! Match ellipses based on their parameters.  (Virtual in BaseData.)
00052   virtual bool isMatchFor(const ShapeRoot& other) const;
00053 
00054   //! Check whether ellipse is large enough to be admissible to the local map (i.e., probably not noise)
00055   virtual bool isAdmissible() const;
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 fmat::Transform& Tmat, const ReferenceFrameType_t newref=unspecified);
00064   
00065   //! Project to ground
00066   virtual void projectToGround(const fmat::Transform& camToBase, const PlaneEquation& groundplane);
00067 
00068   //! Center point access function.
00069   const Point& centerPt() const { return center_pt; }
00070   
00071   virtual unsigned short getDimension() const { return 2; }
00072   
00073   //! Properties functions.
00074   //@{
00075   AngPi getOrientation() const { return orientation; }
00076   float getSemimajor() const { return semimajor; }
00077   float getSemiminor() const { return semiminor; }
00078   float getArea() const { return static_cast<float>(M_PI) * semimajor * 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   //!@name Comparison predicates used by shape functions
00093   //@{
00094 
00095   //! True if ellipse1 has less area than ellipse2
00096   class AreaLessThan : public BinaryShapePred<EllipseData> {
00097   public:
00098     bool operator() (const Shape<EllipseData> &ln1, const Shape<EllipseData> &ln2) const;
00099   };
00100 
00101   
00102 private:
00103   //! Render into a sketch space and return reference. (Private.)
00104   virtual Sketch<bool>* render() const;
00105   //@}
00106 
00107   EllipseData& operator=(const EllipseData&); //!< don't call
00108 
00109 };
00110 
00111 
00112 } // namespace
00113 
00114 #endif

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