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