mirror of https://github.com/CGAL/cgal
adding more tests
This commit is contained in:
parent
06ffd9a86c
commit
dabc8ff85c
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -705,7 +705,8 @@ private:
|
||||||
collect_points_for_faces_lcc();
|
collect_points_for_faces_lcc();
|
||||||
count_volume_votes_lcc();
|
count_volume_votes_lcc();
|
||||||
|
|
||||||
std::cout << "* computing data term ... ";
|
if (m_verbose)
|
||||||
|
std::cout << "* computing data term ... ";
|
||||||
|
|
||||||
std::size_t max_inside = 0, max_outside = 0;
|
std::size_t max_inside = 0, max_outside = 0;
|
||||||
for (std::size_t i = 0; i < m_volumes.size(); i++) {
|
for (std::size_t i = 0; i < m_volumes.size(); i++) {
|
||||||
|
|
@ -1869,47 +1870,50 @@ 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)() };
|
FT bbox_max[] = { -(std::numeric_limits<FT>::max)(), -(std::numeric_limits<FT>::max)(), -(std::numeric_limits<FT>::max)() };
|
||||||
FT bbox_max[] = { -(std::numeric_limits<FT>::max)(), -(std::numeric_limits<FT>::max)(), -(std::numeric_limits<FT>::max)() };
|
for (const auto& p : m_points) {
|
||||||
for (const auto& p : m_points) {
|
const auto& point = get(m_point_map, p);
|
||||||
const auto& point = get(m_point_map, p);
|
for (std::size_t i = 0; i < 3; i++) {
|
||||||
for (std::size_t i = 0; i < 3; i++) {
|
bbox_min[i] = (std::min)(point[i], bbox_min[i]);
|
||||||
bbox_min[i] = (std::min)(point[i], bbox_min[i]);
|
bbox_max[i] = (std::max)(point[i], bbox_max[i]);
|
||||||
bbox_max[i] = (std::max)(point[i], bbox_max[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FT bbox_center[] = { 0.5 * (bbox_min[0] + bbox_max[0]), 0.5 * (bbox_min[1] + bbox_max[1]), 0.5 * (bbox_min[2] + bbox_max[2]) };
|
FT bbox_center[] = { 0.5 * (bbox_min[0] + bbox_max[0]), 0.5 * (bbox_min[1] + bbox_max[1]), 0.5 * (bbox_min[2] + bbox_max[2]) };
|
||||||
|
|
||||||
for (std::size_t i = 0; i < m_regions.size(); i++) {
|
for (std::size_t i = 0; i < m_regions.size(); i++) {
|
||||||
Vector_3 d = m_regions[i].first.orthogonal_vector();
|
Vector_3 d = m_regions[i].first.orthogonal_vector();
|
||||||
if (abs(d.z()) > 0.98) {
|
if (abs(d.z()) > 0.98) {
|
||||||
candidates.push_back(i);
|
candidates.push_back(i);
|
||||||
FT z = m_regions[i].first.projection(Point_3(bbox_center[0], bbox_center[1], bbox_center[2])).z();
|
FT z = m_regions[i].first.projection(Point_3(bbox_center[0], bbox_center[1], bbox_center[2])).z();
|
||||||
low_z_peak = (std::min<FT>)(z, low_z_peak);
|
low_z_peak = (std::min<FT>)(z, low_z_peak);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_ground_polygon_index = -1;
|
m_ground_polygon_index = -1;
|
||||||
std::vector<std::size_t> other_ground;
|
std::vector<std::size_t> other_ground;
|
||||||
for (std::size_t i = 0; i < candidates.size(); i++) {
|
for (std::size_t i = 0; i < candidates.size(); i++) {
|
||||||
Vector_3 d = m_regions[candidates[i]].first.orthogonal_vector();
|
Vector_3 d = m_regions[candidates[i]].first.orthogonal_vector();
|
||||||
FT z = m_regions[candidates[i]].first.projection(Point_3(bbox_center[0], bbox_center[1], bbox_center[2])).z();
|
FT z = m_regions[candidates[i]].first.projection(Point_3(bbox_center[0], bbox_center[1], bbox_center[2])).z();
|
||||||
if (z - low_z_peak < max_distance_to_plane) {
|
if (z - low_z_peak < max_distance_to_plane) {
|
||||||
if (m_ground_polygon_index == -1)
|
if (m_ground_polygon_index == -1)
|
||||||
m_ground_polygon_index = candidates[i];
|
m_ground_polygon_index = candidates[i];
|
||||||
else
|
else
|
||||||
other_ground.push_back(candidates[i]);
|
other_ground.push_back(candidates[i]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
std::cout << "ground polygon " << m_ground_polygon_index << ", merging other polygons";
|
if (m_verbose)
|
||||||
|
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,7 +1945,8 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
KSP_3::internal::dump_polygons(polys_debug, "merged-" + std::to_string(m_regions.size()) + "-polygons.ply");
|
if (m_debug)
|
||||||
|
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,8 +1975,10 @@ private:
|
||||||
}
|
}
|
||||||
CGAL_assertion(m_planar_regions.size() == m_regions.size());
|
CGAL_assertion(m_planar_regions.size() == m_regions.size());
|
||||||
|
|
||||||
std::cout << "found " << num_shapes << " planar shapes regularized into " << m_planar_regions.size() << std::endl;
|
if (m_verbose) {
|
||||||
std::cout << "from " << m_points.size() << " input points " << unassigned << " remain unassigned" << 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue