| 41 | | typedef std::vector<Envelope<double> > label_placements; |
| 42 | | |
| 43 | | bool has_plasement(Envelope<double> const& box) |
| 44 | | { |
| 45 | | label_placements::const_iterator itr=labels_.begin(); |
| 46 | | for( ; itr !=labels_.end();++itr) |
| 47 | | { |
| 48 | | if (itr->intersects(box)) |
| 49 | | { |
| 50 | | return false; |
| 51 | | } |
| 52 | | } |
| 53 | | labels_.push_back(box); |
| 54 | | return true; |
| 55 | | } |
| 56 | | void clear() |
| 57 | | { |
| 58 | | labels_.clear(); |
| 59 | | } |
| 60 | | |
| 61 | | private: |
| 62 | | |
| 63 | | label_placements labels_; |
| | 41 | typedef std::vector<Envelope<double> > label_placements; |
| | 42 | |
| | 43 | bool has_plasement(Envelope<double> const& box) |
| | 44 | { |
| | 45 | label_placements::const_iterator itr=labels_.begin(); |
| | 46 | for( ; itr !=labels_.end();++itr) |
| | 47 | { |
| | 48 | if (itr->intersects(box)) |
| | 49 | { |
| | 50 | return false; |
| | 51 | } |
| | 52 | } |
| | 53 | labels_.push_back(box); |
| | 54 | return true; |
| | 55 | } |
| | 56 | void clear() |
| | 57 | { |
| | 58 | labels_.clear(); |
| | 59 | } |
| | 60 | |
| | 61 | private: |
| | 62 | |
| | 63 | label_placements labels_; |
| 69 | | typedef quad_tree<Envelope<double> > tree_t; |
| 70 | | tree_t tree_; |
| 71 | | public: |
| 72 | | |
| 73 | | explicit label_collision_detector2(Envelope<double> const& extent) |
| 74 | | : tree_(extent) {} |
| 75 | | |
| 76 | | bool has_placement(Envelope<double> const& box) |
| 77 | | { |
| 78 | | tree_t::query_iterator itr = tree_.query_in_box(box); |
| 79 | | tree_t::query_iterator end = tree_.query_end(); |
| | 69 | typedef quad_tree<Envelope<double> > tree_t; |
| | 70 | tree_t tree_; |
| | 71 | public: |
| | 72 | |
| | 73 | explicit label_collision_detector2(Envelope<double> const& extent) |
| | 74 | : tree_(extent) {} |
| | 75 | |
| | 76 | bool has_placement(Envelope<double> const& box) |
| | 77 | { |
| | 78 | tree_t::query_iterator itr = tree_.query_in_box(box); |
| | 79 | tree_t::query_iterator end = tree_.query_end(); |
| 103 | | typedef quad_tree< Envelope<double> > tree_t; |
| 104 | | tree_t tree_; |
| 105 | | public: |
| 106 | | |
| 107 | | explicit label_collision_detector3(Envelope<double> const& extent) |
| 108 | | : tree_(extent) {} |
| 109 | | |
| 110 | | bool has_placement(Envelope<double> const& box) |
| 111 | | { |
| 112 | | tree_t::query_iterator itr = tree_.query_in_box(box); |
| 113 | | tree_t::query_iterator end = tree_.query_end(); |
| 114 | | |
| 115 | | for ( ;itr != end; ++itr) |
| 116 | | { |
| 117 | | if (itr->intersects(box)) |
| 118 | | { |
| 119 | | return false; |
| 120 | | } |
| 121 | | } |
| 122 | | |
| 123 | | return true; |
| 124 | | } |
| 125 | | |
| 126 | | void insert(Envelope<double> const& box) |
| 127 | | { |
| 128 | | tree_.insert(box, box); |
| 129 | | } |
| 130 | | |
| 131 | | void clear() |
| 132 | | { |
| 133 | | tree_.clear(); |
| 134 | | } |
| | 103 | typedef quad_tree< Envelope<double> > tree_t; |
| | 104 | tree_t tree_; |
| | 105 | public: |
| | 106 | |
| | 107 | explicit label_collision_detector3(Envelope<double> const& extent) |
| | 108 | : tree_(extent) {} |
| | 109 | |
| | 110 | bool has_placement(Envelope<double> const& box) |
| | 111 | { |
| | 112 | tree_t::query_iterator itr = tree_.query_in_box(box); |
| | 113 | tree_t::query_iterator end = tree_.query_end(); |
| | 114 | |
| | 115 | for ( ;itr != end; ++itr) |
| | 116 | { |
| | 117 | if (itr->intersects(box)) |
| | 118 | { |
| | 119 | return false; |
| | 120 | } |
| | 121 | } |
| | 122 | |
| | 123 | return true; |
| | 124 | } |
| | 125 | |
| | 126 | void insert(Envelope<double> const& box) |
| | 127 | { |
| | 128 | tree_.insert(box, box); |
| | 129 | } |
| | 130 | |
| | 131 | void clear() |
| | 132 | { |
| | 133 | tree_.clear(); |
| | 134 | } |
| 146 | | Envelope<double> box; |
| 147 | | UnicodeString text; |
| 148 | | }; |
| 149 | | |
| 150 | | typedef quad_tree< label > tree_t; |
| 151 | | Envelope<double> extent_; |
| 152 | | tree_t tree_; |
| 153 | | |
| 154 | | public: |
| 155 | | |
| 156 | | explicit label_collision_detector4(Envelope<double> const& extent) |
| 157 | | : extent_(extent), |
| 158 | | tree_(extent) {} |
| 159 | | |
| 160 | | bool has_placement(Envelope<double> const& box) |
| 161 | | { |
| 162 | | tree_t::query_iterator itr = tree_.query_in_box(box); |
| 163 | | tree_t::query_iterator end = tree_.query_end(); |
| 164 | | |
| 165 | | for ( ;itr != end; ++itr) |
| 166 | | { |
| 167 | | if (itr->box.intersects(box)) |
| 168 | | { |
| 169 | | return false; |
| 170 | | } |
| 171 | | } |
| 172 | | |
| 173 | | return true; |
| 174 | | } |
| 175 | | |
| 176 | | bool has_placement(Envelope<double> const& box, UnicodeString const& text, double distance) |
| 177 | | { |
| 178 | | Envelope<double> bigger_box(box.minx() - distance, box.miny() - distance, box.maxx() + distance, box.maxy() + distance); |
| 179 | | tree_t::query_iterator itr = tree_.query_in_box(bigger_box); |
| 180 | | tree_t::query_iterator end = tree_.query_end(); |
| | 146 | Envelope<double> box; |
| | 147 | UnicodeString text; |
| | 148 | }; |
| | 149 | |
| | 150 | typedef quad_tree< label > tree_t; |
| | 151 | Envelope<double> extent_; |
| | 152 | tree_t tree_; |
| | 153 | |
| | 154 | public: |
| | 155 | |
| | 156 | explicit label_collision_detector4(Envelope<double> const& extent) |
| | 157 | : extent_(extent), |
| | 158 | tree_(extent) {} |
| | 159 | |
| | 160 | bool has_placement(Envelope<double> const& box) |
| | 161 | { |
| | 162 | tree_t::query_iterator itr = tree_.query_in_box(box); |
| | 163 | tree_t::query_iterator end = tree_.query_end(); |
| | 164 | |
| | 165 | for ( ;itr != end; ++itr) |
| | 166 | { |
| | 167 | if (itr->box.intersects(box)) |
| | 168 | { |
| | 169 | return false; |
| | 170 | } |
| | 171 | } |
| | 172 | |
| | 173 | return true; |
| | 174 | } |
| | 175 | |
| | 176 | bool has_placement(Envelope<double> const& box, UnicodeString const& text, double distance) |
| | 177 | { |
| | 178 | Envelope<double> bigger_box(box.minx() - distance, box.miny() - distance, box.maxx() + distance, box.maxy() + distance); |
| | 179 | tree_t::query_iterator itr = tree_.query_in_box(bigger_box); |
| | 180 | tree_t::query_iterator end = tree_.query_end(); |
| 212 | | tree_.insert(label(box), box); |
| 213 | | } |
| 214 | | |
| 215 | | void insert(Envelope<double> const& box, UnicodeString const& text) |
| 216 | | { |
| 217 | | tree_.insert(label(box, text), box); |
| 218 | | } |
| 219 | | |
| 220 | | void clear() |
| 221 | | { |
| 222 | | tree_.clear(); |
| 223 | | } |
| 224 | | Envelope<double> const& extent() const |
| 225 | | { |
| 226 | | return extent_; |
| 227 | | } |
| 228 | | }; |
| | 212 | tree_.insert(label(box), box); |
| | 213 | } |
| | 214 | |
| | 215 | void insert(Envelope<double> const& box, UnicodeString const& text) |
| | 216 | { |
| | 217 | tree_.insert(label(box, text), box); |
| | 218 | } |
| | 219 | |
| | 220 | void clear() |
| | 221 | { |
| | 222 | tree_.clear(); |
| | 223 | } |
| | 224 | |
| | 225 | Envelope<double> const& extent() const |
| | 226 | { |
| | 227 | return extent_; |
| | 228 | } |
| | 229 | }; |