259 {
260 assert(edge.is_infinite());
261 assert((edge.vertex0() == nullptr) != (edge.vertex1() == nullptr));
262
264 const cell_type& cell2 = *edge.twin()->cell();
265
266 assert(cell1.contains_point() || cell2.contains_point());
267 if (! cell1.contains_point() && ! cell2.contains_point()) {
268 printf("Error! clip_infinite_edge - infinite edge separates two segment cells\n");
269 return;
270 }
272 if (cell1.contains_point() && cell2.contains_point()) {
273 assert(! edge.is_secondary());
276 if (edge.vertex0() == nullptr)
277 std::swap(p1, p2);
278 direction.x(p1.y() - p2.y());
279 direction.y(p2.x() - p1.x());
280 } else {
281 assert(edge.is_secondary());
282 segment_type segment = cell1.contains_segment() ? segments[cell1.source_index()] : segments[cell2.source_index()];
283 direction.x(high(segment).y() - low(segment).y());
284 direction.y(low(segment).x() - high(segment).x());
285 }
286 coordinate_type koef = bbox_max_size / (std::max)(fabs(direction.x()), fabs(direction.y()));
287 if (edge.vertex0() == nullptr) {
288 clipped_edge->push_back(
point_type(edge.vertex1()->x() + direction.x() * koef, edge.vertex1()->y() + direction.y() * koef));
289 clipped_edge->push_back(
point_type(edge.vertex1()->x(), edge.vertex1()->y()));
290 } else {
291 clipped_edge->push_back(
point_type(edge.vertex0()->x(), edge.vertex0()->y()));
292 clipped_edge->push_back(
point_type(edge.vertex0()->x() + direction.x() * koef, edge.vertex0()->y() + direction.y() * koef));
293 }
294 }
VD::cell_type cell_type
Definition VoronoiVisualUtils.hpp:218
point_type retrieve_point(const Points &points, const std::vector< segment_type > &segments, const cell_type &cell)
Definition VoronoiVisualUtils.hpp:248
double coordinate_type
Definition VoronoiVisualUtils.hpp:214
boost::polygon::segment_data< coordinate_type > segment_type
Definition VoronoiVisualUtils.hpp:216
boost::polygon::point_data< coordinate_type > point_type
Definition VoronoiVisualUtils.hpp:215