| | 15 | |
| | 16 | // Predicate testing LASPoint against given XY coordinates |
| | 17 | // and tolerance. |
| | 18 | struct is_xy |
| | 19 | { |
| | 20 | is_xy(double x, double y, double tolerance) |
| | 21 | : x(x), y(y), t(tolerance) |
| | 22 | {} |
| | 23 | |
| | 24 | bool operator()(liblas::LASPoint const& p) |
| | 25 | { |
| | 26 | double const dx = x - p.GetX(); |
| | 27 | double const dy = y - p.GetY(); |
| | 28 | |
| | 29 | return ((dx <= t && dx >= -t) && (dy <= t && dy >= -t)); |
| | 30 | } |
| | 31 | |
| | 32 | double x; |
| | 33 | double y; |
| | 34 | double t; |
| | 35 | }; |
| | 36 | |
| | 37 | // Functor to calculate bounding box of a set of points |
| | 38 | struct bbox_calculator |
| | 39 | { |
| | 40 | bbox_calculator(liblas::detail::Extents<double>& bbox) |
| | 41 | : empty(true), bbox(bbox) |
| | 42 | {} |
| | 43 | |
| | 44 | void operator()(liblas::LASPoint const& p) |
| | 45 | { |
| | 46 | // Box initialization during first iteration only |
| | 47 | if (empty) |
| | 48 | { |
| | 49 | bbox.min.x = bbox.max.x = p.GetX(); |
| | 50 | bbox.min.y = bbox.max.y = p.GetY(); |
| | 51 | bbox.min.z = bbox.max.z = p.GetZ(); |
| | 52 | empty = false; |
| | 53 | } |
| | 54 | |
| | 55 | // Expand bounding box to include given point |
| | 56 | bbox.min.x = std::min(bbox.min.x, p.GetX()); |
| | 57 | bbox.min.y = std::min(bbox.min.y, p.GetY()); |
| | 58 | bbox.min.z = std::min(bbox.min.z, p.GetZ()); |
| | 59 | bbox.max.x = std::max(bbox.max.x, p.GetX()); |
| | 60 | bbox.max.y = std::max(bbox.max.y, p.GetY()); |
| | 61 | bbox.max.z = std::max(bbox.max.z, p.GetZ()); |
| | 62 | } |
| | 63 | |
| | 64 | bool empty; |
| | 65 | liblas::detail::Extents<double>& bbox; |
| | 66 | }; |