26 std::vector<typename Kernel::Point_2>
const &points,
27 const double cell_size = 0.2) {
29 double min_x = polygon[0].x(), max_x = polygon[0].x();
30 double min_y = polygon[0].y(), max_y = polygon[0].y();
31 for (
auto &p : polygon) {
32 min_x = std::min(min_x, p.x());
33 max_x = std::max(max_x, p.x());
34 min_y = std::min(min_y, p.y());
35 max_y = std::max(max_y, p.y());
38 int nx =
static_cast<int>(std::ceil((max_x - min_x) / cell_size));
39 int ny =
static_cast<int>(std::ceil((max_y - min_y) / cell_size));
41 int covered_cells = 0;
44 for (
int i = 0; i < nx; ++i) {
45 for (
int j = 0; j < ny; ++j) {
46 const double cx = min_x + (i + 0.5) * cell_size;
47 const double cy = min_y + (j + 0.5) * cell_size;
48 typename Kernel::Point_2 cell_center(cx, cy);
49 if (polygon.bounded_side(cell_center) == CGAL::ON_UNBOUNDED_SIDE)
53 for (
auto &pt : points) {
54 if (std::abs(pt.x() - cx) <= cell_size / 2 &&
55 std::abs(pt.y() - cy) <= cell_size / 2) {
65 return static_cast<double>(covered_cells) / total_cells;
71 std::vector<pcl::IndicesPtr> &inliers,
72 const double grid_size) ->
void {
74 using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel;
76 using Point_3 = EPICK::Point_3;
77 using Plane_3 = EPICK::Plane_3;
79 using Polygon_2 = CGAL::Polygon_2<EPICK>;
80 using Point_2 = Polygon_2::Point_2;
91 std::vector<ReUseX::geometry::CellComplex::Vertex> face_list;
94 face_list.push_back(*fit);
96#pragma omp parallel for schedule(dynamic)
97 for (
size_t face_idx = 0; face_idx < face_list.size(); ++face_idx) {
98 auto fit = face_list[face_idx];
103 const int plane_id = std::get<FaceData>((*
this)[fit].data).plane_id;
105 auto get_comverage = [&](
const int id) {
113 const auto plane_vec = planes[id];
114 const auto indices = inliers[id];
116 const Plane_3 plane(plane_vec[0], plane_vec[1], plane_vec[2],
119 if (indices->empty())
124 std::back_inserter(polygon), [&](
Vertex v) {
125 const auto pos = (*this)[v].pos;
126 return plane.to_2d(Point_3(pos[0], pos[1], pos[2]));
136 const auto inliers = *indices | ranges::views::transform([&](
int idx) {
137 const PointT &p = cloud->points[idx];
138 return plane.to_2d(Point_3(p.x, p.y, p.z));
139 }) | ranges::views::filter([&](
const Point_2 &p) {
140 return polygon.bounded_side(p) == CGAL::ON_BOUNDED_SIDE;
141 }) | ranges::to<std::vector>();
149 auto val = get_comverage(plane_id);
std::vector< Eigen::Matrix< Scalar, Rows, 1 >, Eigen::aligned_allocator< Eigen::Matrix< Scalar, Rows, 1 > > > EigenVectorContainer