diff options
author | Arnur Nigmetov <nigmetov@tugraz.at> | 2020-03-04 00:33:51 +0100 |
---|---|---|
committer | Arnur Nigmetov <nigmetov@tugraz.at> | 2020-03-04 00:33:51 +0100 |
commit | 3809e4071827a5959f27e472514eaed08ba6d15e (patch) | |
tree | 113fd1c373e4a04b568f8daf25324efafff6b107 /matching/include/dual_point.h | |
parent | d56c07b093bfea1690a81ebbef41b8bb9c7c2464 (diff) |
Make matching distance header-only.
Diffstat (limited to 'matching/include/dual_point.h')
-rw-r--r-- | matching/include/dual_point.h | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/matching/include/dual_point.h b/matching/include/dual_point.h index db32f1a..8438860 100644 --- a/matching/include/dual_point.h +++ b/matching/include/dual_point.h @@ -1,12 +1,9 @@ -// -// Created by narn on 12.02.19. -// - #ifndef MATCHING_DISTANCE_DUAL_POINT_H #define MATCHING_DISTANCE_DUAL_POINT_H #include <vector> #include <ostream> +#include <tuple> #include "common_util.h" #include "box.h" @@ -25,9 +22,10 @@ namespace md { // so, e.g., line y = x has 4 different non-equal representation. // we are unlikely to ever need this, because 4 cases are // always treated separately. + template<class Real_> class DualPoint { public: - using Real = md::Real; + using Real = Real_; DualPoint() = default; @@ -56,7 +54,6 @@ namespace md { bool is_y_type() const { return axis_type_ == AxisType::y_type; } - friend std::ostream& operator<<(std::ostream& os, const DualPoint& dp); bool operator<(const DualPoint& rhs) const; AxisType axis_type() const { return axis_type_; } @@ -66,16 +63,16 @@ namespace md { // return true otherwise bool sanity_check() const; - Real weighted_push(Point p) const; - Point push(Point p) const; + Real weighted_push(Point<Real> p) const; + Point<Real> push(Point<Real> p) const; bool is_horizontal() const; bool is_vertical() const; - bool goes_below(Point p) const; - bool goes_above(Point p) const; + bool goes_below(Point<Real> p) const; + bool goes_above(Point<Real> p) const; - bool contains(Point p) const; + bool contains(Point<Real> p) const; Real x_slope() const; Real y_slope() const; @@ -98,9 +95,13 @@ namespace md { Real mu_ {-1.0}; }; - std::ostream& operator<<(std::ostream& os, const DualPoint& dp); + template<class Real> + std::ostream& operator<<(std::ostream& os, const DualPoint<Real>& dp); - DualPoint midpoint(DualPoint x, DualPoint y); + template<class Real> + DualPoint<Real> midpoint(DualPoint<Real> x, DualPoint<Real> y); }; +#include "dual_point.hpp" + #endif //MATCHING_DISTANCE_DUAL_POINT_H |