Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

arak.hpp

Go to the documentation of this file.
00001 #ifndef _ARAK_HPP
00002 #define _ARAK_HPP
00003 
00004 #include "properties.hpp"
00005 #include "coloring.hpp"
00006 
00007 namespace CGAL {
00008   class Qt_widget;
00009 }
00010 
00011 namespace Arak {
00012 
00051   class ArakProcess {
00052 
00053   protected:
00054 
00060     const Coloring& c;
00061 
00062   public:
00063 
00072     ArakProcess(const Coloring& c) : c(c) { }
00073 
00077     virtual ~ArakProcess() { }
00078 
00083     const Coloring& getColoring() const { return c; }
00084 
00088     virtual double scale() const = 0;
00089 
00098     virtual double logMeasure() const = 0;
00099 
00111     virtual double potential() const = 0;
00112 
00119     double logLikelihood(double temp = 1.0) const {
00120       return logMeasure() - potential() / temp;
00121     }
00122     
00131     double logLikelihood(Coloring& c, double temp = 1.0) const {
00132       assert(c == this->c);
00133       return logLikelihood(temp);
00134     }
00135 
00144     virtual void visualize(CGAL::Qt_widget& widget) const { }
00145   };
00146 
00155   inline CGAL::Qt_widget& 
00156   operator<<(CGAL::Qt_widget& widget, const ArakProcess& p) {
00157     p.visualize(widget);
00158     return widget;
00159   }
00160 
00171   class ArakPrior : public ArakProcess, public Coloring::Listener {
00172 
00173   protected:
00174 
00180     double p;
00181 
00194     double sumLogLengths;
00195   
00212     double sumLogSines;
00213 
00226     double sumLengths;
00227   
00231     void initialize();
00232 
00233   public:
00234 
00244     ArakPrior(Coloring& c, double p = 1.0) : ArakProcess(c), p(p) { 
00245       initialize();
00246     }
00247 
00258     ArakPrior(Coloring& c, const Arak::Util::PropertyMap& props) : 
00259       ArakProcess(c), p(1.0) { 
00260       using namespace Arak::Util;
00261       assert(parse(getp(props, "arak.scale"), p));
00262       initialize();
00263     }
00264 
00268     virtual ~ArakPrior() { }
00269 
00273     virtual double scale() const { return p; }
00274 
00284     virtual double logMeasure() const;
00285 
00297     virtual double potential() const {
00298       return 2.0 * p * sumLengths;
00299     }
00300 
00309     virtual void recolored(const Geometry::Point& a,
00310          const Geometry::Point& b,
00311          const Geometry::Point& c) { }
00312       
00325     virtual void recolored(const Geometry::Point& a,
00326          const Geometry::Point& b,
00327          const Geometry::Point& c,
00328          const Geometry::Point& d) { }
00329     
00336     virtual void vertexHasBeenAdded(Coloring::VertexHandle vh);
00337     
00344     virtual void vertexWillBeRemoved(Coloring::VertexHandle vh);
00345 
00352     virtual void edgeHasBeenAdded(Coloring::IntEdgeHandle eh);
00353 
00360     virtual void edgeWillBeRemoved(Coloring::IntEdgeHandle eh);
00361     
00370     virtual void visualize(CGAL::Qt_widget& widget) const { }
00371   };
00372 
00373 }
00374 
00375 #endif

Generated on Wed May 25 14:39:15 2005 for Arak by doxygen 1.3.6