244 {
245 assert(edge.is_infinite());
246 assert((edge.vertex0() == nullptr) != (edge.vertex1() == nullptr));
247
249 const cell_type& cell2 = *edge.twin()->cell();
250
251 assert(cell1.contains_point() || cell2.contains_point());
252 if (! cell1.contains_point() && ! cell2.contains_point()) {
253 printf("Error! clip_infinite_edge - infinite edge separates two segment cells\n");
254 return;
255 }
256 point_type direction;
257 if (cell1.contains_point() && cell2.contains_point()) {
258 assert(! edge.is_secondary());
259 point_type p1 = retrieve_point(points, segments, cell1);
260 point_type p2 = retrieve_point(points, segments, cell2);
261 if (edge.vertex0() == nullptr)
262 std::swap(p1, p2);
263 direction.x(p1.y() - p2.y());
264 direction.y(p2.x() - p1.x());
265 } else {
266 assert(edge.is_secondary());
267 segment_type
segment = cell1.contains_segment() ? segments[cell1.source_index()] : segments[cell2.source_index()];
270 }
271 coordinate_type koef = bbox_max_size / (std::max)(fabs(direction.x()), fabs(direction.y()));
272 if (edge.vertex0() == nullptr) {
273 clipped_edge->push_back(point_type(edge.vertex1()->x() + direction.x() * koef, edge.vertex1()->y() + direction.y() * koef));
274 clipped_edge->push_back(point_type(edge.vertex1()->x(), edge.vertex1()->y()));
275 } else {
276 clipped_edge->push_back(
point_type(edge.vertex0()->x(), edge.vertex0()->y()));
277 clipped_edge->push_back(
point_type(edge.vertex0()->x() + direction.x() * koef, edge.vertex0()->y() + direction.y() * koef));
278 }
279 }
EIGEN_DEVICE_FUNC SegmentReturnType segment(Index start, Index n)
This is the const version of segment(Index,Index).
Definition BlockMethods.h:888
VD::cell_type cell_type
Definition VoronoiVisualUtils.hpp:203
boost::polygon::point_data< coordinate_type > point_type
Definition VoronoiVisualUtils.hpp:200