mirror of https://github.com/CGAL/cgal
more precise tests, point set free function, better plane detection on points
This commit is contained in:
parent
664bc73149
commit
793037c3d7
|
|
@ -10,15 +10,15 @@ using Vector_3 = typename Kernel::Vector_3;
|
|||
int main() {
|
||||
|
||||
const std::vector< std::pair<Point_3, Vector_3> > points_with_normals = {
|
||||
std::make_pair(Point_3(0.1, 0.0, 0.0), Vector_3(0.1, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.5, 0.0, 0.0), Vector_3(0.5, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.9, 0.0, 0.0), Vector_3(0.9, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.1, 1.0, 0.0), Vector_3(0.1, 1.0, 1.0)),
|
||||
std::make_pair(Point_3(0.5, 1.0, 0.0), Vector_3(0.5, 1.0, 1.0)),
|
||||
std::make_pair(Point_3(0.9, 1.0, 0.0), Vector_3(0.9, 1.0, 1.0)),
|
||||
std::make_pair(Point_3(0.1, 2.0, 0.0), Vector_3(0.1, 2.0, 1.0)),
|
||||
std::make_pair(Point_3(0.5, 2.0, 0.0), Vector_3(0.5, 2.0, 1.0)),
|
||||
std::make_pair(Point_3(0.9, 2.0, 0.0), Vector_3(0.9, 2.0, 1.0))
|
||||
std::make_pair(Point_3(0.1, 0.0, 0.0), Vector_3(0.0, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.5, 0.0, 0.0), Vector_3(0.0, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.9, 0.0, 0.0), Vector_3(0.0, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.1, 1.0, 0.0), Vector_3(0.0, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.5, 1.0, 0.0), Vector_3(0.0, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.9, 1.0, 0.0), Vector_3(0.0, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.1, 2.0, 0.0), Vector_3(0.0, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.5, 2.0, 0.0), Vector_3(0.0, 0.0, 1.0)),
|
||||
std::make_pair(Point_3(0.9, 2.0, 0.0), Vector_3(0.0, 0.0, 1.0))
|
||||
};
|
||||
|
||||
std::cout << "* number of input pairs: " << points_with_normals.size() << std::endl;
|
||||
|
|
@ -26,9 +26,12 @@ int main() {
|
|||
|
||||
std::vector< std::vector<std::size_t> > regions;
|
||||
CGAL::Shape_detection::region_growing_planes(
|
||||
points_with_normals, std::back_inserter(regions), CGAL::parameters::neighbor_radius(1.5));
|
||||
points_with_normals, std::back_inserter(regions));
|
||||
|
||||
std::cout << "* number of found planar regions: " << regions.size() << std::endl;
|
||||
assert(regions.size() == 1);
|
||||
std::cout << "* number of points in the region: " << regions[0].size() << std::endl;
|
||||
assert(regions[0].size() == 9);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,13 +39,13 @@ namespace Shape_detection {
|
|||
- the `SeedMap` property map enables to define the seeding order of items and skip unnecessary items.
|
||||
|
||||
\tparam InputRange
|
||||
a model of `ConstRange`.
|
||||
a model of `ConstRange`
|
||||
|
||||
\tparam NeighborQuery
|
||||
a model of `NeighborQuery`.
|
||||
a model of `NeighborQuery`
|
||||
|
||||
\tparam RegionType
|
||||
a model of `RegionType`.
|
||||
a model of `RegionType`
|
||||
|
||||
\tparam SeedMap
|
||||
a model of `ReadablePropertyMap` whose key and value types are `std::size_t`.
|
||||
|
|
@ -120,7 +120,7 @@ namespace Shape_detection {
|
|||
with the found regions.
|
||||
|
||||
\tparam OutputIterator
|
||||
must be an output iterator whose value type is `std::vector<std::size_t>`.
|
||||
a model of output iterator whose value type is `std::vector<std::size_t>`
|
||||
|
||||
\param regions
|
||||
an output iterator that stores regions, where each region is returned
|
||||
|
|
@ -168,7 +168,7 @@ namespace Shape_detection {
|
|||
\brief fills an output iterator with indices of all unassigned items.
|
||||
|
||||
\tparam OutputIterator
|
||||
must be an output iterator whose value type is `std::size_t`.
|
||||
a model of output iterator whose value type is `std::size_t`
|
||||
|
||||
\param output
|
||||
an output iterator that stores indices of all items, which are not assigned
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#include <CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_line_fit_sorting.h>
|
||||
#include <CGAL/Shape_detection/Region_growing/Region_growing_on_point_set/Least_squares_plane_fit_sorting.h>
|
||||
|
||||
#include <CGAL/Point_set_3.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Shape_detection {
|
||||
|
||||
|
|
@ -42,7 +44,7 @@ OutputIterator region_growing_lines(
|
|||
using Point_map = CGAL::First_of_pair_property_map<Point_with_normal>;
|
||||
using Normal_map = CGAL::Second_of_pair_property_map<Point_with_normal>;
|
||||
|
||||
using Neighbor_query = Point_set::Sphere_neighbor_query<Traits, Input_range, Point_map>;
|
||||
using Neighbor_query = Point_set::K_neighbor_query<Traits, Input_range, Point_map>;
|
||||
using Region_type = Point_set::Least_squares_line_fit_region<Traits, Input_range, Point_map, Normal_map>;
|
||||
using Sorting = Point_set::Least_squares_line_fit_sorting<Traits, Input_range, Neighbor_query, Point_map>;
|
||||
using Region_growing = Region_growing<Input_range, Neighbor_query, Region_type, typename Sorting::Seed_map>;
|
||||
|
|
@ -82,7 +84,7 @@ OutputIterator region_growing_planes(
|
|||
using Point_map = CGAL::First_of_pair_property_map<Point_with_normal>;
|
||||
using Normal_map = CGAL::Second_of_pair_property_map<Point_with_normal>;
|
||||
|
||||
using Neighbor_query = Point_set::Sphere_neighbor_query<Traits, Input_range, Point_map>;
|
||||
using Neighbor_query = Point_set::K_neighbor_query<Traits, Input_range, Point_map>;
|
||||
using Region_type = Point_set::Least_squares_plane_fit_region<Traits, Input_range, Point_map, Normal_map>;
|
||||
using Sorting = Point_set::Least_squares_plane_fit_sorting<Traits, Input_range, Neighbor_query, Point_map>;
|
||||
using Region_growing = Region_growing<Input_range, Neighbor_query, Region_type, typename Sorting::Seed_map>;
|
||||
|
|
@ -108,6 +110,50 @@ OutputIterator region_growing_planes(
|
|||
points_with_normals, regions, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
template<
|
||||
typename PointType,
|
||||
typename VectorType,
|
||||
typename OutputIterator,
|
||||
typename NamedParameters>
|
||||
OutputIterator region_growing_planes(
|
||||
const CGAL::Point_set_3<PointType, VectorType>& point_set, OutputIterator regions, const NamedParameters& np) {
|
||||
|
||||
using Point_type = PointType;
|
||||
using Vector_type = VectorType;
|
||||
using Traits = typename Kernel_traits<Point_type>::Kernel;
|
||||
using Point_set_3 = CGAL::Point_set_3<Point_type, Vector_type>;
|
||||
using Point_map = typename Point_set_3::Point_map;
|
||||
using Normal_map = typename Point_set_3::Vector_map;
|
||||
|
||||
using Neighbor_query = Point_set::K_neighbor_query<Traits, Point_set_3, Point_map>;
|
||||
using Region_type = Point_set::Least_squares_plane_fit_region<Traits, Point_set_3, Point_map, Normal_map>;
|
||||
using Sorting = Point_set::Least_squares_plane_fit_sorting<Traits, Point_set_3, Neighbor_query, Point_map>;
|
||||
using Region_growing = Region_growing<Point_set_3, Neighbor_query, Region_type, typename Sorting::Seed_map>;
|
||||
|
||||
CGAL_precondition(point_set.has_normal_map());
|
||||
Neighbor_query neighbor_query(point_set, np, Point_map());
|
||||
Region_type region_type(point_set, np, Point_map(), Normal_map());
|
||||
Sorting sorting(point_set, neighbor_query, Point_map());
|
||||
sorting.sort();
|
||||
|
||||
Region_growing region_growing(
|
||||
point_set, neighbor_query, region_type, sorting.seed_map());
|
||||
region_growing.detect(regions);
|
||||
return regions;
|
||||
}
|
||||
|
||||
template<
|
||||
typename PointType,
|
||||
typename VectorType,
|
||||
typename OutputIterator,
|
||||
typename NamedParameters>
|
||||
OutputIterator region_growing_planes(
|
||||
const CGAL::Point_set_3<PointType, VectorType>& point_set, OutputIterator regions) {
|
||||
|
||||
return region_growing_planes(
|
||||
point_set, regions, CGAL::parameters::all_default());
|
||||
}
|
||||
|
||||
} // namespace Shape_detection
|
||||
} // namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -258,7 +258,8 @@ namespace Point_set {
|
|||
m_normal_of_best_fit = m_plane_of_best_fit.orthogonal_vector();
|
||||
|
||||
} else { // update reference plane and normal
|
||||
CGAL_precondition(region.size() >= 2);
|
||||
if (region.size() <= 3) return;
|
||||
CGAL_precondition(region.size() >= 3);
|
||||
std::tie(m_plane_of_best_fit, m_normal_of_best_fit) =
|
||||
get_plane_and_normal(region);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,8 +74,9 @@ typename NamedParameters>
|
|||
OutputIterator region_growing_planes(
|
||||
const CGAL::Surface_mesh<PointType>& surface_mesh, OutputIterator regions, const NamedParameters& np) {
|
||||
|
||||
using Traits = typename Kernel_traits<PointType>::Kernel;
|
||||
using Surface_mesh = CGAL::Surface_mesh<PointType>;
|
||||
using Point_type = PointType;
|
||||
using Traits = typename Kernel_traits<Point_type>::Kernel;
|
||||
using Surface_mesh = CGAL::Surface_mesh<Point_type>;
|
||||
using Face_range = typename Surface_mesh::Face_range;
|
||||
using Neighbor_query = Polygon_mesh::One_ring_neighbor_query<Surface_mesh>;
|
||||
using Region_type = Polygon_mesh::Least_squares_plane_fit_region<Traits, Surface_mesh>;
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ namespace Polyline {
|
|||
const Point& input_point = get(m_point_map, key1);
|
||||
const Point& query_point = get(m_point_map, key2);
|
||||
|
||||
if (region.size() == 1) {
|
||||
if (region.size() == 1) { // update new reference line and direction
|
||||
CGAL_precondition(input_point != query_point);
|
||||
m_line_of_best_fit = Line(input_point, query_point);
|
||||
m_direction_of_best_fit = m_line_of_best_fit.to_vector();
|
||||
|
|
@ -157,15 +157,15 @@ namespace Polyline {
|
|||
|
||||
void update(const std::vector<std::size_t>& region) {
|
||||
|
||||
if (region.size() < 2) {
|
||||
CGAL_precondition(region.size() > 0);
|
||||
if (region.size() == 1) { // create new reference line and direction
|
||||
m_line_of_best_fit = Line();
|
||||
m_direction_of_best_fit = Vector();
|
||||
return;
|
||||
} else { // update reference line and direction
|
||||
CGAL_precondition(region.size() >= 2);
|
||||
std::tie(m_line_of_best_fit, m_direction_of_best_fit) =
|
||||
get_line_and_direction(region);
|
||||
}
|
||||
|
||||
CGAL_precondition(region.size() >= 2);
|
||||
std::tie(m_line_of_best_fit, m_direction_of_best_fit) =
|
||||
get_line_and_direction(region);
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ find_package(Eigen3 3.1.0 QUIET) # (3.1.0 or greater)
|
|||
include(CGAL_Eigen3_support)
|
||||
if(EIGEN3_FOUND)
|
||||
create_single_source_cgal_program("test_region_growing_basic.cpp")
|
||||
# create_single_source_cgal_program("test_region_growing_strict.cpp")
|
||||
create_single_source_cgal_program("test_region_growing_on_cube.cpp")
|
||||
create_single_source_cgal_program("test_region_growing_on_point_set_2.cpp")
|
||||
create_single_source_cgal_program("test_region_growing_on_point_set_3.cpp")
|
||||
|
|
@ -27,6 +28,7 @@ if(EIGEN3_FOUND)
|
|||
foreach(
|
||||
target
|
||||
test_region_growing_basic
|
||||
# test_region_growing_strict
|
||||
test_region_growing_on_cube
|
||||
test_region_growing_on_point_set_2
|
||||
test_region_growing_on_point_set_3
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ bool test_region_growing_on_cube(int argc, char *argv[]) {
|
|||
|
||||
using Neighbor_query = SD::Polygon_mesh::One_ring_neighbor_query<Polyhedron, Face_range>;
|
||||
using Region_type = SD::Polygon_mesh::Least_squares_plane_fit_region<Kernel, Polyhedron, Face_range>;
|
||||
using Region_growing = SD::Region_growing<Face_range, Neighbor_query, Region_type>;
|
||||
using Sorting = SD::Polygon_mesh::Least_squares_plane_fit_sorting<Kernel, Polyhedron, Neighbor_query, Face_range>;
|
||||
using Region_growing = SD::Region_growing<Face_range, Neighbor_query, Region_type, typename Sorting::Seed_map>;
|
||||
|
||||
// Default parameter values for the data file cube.off.
|
||||
const FT distance_threshold = FT(1) / FT(10);
|
||||
|
|
@ -59,9 +60,14 @@ bool test_region_growing_on_cube(int argc, char *argv[]) {
|
|||
angle_deg_threshold(angle_threshold).
|
||||
min_region_size(min_region_size));
|
||||
|
||||
// Sort indices.
|
||||
Sorting sorting(
|
||||
polyhedron, neighbor_query);
|
||||
sorting.sort();
|
||||
|
||||
// Run region growing.
|
||||
Region_growing region_growing(
|
||||
face_range, neighbor_query, region_type);
|
||||
face_range, neighbor_query, region_type, sorting.seed_map());
|
||||
|
||||
std::vector< std::vector<std::size_t> > regions;
|
||||
region_growing.detect(std::back_inserter(regions));
|
||||
|
|
@ -72,38 +78,43 @@ bool test_region_growing_on_cube(int argc, char *argv[]) {
|
|||
std::vector<std::size_t> unassigned_faces;
|
||||
region_growing.unassigned_items(std::back_inserter(unassigned_faces));
|
||||
assert(unassigned_faces.size() == 0);
|
||||
|
||||
// test free function
|
||||
// test randomness
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// ------>
|
||||
|
||||
bool cartesian_double_test_success = true;
|
||||
if (!test_region_growing_on_cube< CGAL::Simple_cartesian<double> >(argc, argv))
|
||||
cartesian_double_test_success = false;
|
||||
|
||||
std::cout << "rg_cube, cartesian_test_success: " << cartesian_double_test_success << std::endl;
|
||||
assert(cartesian_double_test_success);
|
||||
using SC = CGAL::Simple_cartesian<double>;
|
||||
using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using EPECK = CGAL::Exact_predicates_exact_constructions_kernel;
|
||||
|
||||
// ------>
|
||||
|
||||
bool exact_inexact_test_success = true;
|
||||
if (!test_region_growing_on_cube<CGAL::Exact_predicates_inexact_constructions_kernel>(argc, argv))
|
||||
exact_inexact_test_success = false;
|
||||
|
||||
std::cout << "rg_cube, epick_test_success: " << exact_inexact_test_success << std::endl;
|
||||
assert(exact_inexact_test_success);
|
||||
bool sc_test_success = true;
|
||||
if (!test_region_growing_on_cube<SC>(argc, argv))
|
||||
sc_test_success = false;
|
||||
std::cout << "rg_cube, sc_test_success: " << sc_test_success << std::endl;
|
||||
assert(sc_test_success);
|
||||
|
||||
// ------>
|
||||
|
||||
bool exact_exact_test_success = true;
|
||||
if (!test_region_growing_on_cube<CGAL::Exact_predicates_exact_constructions_kernel>(argc, argv))
|
||||
exact_exact_test_success = false;
|
||||
bool epick_test_success = true;
|
||||
if (!test_region_growing_on_cube<EPICK>(argc, argv))
|
||||
epick_test_success = false;
|
||||
std::cout << "rg_cube, epick_test_success: " << epick_test_success << std::endl;
|
||||
assert(epick_test_success);
|
||||
|
||||
std::cout << "rg_cube, epeck_test_success: " << exact_exact_test_success << std::endl;
|
||||
assert(exact_exact_test_success);
|
||||
// ------>
|
||||
|
||||
const bool success = cartesian_double_test_success && exact_inexact_test_success && exact_exact_test_success;
|
||||
bool epeck_test_success = true;
|
||||
if (!test_region_growing_on_cube<EPECK>(argc, argv))
|
||||
epeck_test_success = false;
|
||||
std::cout << "rg_cube, epeck_test_success: " << epeck_test_success << std::endl;
|
||||
assert(epeck_test_success);
|
||||
|
||||
const bool success = sc_test_success && epick_test_success && epeck_test_success;
|
||||
return (success) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,46 +70,47 @@ bool test_region_growing_on_degenerated_mesh(int argc, char *argv[]) {
|
|||
std::vector< std::vector<std::size_t> > regions;
|
||||
region_growing.detect(std::back_inserter(regions));
|
||||
// std::cout << regions.size() << std::endl;
|
||||
assert(regions.size() >= 260 && regions.size() <= 264);
|
||||
assert(regions.size() == 262);
|
||||
for (const auto& region : regions)
|
||||
assert(region_type.is_valid_region(region));
|
||||
|
||||
std::vector<std::size_t> unassigned_faces;
|
||||
region_growing.unassigned_items(std::back_inserter(unassigned_faces));
|
||||
// std::cout << unassigned_faces.size() << std::endl;
|
||||
assert(unassigned_faces.size() >= 493 && unassigned_faces.size() <= 513);
|
||||
assert(unassigned_faces.size() == 503);
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// ------>
|
||||
|
||||
bool cartesian_double_test_success = true;
|
||||
if (!test_region_growing_on_degenerated_mesh< CGAL::Simple_cartesian<double> >(argc, argv))
|
||||
cartesian_double_test_success = false;
|
||||
|
||||
std::cout << "rg_degmesh, cartesian_test_success: " << cartesian_double_test_success << std::endl;
|
||||
assert(cartesian_double_test_success);
|
||||
using SC = CGAL::Simple_cartesian<double>;
|
||||
using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using EPECK = CGAL::Exact_predicates_exact_constructions_kernel;
|
||||
|
||||
// ------>
|
||||
|
||||
bool exact_inexact_test_success = true;
|
||||
if (!test_region_growing_on_degenerated_mesh<CGAL::Exact_predicates_inexact_constructions_kernel>(argc, argv))
|
||||
exact_inexact_test_success = false;
|
||||
|
||||
std::cout << "rg_degmesh, epick_test_success: " << exact_inexact_test_success << std::endl;
|
||||
assert(exact_inexact_test_success);
|
||||
bool sc_test_success = true;
|
||||
if (!test_region_growing_on_degenerated_mesh<SC>(argc, argv))
|
||||
sc_test_success = false;
|
||||
std::cout << "rg_degmesh, sc_test_success: " << sc_test_success << std::endl;
|
||||
assert(sc_test_success);
|
||||
|
||||
// ------>
|
||||
|
||||
bool exact_exact_test_success = true;
|
||||
if (!test_region_growing_on_degenerated_mesh<CGAL::Exact_predicates_exact_constructions_kernel>(argc, argv))
|
||||
exact_exact_test_success = false;
|
||||
bool epick_test_success = true;
|
||||
if (!test_region_growing_on_degenerated_mesh<EPICK>(argc, argv))
|
||||
epick_test_success = false;
|
||||
std::cout << "rg_degmesh, epick_test_success: " << epick_test_success << std::endl;
|
||||
assert(epick_test_success);
|
||||
|
||||
std::cout << "rg_degmesh, epeck_test_success: " << exact_exact_test_success << std::endl;
|
||||
assert(exact_exact_test_success);
|
||||
// ------>
|
||||
|
||||
const bool success = cartesian_double_test_success && exact_inexact_test_success && exact_exact_test_success;
|
||||
bool epeck_test_success = true;
|
||||
if (!test_region_growing_on_degenerated_mesh<EPECK>(argc, argv))
|
||||
epeck_test_success = false;
|
||||
std::cout << "rg_degmesh, epeck_test_success: " << epeck_test_success << std::endl;
|
||||
assert(epeck_test_success);
|
||||
|
||||
const bool success = sc_test_success && epick_test_success && epeck_test_success;
|
||||
return (success) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,46 +72,47 @@ bool test_region_growing_on_point_set_2(int argc, char *argv[]) {
|
|||
std::vector< std::vector<std::size_t> > regions;
|
||||
region_growing.detect(std::back_inserter(regions));
|
||||
// std::cout << regions.size() << std::endl;
|
||||
assert(regions.size() >= 63 && regions.size() <= 67);
|
||||
assert(regions.size() == 65);
|
||||
for (const auto& region : regions)
|
||||
assert(region_type.is_valid_region(region));
|
||||
|
||||
std::vector<std::size_t> unassigned_points;
|
||||
region_growing.unassigned_items(std::back_inserter(unassigned_points));
|
||||
// std::cout << unassigned_points.size() << std::endl;
|
||||
assert(unassigned_points.size() >= 77 && unassigned_points.size() <= 97);
|
||||
assert(unassigned_points.size() == 87);
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// ------>
|
||||
|
||||
bool cartesian_double_test_success = true;
|
||||
if (!test_region_growing_on_point_set_2< CGAL::Simple_cartesian<double> >(argc, argv))
|
||||
cartesian_double_test_success = false;
|
||||
|
||||
std::cout << "rg_points2, cartesian_test_success: " << cartesian_double_test_success << std::endl;
|
||||
assert(cartesian_double_test_success);
|
||||
using SC = CGAL::Simple_cartesian<double>;
|
||||
using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using EPECK = CGAL::Exact_predicates_exact_constructions_kernel;
|
||||
|
||||
// ------>
|
||||
|
||||
bool exact_inexact_test_success = true;
|
||||
if (!test_region_growing_on_point_set_2<CGAL::Exact_predicates_inexact_constructions_kernel>(argc, argv))
|
||||
exact_inexact_test_success = false;
|
||||
|
||||
std::cout << "rg_points2, epick_test_success: " << exact_inexact_test_success << std::endl;
|
||||
assert(exact_inexact_test_success);
|
||||
bool sc_test_success = true;
|
||||
if (!test_region_growing_on_point_set_2<SC>(argc, argv))
|
||||
sc_test_success = false;
|
||||
std::cout << "rg_points2, sc_test_success: " << sc_test_success << std::endl;
|
||||
assert(sc_test_success);
|
||||
|
||||
// ------>
|
||||
|
||||
bool exact_exact_test_success = true;
|
||||
if (!test_region_growing_on_point_set_2<CGAL::Exact_predicates_exact_constructions_kernel>(argc, argv))
|
||||
exact_exact_test_success = false;
|
||||
bool epick_test_success = true;
|
||||
if (!test_region_growing_on_point_set_2<EPICK>(argc, argv))
|
||||
epick_test_success = false;
|
||||
std::cout << "rg_points2, epick_test_success: " << epick_test_success << std::endl;
|
||||
assert(epick_test_success);
|
||||
|
||||
std::cout << "rg_points2, epeck_test_success: " << exact_exact_test_success << std::endl;
|
||||
assert(exact_exact_test_success);
|
||||
// ------>
|
||||
|
||||
const bool success = cartesian_double_test_success && exact_inexact_test_success && exact_exact_test_success;
|
||||
bool epeck_test_success = true;
|
||||
if (!test_region_growing_on_point_set_2<EPECK>(argc, argv))
|
||||
epeck_test_success = false;
|
||||
std::cout << "rg_points2, epeck_test_success: " << epeck_test_success << std::endl;
|
||||
assert(epeck_test_success);
|
||||
|
||||
const bool success = sc_test_success && epick_test_success && epeck_test_success;
|
||||
return (success) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,15 +72,18 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// Create an instance of the region growing class.
|
||||
Region_growing region_growing(
|
||||
input_range, neighbor_query, region_type,
|
||||
sorting.seed_map());
|
||||
input_range, neighbor_query, region_type, sorting.seed_map());
|
||||
|
||||
// Run the algorithm.
|
||||
std::vector< std::vector<std::size_t> > regions;
|
||||
region_growing.detect(std::back_inserter(regions));
|
||||
region_growing.release_memory();
|
||||
// std::cout << regions.size() << std::endl;
|
||||
assert(regions.size() >= 60 && regions.size() <= 64);
|
||||
std::cout << "rg_sortpoints2, cartesian_test_success: " << true << std::endl;
|
||||
assert(regions.size() == 62);
|
||||
|
||||
// test free function
|
||||
// test randomness
|
||||
|
||||
std::cout << "rg_sortpoints2, sc_test_success: " << true << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Shape_detection/Region_growing/Region_growing.h>
|
||||
#include <CGAL/Shape_detection/Region_growing/Region_growing_on_point_set.h>
|
||||
|
|
@ -36,7 +37,7 @@ bool test_region_growing_on_point_set_3(int argc, char *argv[]) {
|
|||
using Region_growing = SD::Region_growing<Input_range, Neighbor_query, Region_type>;
|
||||
|
||||
// Default parameter values for the data file point_set_3.xyz.
|
||||
const FT sphere_radius = FT(5);
|
||||
const FT sphere_radius = FT(5) / FT(100);
|
||||
const FT distance_threshold = FT(2);
|
||||
const FT angle_threshold = FT(20);
|
||||
const std::size_t min_region_size = 50;
|
||||
|
|
@ -72,37 +73,47 @@ bool test_region_growing_on_point_set_3(int argc, char *argv[]) {
|
|||
std::vector< std::vector<std::size_t> > regions;
|
||||
region_growing.detect(std::back_inserter(regions));
|
||||
// std::cout << regions.size() << std::endl;
|
||||
assert(regions.size() >= 7 && regions.size() <= 9);
|
||||
assert(regions.size() == 9);
|
||||
for (const auto& region : regions)
|
||||
assert(region_type.is_valid_region(region));
|
||||
|
||||
std::vector<std::size_t> unassigned_points;
|
||||
region_growing.unassigned_items(std::back_inserter(unassigned_points));
|
||||
// std::cout << unassigned_points.size() << std::endl;
|
||||
assert(unassigned_points.size() >= 49 && unassigned_points.size() <= 69);
|
||||
assert(unassigned_points.size() == 196);
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// ------>
|
||||
|
||||
bool cartesian_double_test_success = true;
|
||||
if (!test_region_growing_on_point_set_3< CGAL::Simple_cartesian<double> >(argc, argv))
|
||||
cartesian_double_test_success = false;
|
||||
|
||||
std::cout << "rg_points3, cartesian_test_success: " << cartesian_double_test_success << std::endl;
|
||||
assert(cartesian_double_test_success);
|
||||
using SC = CGAL::Simple_cartesian<double>;
|
||||
using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
|
||||
// ------>
|
||||
|
||||
bool exact_inexact_test_success = true;
|
||||
if (!test_region_growing_on_point_set_3<CGAL::Exact_predicates_inexact_constructions_kernel>(argc, argv))
|
||||
exact_inexact_test_success = false;
|
||||
bool sc_test_success = true;
|
||||
if (!test_region_growing_on_point_set_3<SC>(argc, argv))
|
||||
sc_test_success = false;
|
||||
std::cout << "rg_points3, sc_test_success: " << sc_test_success << std::endl;
|
||||
assert(sc_test_success);
|
||||
|
||||
std::cout << "rg_points3, epick_test_success: " << exact_inexact_test_success << std::endl;
|
||||
assert(exact_inexact_test_success);
|
||||
// ------>
|
||||
|
||||
const bool success = cartesian_double_test_success && exact_inexact_test_success;
|
||||
bool epick_test_success = true;
|
||||
if (!test_region_growing_on_point_set_3<EPICK>(argc, argv))
|
||||
epick_test_success = false;
|
||||
std::cout << "rg_points3, epick_test_success: " << epick_test_success << std::endl;
|
||||
assert(epick_test_success);
|
||||
|
||||
// ------>
|
||||
|
||||
bool epeck_test_success = true; // turn it off, very slow
|
||||
// using EPECK = CGAL::Exact_predicates_exact_constructions_kernel;
|
||||
// if (!test_region_growing_on_point_set_3<EPECK>(argc, argv))
|
||||
// epeck_test_success = false;
|
||||
// std::cout << "rg_points3, epeck_test_success: " << epeck_test_success << std::endl;
|
||||
// assert(epeck_test_success);
|
||||
|
||||
const bool success = sc_test_success && epick_test_success && epeck_test_success;
|
||||
return (success) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,21 +67,19 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// Sort indices.
|
||||
Sorting sorting(
|
||||
input_range, neighbor_query,
|
||||
input_range.point_map());
|
||||
input_range, neighbor_query, input_range.point_map());
|
||||
sorting.sort();
|
||||
|
||||
// Create an instance of the region growing class.
|
||||
Region_growing region_growing(
|
||||
input_range, neighbor_query, region_type,
|
||||
sorting.seed_map());
|
||||
input_range, neighbor_query, region_type, sorting.seed_map());
|
||||
|
||||
// Run the algorithm.
|
||||
std::vector< std::vector<std::size_t> > regions;
|
||||
region_growing.detect(std::back_inserter(regions));
|
||||
region_growing.release_memory();
|
||||
// std::cout << regions.size() << std::endl;
|
||||
assert(regions.size() >= 6 && regions.size() <= 8);
|
||||
assert(regions.size() == 7);
|
||||
std::cout << "rg_sortpoints3, epick_test_success: " << true << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Shape_detection/Region_growing/Region_growing.h>
|
||||
#include <CGAL/Shape_detection/Region_growing/Region_growing_on_polygon_mesh.h>
|
||||
|
|
@ -69,37 +70,47 @@ bool test_region_growing_on_polygon_mesh(int argc, char *argv[]) {
|
|||
std::vector< std::vector<std::size_t> > regions;
|
||||
region_growing.detect(std::back_inserter(regions));
|
||||
// std::cout << regions.size() << std::endl;
|
||||
assert(regions.size() >= 325 && regions.size() <= 334);
|
||||
assert(regions.size() == 329);
|
||||
for (const auto& region : regions)
|
||||
assert(region_type.is_valid_region(region));
|
||||
|
||||
std::vector<std::size_t> unassigned_faces;
|
||||
region_growing.unassigned_items(std::back_inserter(unassigned_faces));
|
||||
// std::cout << unassigned_faces.size() << std::endl;
|
||||
assert(unassigned_faces.size() >= 908 && unassigned_faces.size() <= 928);
|
||||
assert(unassigned_faces.size() == 918);
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// ------>
|
||||
|
||||
bool cartesian_double_test_success = true;
|
||||
if (!test_region_growing_on_polygon_mesh< CGAL::Simple_cartesian<double> >(argc, argv))
|
||||
cartesian_double_test_success = false;
|
||||
|
||||
std::cout << "rg_pmesh, cartesian_test_success: " << cartesian_double_test_success << std::endl;
|
||||
assert(cartesian_double_test_success);
|
||||
using SC = CGAL::Simple_cartesian<double>;
|
||||
using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using EPECK = CGAL::Exact_predicates_exact_constructions_kernel;
|
||||
|
||||
// ------>
|
||||
|
||||
bool exact_inexact_test_success = true;
|
||||
if (!test_region_growing_on_polygon_mesh<CGAL::Exact_predicates_inexact_constructions_kernel>(argc, argv))
|
||||
exact_inexact_test_success = false;
|
||||
bool sc_test_success = true;
|
||||
if (!test_region_growing_on_polygon_mesh<SC>(argc, argv))
|
||||
sc_test_success = false;
|
||||
std::cout << "rg_pmesh, sc_test_success: " << sc_test_success << std::endl;
|
||||
assert(sc_test_success);
|
||||
|
||||
std::cout << "rg_pmesh, epick_test_success: " << exact_inexact_test_success << std::endl;
|
||||
assert(exact_inexact_test_success);
|
||||
// ------>
|
||||
|
||||
const bool success = cartesian_double_test_success && exact_inexact_test_success;
|
||||
bool epick_test_success = true;
|
||||
if (!test_region_growing_on_polygon_mesh<EPICK>(argc, argv))
|
||||
epick_test_success = false;
|
||||
std::cout << "rg_pmesh, epick_test_success: " << epick_test_success << std::endl;
|
||||
assert(epick_test_success);
|
||||
|
||||
// ------>
|
||||
|
||||
bool epeck_test_success = true;
|
||||
if (!test_region_growing_on_polygon_mesh<EPECK>(argc, argv))
|
||||
epeck_test_success = false;
|
||||
std::cout << "rg_pmesh, epeck_test_success: " << epeck_test_success << std::endl;
|
||||
assert(epeck_test_success);
|
||||
|
||||
const bool success = sc_test_success && epick_test_success && epeck_test_success;
|
||||
return (success) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,21 +65,23 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// Sort indices.
|
||||
Sorting sorting(
|
||||
polygon_mesh, neighbor_query,
|
||||
vertex_to_point_map);
|
||||
polygon_mesh, neighbor_query, vertex_to_point_map);
|
||||
sorting.sort();
|
||||
|
||||
// Create an instance of the region growing class.
|
||||
Region_growing region_growing(
|
||||
face_range, neighbor_query, region_type,
|
||||
sorting.seed_map());
|
||||
face_range, neighbor_query, region_type, sorting.seed_map());
|
||||
|
||||
// Run the algorithm.
|
||||
std::vector< std::vector<std::size_t> > regions;
|
||||
region_growing.detect(std::back_inserter(regions));
|
||||
region_growing.release_memory();
|
||||
// std::cout << regions.size() << std::endl;
|
||||
assert(regions.size() >= 324 && regions.size() <= 328);
|
||||
assert(regions.size() == 326);
|
||||
|
||||
// test free function
|
||||
// test randomness
|
||||
|
||||
std::cout << "rg_sortfaces3, epeck_test_success: " << true << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,117 +0,0 @@
|
|||
// STL includes.
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
// CGAL includes.
|
||||
#include <CGAL/assertions.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Shape_detection/Region_growing/Region_growing.h>
|
||||
#include <CGAL/Shape_detection/Region_growing/Region_growing_on_point_set.h>
|
||||
|
||||
namespace SD = CGAL::Shape_detection;
|
||||
|
||||
template<class Kernel>
|
||||
bool test_region_growing_on_point_set_2(int argc, char *argv[]) {
|
||||
|
||||
using FT = typename Kernel::FT;
|
||||
using Point_2 = typename Kernel::Point_2;
|
||||
using Vector_2 = typename Kernel::Vector_2;
|
||||
|
||||
using Point_with_normal = std::pair<Point_2, Vector_2>;
|
||||
using Input_range = std::vector<Point_with_normal>;
|
||||
using Point_map = CGAL::First_of_pair_property_map<Point_with_normal>;
|
||||
using Normal_map = CGAL::Second_of_pair_property_map<Point_with_normal>;
|
||||
|
||||
using Neighbor_query = SD::Point_set::Sphere_neighbor_query<Kernel, Input_range, Point_map>;
|
||||
using Region_type = SD::Point_set::Least_squares_line_fit_region<Kernel, Input_range, Point_map, Normal_map>;
|
||||
using Region_growing = SD::Region_growing<Input_range, Neighbor_query, Region_type>;
|
||||
|
||||
// Default parameter values for the data file point_set_2.xyz.
|
||||
const FT sphere_radius = FT(5);
|
||||
const FT distance_threshold = FT(45) / FT(10);
|
||||
const FT angle_threshold = FT(45);
|
||||
const std::size_t min_region_size = 5;
|
||||
|
||||
// Load data.
|
||||
std::ifstream in(argc > 1 ? argv[1] : "data/point_set_2.xyz");
|
||||
CGAL::set_ascii_mode(in);
|
||||
assert(in);
|
||||
|
||||
FT a, b, c, d, e, f;
|
||||
Input_range input_range;
|
||||
while (in >> a >> b >> c >> d >> e >> f)
|
||||
input_range.push_back(std::make_pair(Point_2(a, b), Vector_2(d, e)));
|
||||
in.close();
|
||||
assert(input_range.size() == 3634);
|
||||
|
||||
// Create parameter classes.
|
||||
Neighbor_query neighbor_query(
|
||||
input_range, CGAL::parameters::neighbor_radius(sphere_radius));
|
||||
|
||||
Region_type region_type(
|
||||
input_range,
|
||||
CGAL::parameters::
|
||||
distance_threshold(distance_threshold).
|
||||
angle_deg_threshold(angle_threshold).
|
||||
min_region_size(min_region_size));
|
||||
|
||||
// Run region growing.
|
||||
Region_growing region_growing(
|
||||
input_range, neighbor_query, region_type);
|
||||
|
||||
std::vector< std::vector<std::size_t> > regions;
|
||||
region_growing.detect(std::back_inserter(regions));
|
||||
// std::cout << regions.size() << std::endl;
|
||||
assert(regions.size() >= 63 && regions.size() <= 67);
|
||||
for (const auto& region : regions)
|
||||
assert(region_type.is_valid_region(region));
|
||||
|
||||
std::vector<std::size_t> unassigned_points;
|
||||
region_growing.unassigned_items(std::back_inserter(unassigned_points));
|
||||
// std::cout << unassigned_points.size() << std::endl;
|
||||
assert(unassigned_points.size() >= 77 && unassigned_points.size() <= 97);
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// ------>
|
||||
|
||||
bool cartesian_double_test_success = true;
|
||||
if (!test_region_growing_on_point_set_2< CGAL::Simple_cartesian<double> >(argc, argv))
|
||||
cartesian_double_test_success = false;
|
||||
|
||||
std::cout << "rg_points2, cartesian_test_success: " << cartesian_double_test_success << std::endl;
|
||||
assert(cartesian_double_test_success);
|
||||
|
||||
// ------>
|
||||
|
||||
bool exact_inexact_test_success = true;
|
||||
if (!test_region_growing_on_point_set_2<CGAL::Exact_predicates_inexact_constructions_kernel>(argc, argv))
|
||||
exact_inexact_test_success = false;
|
||||
|
||||
std::cout << "rg_points2, epick_test_success: " << exact_inexact_test_success << std::endl;
|
||||
assert(exact_inexact_test_success);
|
||||
|
||||
// ------>
|
||||
|
||||
bool exact_exact_test_success = true;
|
||||
if (!test_region_growing_on_point_set_2<CGAL::Exact_predicates_exact_constructions_kernel>(argc, argv))
|
||||
exact_exact_test_success = false;
|
||||
|
||||
std::cout << "rg_points2, epeck_test_success: " << exact_exact_test_success << std::endl;
|
||||
assert(exact_exact_test_success);
|
||||
|
||||
const bool success = cartesian_double_test_success && exact_inexact_test_success && exact_exact_test_success;
|
||||
return (success) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
// STL includes.
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
// CGAL includes.
|
||||
#include <CGAL/assertions.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <CGAL/Shape_detection/Region_growing/Region_growing.h>
|
||||
#include <CGAL/Shape_detection/Region_growing/Region_growing_on_point_set.h>
|
||||
|
||||
namespace SD = CGAL::Shape_detection;
|
||||
using Kernel = CGAL::Simple_cartesian<double>;
|
||||
|
||||
using FT = typename Kernel::FT;
|
||||
using Point_2 = typename Kernel::Point_2;
|
||||
using Vector_2 = typename Kernel::Vector_2;
|
||||
|
||||
using Point_with_normal = std::pair<Point_2, Vector_2>;
|
||||
using Input_range = std::vector<Point_with_normal>;
|
||||
using Point_map = CGAL::First_of_pair_property_map<Point_with_normal>;
|
||||
using Normal_map = CGAL::Second_of_pair_property_map<Point_with_normal>;
|
||||
|
||||
using Neighbor_query = SD::Point_set::K_neighbor_query<Kernel, Input_range, Point_map>;
|
||||
using Region_type = SD::Point_set::Least_squares_line_fit_region<Kernel, Input_range, Point_map, Normal_map>;
|
||||
using Sorting = SD::Point_set::Least_squares_line_fit_sorting<Kernel, Input_range, Neighbor_query, Point_map>;
|
||||
using Region_growing = SD::Region_growing<Input_range, Neighbor_query, Region_type, typename Sorting::Seed_map>;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// Load data.
|
||||
std::ifstream in(argc > 1 ? argv[1] : "data/point_set_2.xyz");
|
||||
CGAL::set_ascii_mode(in);
|
||||
assert(in);
|
||||
|
||||
FT a, b, c, d, e, f;
|
||||
Input_range input_range;
|
||||
while (in >> a >> b >> c >> d >> e >> f)
|
||||
input_range.push_back(
|
||||
std::make_pair(Point_2(a, b), Vector_2(d, e)));
|
||||
in.close();
|
||||
assert(input_range.size() == 3634);
|
||||
|
||||
// Default parameter values for the data file point_set_2.xyz.
|
||||
const std::size_t k = 12;
|
||||
const FT distance_threshold = FT(45) / FT(10);
|
||||
const FT angle_threshold = FT(45);
|
||||
const std::size_t min_region_size = 5;
|
||||
|
||||
// Create parameter classes.
|
||||
Neighbor_query neighbor_query(
|
||||
input_range, CGAL::parameters::neighbor_radius(k));
|
||||
|
||||
Region_type region_type(
|
||||
input_range,
|
||||
CGAL::parameters::
|
||||
distance_threshold(distance_threshold).
|
||||
angle_deg_threshold(angle_threshold).
|
||||
min_region_size(min_region_size));
|
||||
|
||||
// Sort indices.
|
||||
Sorting sorting(
|
||||
input_range, neighbor_query);
|
||||
sorting.sort();
|
||||
|
||||
// Create an instance of the region growing class.
|
||||
Region_growing region_growing(
|
||||
input_range, neighbor_query, region_type,
|
||||
sorting.seed_map());
|
||||
|
||||
// Run the algorithm.
|
||||
std::vector< std::vector<std::size_t> > regions;
|
||||
region_growing.detect(std::back_inserter(regions));
|
||||
region_growing.release_memory();
|
||||
// std::cout << regions.size() << std::endl;
|
||||
assert(regions.size() >= 60 && regions.size() <= 64);
|
||||
std::cout << "rg_sortpoints2, cartesian_test_success: " << true << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
- add Polyline_graph that extracts the graph from the polygon mesh
|
||||
- add new tests: polyline (2D, 3D), polyline with sorting (2D, 3D), free functions, randomness
|
||||
- update the docs
|
||||
- update polyhedron demo
|
||||
- ---- submission ----
|
||||
- update the polyhedron demo
|
||||
- add new tests: polyline (2D, 3D), polyline with sorting (2D, 3D), free functions, randomness, strict tests on the data from PMP, tests similar to the basic_example
|
||||
Loading…
Reference in New Issue