adding more tests

This commit is contained in:
Sven Oesau 2024-01-05 15:03:10 +01:00
parent 06ffd9a86c
commit dabc8ff85c
7 changed files with 167 additions and 39 deletions

View File

@ -105,6 +105,11 @@ int main(const int argc, const char** argv) {
Point_set point_set(parameters.with_normals); Point_set point_set(parameters.with_normals);
CGAL::IO::read_point_set(parameters.data, point_set); CGAL::IO::read_point_set(parameters.data, point_set);
if (point_set.size() == 0) {
std::cout << "input file not found or empty!" << std::endl;
return EXIT_FAILURE;
}
if (!point_set.has_normal_map()) { if (!point_set.has_normal_map()) {
point_set.add_normal_map(); point_set.add_normal_map();
CGAL::pca_estimate_normals<CGAL::Parallel_if_available_tag>(point_set, 9); CGAL::pca_estimate_normals<CGAL::Parallel_if_available_tag>(point_set, 9);
@ -195,7 +200,7 @@ int main(const int argc, const char** argv) {
FT after_reconstruction = timer.time(); FT after_reconstruction = timer.time();
if (polylist.size() > 0) if (polylist.size() > 0)
CGAL::IO::write_polygon_soup("polylist_" + std::to_string(parameters.graphcut_beta) + ".off", vtx, polylist); CGAL::IO::write_polygon_soup("polylist_" + std::to_string(parameters.graphcut_beta) + (parameters.use_ground ? "_g" : "_") + ".off", vtx, polylist);
timer.stop(); timer.stop();
const FT time = static_cast<FT>(timer.time()); const FT time = static_cast<FT>(timer.time());
@ -217,7 +222,7 @@ int main(const int argc, const char** argv) {
if (polylist.size() > 0) if (polylist.size() > 0)
CGAL::IO::write_polygon_soup("polylist_" + std::to_string(l) + ".off", vtx, polylist); CGAL::IO::write_polygon_soup("polylist_" + std::to_string(l) + (parameters.use_ground ? "_g" : "_") + ".off", vtx, polylist);
} }
std::cout << "Shape detection: " << after_shape_detection << " seconds!" << std::endl; std::cout << "Shape detection: " << after_shape_detection << " seconds!" << std::endl;

View File

@ -705,6 +705,7 @@ private:
collect_points_for_faces_lcc(); collect_points_for_faces_lcc();
count_volume_votes_lcc(); count_volume_votes_lcc();
if (m_verbose)
std::cout << "* computing data term ... "; std::cout << "* computing data term ... ";
std::size_t max_inside = 0, max_outside = 0; std::size_t max_inside = 0, max_outside = 0;
@ -1869,7 +1870,6 @@ private:
} }
// Estimate ground plane by finding a low mostly horizontal plane // Estimate ground plane by finding a low mostly horizontal plane
{
std::vector<std::size_t> candidates; std::vector<std::size_t> candidates;
FT low_z_peak = (std::numeric_limits<FT>::max)(); FT low_z_peak = (std::numeric_limits<FT>::max)();
FT bbox_min[] = { (std::numeric_limits<FT>::max)(), (std::numeric_limits<FT>::max)(), (std::numeric_limits<FT>::max)() }; FT bbox_min[] = { (std::numeric_limits<FT>::max)(), (std::numeric_limits<FT>::max)(), (std::numeric_limits<FT>::max)() };
@ -1906,10 +1906,14 @@ private:
} }
} }
if (m_ground_polygon_index != -1) {
for (std::size_t i = 0; i < other_ground.size(); i++) for (std::size_t i = 0; i < other_ground.size(); i++)
std::move(m_regions[other_ground[i]].second.begin(), m_regions[other_ground[i]].second.end(), std::back_inserter(m_regions[m_ground_polygon_index].second)); std::move(m_regions[other_ground[i]].second.begin(), m_regions[other_ground[i]].second.end(), std::back_inserter(m_regions[m_ground_polygon_index].second));
if (m_verbose)
std::cout << "ground polygon " << m_ground_polygon_index << ", merging other polygons"; std::cout << "ground polygon " << m_ground_polygon_index << ", merging other polygons";
while (other_ground.size() != 0) { while (other_ground.size() != 0) {
m_regions.erase(m_regions.begin() + other_ground.back()); m_regions.erase(m_regions.begin() + other_ground.back());
std::cout << " " << other_ground.back(); std::cout << " " << other_ground.back();
@ -1941,6 +1945,7 @@ private:
//KSP_3::dump_polygon(polys_debug[i], std::to_string(i) + "-detected-region.ply"); //KSP_3::dump_polygon(polys_debug[i], std::to_string(i) + "-detected-region.ply");
} }
if (m_debug)
KSP_3::internal::dump_polygons(polys_debug, "merged-" + std::to_string(m_regions.size()) + "-polygons.ply"); KSP_3::internal::dump_polygons(polys_debug, "merged-" + std::to_string(m_regions.size()) + "-polygons.ply");
std::vector<Plane_3> pl; std::vector<Plane_3> pl;
@ -1970,9 +1975,11 @@ private:
} }
CGAL_assertion(m_planar_regions.size() == m_regions.size()); CGAL_assertion(m_planar_regions.size() == m_regions.size());
if (m_verbose) {
std::cout << "found " << num_shapes << " planar shapes regularized into " << m_planar_regions.size() << std::endl; std::cout << "found " << num_shapes << " planar shapes regularized into " << m_planar_regions.size() << std::endl;
std::cout << "from " << m_points.size() << " input points " << unassigned << " remain unassigned" << std::endl; std::cout << "from " << m_points.size() << " input points " << unassigned << " remain unassigned" << std::endl;
} }
}
void map_points_to_faces(const std::size_t polygon_index, const std::vector<Point_3>& pts, std::vector<std::pair<typename LCC::Dart_descriptor, std::vector<std::size_t> > >& face_to_points) { void map_points_to_faces(const std::size_t polygon_index, const std::vector<Point_3>& pts, std::vector<std::pair<typename LCC::Dart_descriptor, std::vector<std::size_t> > >& face_to_points) {
std::vector<Index> faces; std::vector<Index> faces;

View File

@ -19,7 +19,7 @@ if(Boost_FOUND)
message(STATUS "Found Eigen") message(STATUS "Found Eigen")
include(CGAL_Eigen_support) include(CGAL_Eigen_support)
set(targets ksr_test) set(targets ksr_test ksr_reorientation ksr_regularization)
set(project_linked_libraries) set(project_linked_libraries)
set(project_compilation_definitions) set(project_compilation_definitions)

View File

@ -0,0 +1,56 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Kinetic_surface_reconstruction_3.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Point_set_3/IO.h>
#include <CGAL/IO/polygon_soup_io.h>
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using FT = typename Kernel::FT;
using Point_3 = typename Kernel::Point_3;
using Vector_3 = typename Kernel::Vector_3;
using Segment_3 = typename Kernel::Segment_3;
using Point_set = CGAL::Point_set_3<Point_3>;
using Point_map = typename Point_set::Point_map;
using Normal_map = typename Point_set::Vector_map;
using KSR = CGAL::Kinetic_surface_reconstruction_3<Kernel, Point_set, Point_map, Normal_map>;
int main(const int argc, const char** argv) {
// Input.
Point_set point_set;
CGAL::IO::read_point_set("hilbert_cube.ply", point_set);
auto with_reg = CGAL::parameters::maximum_distance(0.1)
.maximum_angle(10)
.k_neighbors(12)
.minimum_region_size(10)
.regularize_coplanarity(true)
.regularize_parallelism(true)
.maximum_offset(0.1)
.angle_tolerance(10)
.debug(true);
auto without_reg = CGAL::parameters::maximum_distance(0.1)
.maximum_angle(10)
.k_neighbors(12)
.minimum_region_size(10)
.regularize_coplanarity(false)
.regularize_parallelism(false);
// Algorithm.
KSR ksr(point_set);
ksr.detect_planar_shapes(without_reg);
std::size_t detected = ksr.detected_planar_shapes().size();
ksr.detect_planar_shapes(with_reg);
std::size_t regularized = ksr.detected_planar_shapes().size();
std::cout << detected << " planar shapes regularized into " << regularized << std::endl;
return regularized < detected ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -0,0 +1,52 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Kinetic_surface_reconstruction_3.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Point_set_3/IO.h>
#include <CGAL/IO/polygon_soup_io.h>
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using FT = typename Kernel::FT;
using Point_3 = typename Kernel::Point_3;
using Vector_3 = typename Kernel::Vector_3;
using Segment_3 = typename Kernel::Segment_3;
using Point_set = CGAL::Point_set_3<Point_3>;
using Point_map = typename Point_set::Point_map;
using Normal_map = typename Point_set::Vector_map;
using KSR = CGAL::Kinetic_surface_reconstruction_3<Kernel, Point_set, Point_map, Normal_map>;
int main(const int argc, const char** argv) {
// Input.
Point_set point_set;
CGAL::IO::read_point_set("Cottage_cut.ply", point_set);
auto param = CGAL::parameters::maximum_distance(0.33)
.maximum_angle(32)
.k_neighbors(12)
.minimum_region_size(330)
.reorient_bbox(false);
// Algorithm.
KSR ksr(point_set, param);
ksr.detection_and_partition(1, param);
std::vector<Point_3> vtx;
std::vector<std::vector<std::size_t> > polylist;
bool failed = false;
ksr.reconstruct_with_ground(0.5, std::back_inserter(vtx), std::back_inserter(polylist));
if (vtx.size() != 314 && polylist.size() != 91) {
std::cerr << "reconstruction with reorientation and ground estimation set to outside provided wrong result: #vtx " << vtx.size() << " expected: 314, #polys: " << polylist.size() << " expected: 91" << std::endl;
failed = true;
}
if (!failed)
std::cout << "done!";
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
}

View File

@ -25,13 +25,18 @@ int main(const int argc, const char** argv) {
auto param = CGAL::parameters::maximum_distance(0.05) auto param = CGAL::parameters::maximum_distance(0.05)
.maximum_angle(10) .maximum_angle(10)
.k_neighbors(12) .k_neighbors(12)
.minimum_region_size(50); .minimum_region_size(50)
.regularize_coplanarity(true)
.regularize_parallelism(true)
.maximum_offset(0.1);
// Algorithm. // Algorithm.
KSR ksr(point_set, param); KSR ksr(point_set, param);
ksr.detection_and_partition(1, param); ksr.detection_and_partition(1, param);
std::cout << ksr.detected_planar_shapes().size() << " planar shapes" << std::endl;
std::vector<Point_3> vtx; std::vector<Point_3> vtx;
std::vector<std::vector<std::size_t> > polylist; std::vector<std::vector<std::size_t> > polylist;
@ -66,5 +71,8 @@ int main(const int argc, const char** argv) {
failed = true; failed = true;
} }
if (!failed)
std::cout << "done!";
return failed ? EXIT_FAILURE : EXIT_SUCCESS; return failed ? EXIT_FAILURE : EXIT_SUCCESS;
} }