00001 #ifndef _RANGE_OBS_HPP
00002 #define _RANGE_OBS_HPP
00003
00004 #include <iostream>
00005 #include "properties.hpp"
00006 #include "query_point.hpp"
00007 #include "coloring.hpp"
00008 #include "arak.hpp"
00009 #include "grid.hpp"
00010
00011 namespace Arak {
00012
00020 class ArakPosteriorRangeObs : public ArakProcess,
00021 public Coloring::Listener {
00022
00023 protected:
00024
00025 class RangeObs;
00026 typedef PointerHandle<RangeObs> RangeObsHandle;
00027
00032 typedef Grid<RangeObsHandle> RangeObsIndex;
00033
00041 class RangeObs : public QueryPointListener {
00042
00043 public:
00044
00048 Geometry::Point source;
00049
00053 Geometry::Point target;
00054
00058 Geometry::Point max;
00059
00063 double range;
00064
00068 bool isMaxRange;
00069
00073 Color sourceColor;
00074
00079 Geometry::Point curContact;
00080
00084 double curRange;
00085
00089 double lp;
00090
00094 typedef RangeObsIndex::Cell::Entry CellEntry;
00095
00099 typedef std::list<CellEntry> CellEntryList;
00100
00104 CellEntryList entries;
00105
00110 CellEntryList unused;
00111
00115 unsigned long int updateId;
00116
00120 RangeObs(const Geometry::Point& source,
00121 const Geometry::Point& target,
00122 const double maxRange);
00123
00127 virtual ~RangeObs() {};
00128
00134 virtual void recolor(Color color) {
00135 sourceColor = color;
00136 }
00137
00138 };
00139
00143 const ArakProcess& prior;
00144
00148 std::vector<RangeObs*> obs;
00149
00153 RangeObsIndex* obsIndex;
00154
00158 unsigned long int updateId;
00159
00164 double maxRange;
00165
00170 double rangeVar;
00171
00175 double pOutlier;
00176
00182 double pMaxFalseNeg;
00183
00189 double pMaxFalsePos;
00190
00194 double lp;
00195
00200 bool retraceObs(RangeObs& o, bool init = false) const;
00201
00207 double updateObsLP(RangeObs& o, bool init = false) const;
00208
00209 public:
00210
00229 ArakPosteriorRangeObs(const ArakProcess& prior,
00230 const Arak::Util::PropertyMap& props);
00231
00235 virtual ~ArakPosteriorRangeObs();
00236
00241 const Geometry::Rectangle& boundary() const {
00242 return obsIndex->boundary();
00243 }
00244
00248 virtual double scale() const { return prior.scale(); }
00249
00258 virtual double logMeasure() const;
00259
00267 virtual double potential() const;
00268
00276 virtual void visualize(CGAL::Qt_widget& widget) const;
00277
00286 virtual void update(const Geometry::Point& a,
00287 const Geometry::Point& b,
00288 const Geometry::Point& c);
00289
00298 virtual void recolored(const Geometry::Point& a,
00299 const Geometry::Point& b,
00300 const Geometry::Point& c);
00301
00314 virtual void recolored(const Geometry::Point& a,
00315 const Geometry::Point& b,
00316 const Geometry::Point& c,
00317 const Geometry::Point& d);
00318 };
00319
00328 CGAL::Qt_widget& operator<<(CGAL::Qt_widget& widget,
00329 ArakPosteriorRangeObs& p);
00330
00331 }
00332
00333 #endif