00001
00002
00003 #ifndef _JAFAR_GEOM_DISTANCE_COV_VISITOR_HPP_
00004 #define _JAFAR_GEOM_DISTANCE_COV_VISITOR_HPP_
00005
00006 #include "AtomVisitor.hpp"
00007 #include "DistanceCov.hpp"
00008
00009 namespace jafar {
00010 namespace geom {
00011 template<int dimension>
00012 class DistanceCovVisitor : public AtomVisitor<dimension>
00013 {
00014 public:
00015 DistanceCovVisitor() : m_distance(0.0), m_distanceCov(0.0) {}
00016 double distance() const { return m_distance; }
00017 double distanceCov() const { return m_distanceCov; }
00018 protected:
00019 double m_distance, m_distanceCov;
00020 };
00021 template<class _AtomT_>
00022 class DistanceCovVisitorImpl : public DistanceCovVisitor<_AtomT_::Dimension>
00023 {
00024 public:
00025 DistanceCovVisitorImpl(const _AtomT_* atom) : m_atom(atom)
00026 {
00027 }
00028 virtual void visit( const geom::Point<_AtomT_::Dimension>& point)
00029 {
00030 distanceCov( *m_atom, point, this->m_distance, this->m_distanceCov );
00031 }
00032 virtual void visit( const geom::Line<_AtomT_::Dimension>& line)
00033 {
00034 distanceCov( *m_atom, line, this->m_distance, this->m_distanceCov );
00035 }
00036 virtual void visit( const geom::HyperPlane<_AtomT_::Dimension>& plan)
00037 {
00038 distanceCov( *m_atom, plan, this->m_distance, this->m_distanceCov );
00039 }
00040 virtual void visit( const geom::Segment<_AtomT_::Dimension>& segment)
00041 {
00042 distanceCov( *m_atom, segment, this->m_distance, this->m_distanceCov );
00043 }
00044 virtual void visit( const geom::Facet<_AtomT_::Dimension>& facet)
00045 {
00046 distanceCov( *m_atom, facet, this->m_distance, this->m_distanceCov );
00047 }
00048 private:
00049 const _AtomT_* m_atom;
00050 };
00051
00052 }
00053 }
00054
00055 #endif