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