EllipseData.h
Go to the documentation of this file.00001
00002 #ifndef _ELLIPSEDATA_H_
00003 #define _ELLIPSEDATA_H_
00004
00005 #include <vector>
00006 #include <iostream>
00007
00008 #include "BaseData.h"
00009 #include "Point.h"
00010 #include "Shared/Measures.h"
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
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
00039 Point getCentroid() const { return center_pt; }
00040 void setCentroidPt(const Point& other) { center_pt.setCoords(other); }
00041
00042
00043 std::pair<Point,Point> findFeaturePoints() const;
00044
00045
00046 void updateProperties(const Point& minorPt, const Point& majorPt);
00047
00048
00049 BoundingBox2D getBoundingBox() const;
00050
00051
00052 virtual bool isMatchFor(const ShapeRoot& other) const;
00053
00054
00055 virtual bool isAdmissible() const;
00056
00057 virtual bool updateParams(const ShapeRoot& other, bool force=false);
00058
00059
00060 virtual void printParams() const;
00061
00062
00063 void applyTransform(const fmat::Transform& Tmat, const ReferenceFrameType_t newref=unspecified);
00064
00065
00066 virtual void projectToGround(const fmat::Transform& camToBase, const PlaneEquation& groundplane);
00067
00068
00069 const Point& centerPt() const { return center_pt; }
00070
00071 virtual unsigned short getDimension() const { return 2; }
00072
00073
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
00083
00084 void setOrientation(const AngPi _orientation);
00085 void setSemimajor(float _semimajor);
00086 void setSemiminor(float _semiminor);
00087
00088
00089
00090 static std::vector<Shape<EllipseData> > extractEllipses(const Sketch<bool>& sketch);
00091
00092
00093
00094
00095
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
00104 virtual Sketch<bool>* render() const;
00105
00106
00107 EllipseData& operator=(const EllipseData&);
00108
00109 };
00110
00111
00112 }
00113
00114 #endif