Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00053 #ifdef _MSC_VER
00054 #pragma once
00055 #endif
00056
00057
00058 #ifndef OGDF_NEAREST_RECTANGLE_FINDER_H
00059 #define OGDF_NEAREST_RECTANGLE_FINDER_H
00060
00061
00062 #include <ogdf/basic/Array.h>
00063 #include <ogdf/basic/geometry.h>
00064
00065
00066 namespace ogdf {
00067
00068
00069
00070
00071
00072
00073
00074 class OGDF_EXPORT NearestRectangleFinder
00075 {
00076 public:
00077 struct RectRegion;
00078 struct PairRectDist;
00079 struct PairCoordId;
00080
00081 NearestRectangleFinder(double mad = 20, double td = 5) {
00082 m_maxAllowedDistance = mad;
00083 m_toleranceDistance = td;
00084 }
00085
00086
00087
00088 void maxAllowedDistance(double mad) { m_maxAllowedDistance = mad; }
00089 double maxAllowedDistance() const { return m_maxAllowedDistance; }
00090
00091
00092
00093
00094
00095 void toleranceDistance(double td) { m_toleranceDistance = td; }
00096 double toleranceDistance() const { return m_toleranceDistance; }
00097
00098
00099
00100
00101
00102
00103
00104 void find(
00105 const Array<RectRegion> ®ion,
00106 const Array<DPoint> &point,
00107 Array<List<PairRectDist> > &nearest);
00108
00109
00110
00111
00112 void findSimple(
00113 const Array<RectRegion> ®ion,
00114 const Array<DPoint> &point,
00115 Array<List<PairRectDist> > &nearest);
00116
00117 private:
00118 class CoordComparer;
00119 class YCoordComparer;
00120
00121 double m_maxAllowedDistance;
00122 double m_toleranceDistance;
00123 };
00124
00125
00126
00127
00128
00129
00130 struct NearestRectangleFinder::RectRegion
00131 {
00132 friend ostream &operator<<(ostream &os, const RectRegion &rect) {
00133 os << "(" << rect.m_x << "," << rect.m_y << ":" <<
00134 rect.m_width << "," << rect.m_height << ")";
00135 return os;
00136 }
00137
00138 double m_x, m_y, m_width, m_height;
00139 };
00140
00141
00142
00143
00144
00145
00146
00147 struct OGDF_EXPORT NearestRectangleFinder::PairRectDist
00148 {
00149 PairRectDist() { }
00150
00151 PairRectDist(int index, double distance) {
00152 m_index = index;
00153 m_distance = distance;
00154 }
00155
00156 friend ostream &operator<<(ostream &os, const PairRectDist &p) {
00157 os << "(" << p.m_index << "," << p.m_distance << ")";
00158 return os;
00159 }
00160
00161 int m_index;
00162 double m_distance;
00163 };
00164
00165
00166
00167 }
00168
00169
00170 #endif