CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.9k stars 1.38k forks source link

'boost::hash_value': no overloaded function could convert all the argument types #8012

Closed adokhugi closed 8 months ago

adokhugi commented 8 months ago

Issue Details

When compiling my code I get the error:

'boost::hash_value': no overloaded function could convert all the argument types

This is related to:

region_growing.detect(
    boost::make_function_output_iterator(inserter));

(The source code is more or less a copy of code from the Shape Detection examples.)

Source Code

using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using Projection_traits = CGAL::Projection_traits_xz_3<Kernel>;
using FT = typename Kernel::FT;
using Point_2 = typename Kernel::Point_2;
using Point_3 = typename Kernel::Point_3;
using Line_3 = typename Kernel::Line_3;
using Vector_3 = typename Kernel::Vector_3;
using TIN = CGAL::Delaunay_triangulation_2<Projection_traits>;

void region_growing_for_clustering(Point_set point_set, int counter)
{
    using Output_range = Point_set;
    using Point_map = typename Point_set::Point_map;
    using Normal_map = typename Point_set::Vector_map;

    using Region_type = CGAL::Shape_detection::Point_set::Least_squares_plane_fit_region_for_point_set<Point_set>;
    using Neighbor_query = CGAL::Shape_detection::Point_set::K_neighbor_query_for_point_set<Point_set>;
    using Sorting = CGAL::Shape_detection::Point_set::Least_squares_plane_fit_sorting_for_point_set<Point_set, Neighbor_query>;
    using Region_growing = CGAL::Shape_detection::Region_growing<Neighbor_query, Region_type>;
    using Point_inserter = utils::Insert_point_colored_by_region_index<Point_set::Index, Output_range, Point_map, Kernel::Plane_3>;

    // Default parameter values for the data file building.xyz.
    const std::size_t k = 12;
    const FT          max_distance = FT(2);
    const FT          max_angle = FT(20);
    const std::size_t min_region_size = 50;
    // Create instances of the classes Neighbor_query and Region_type.
    Neighbor_query neighbor_query = CGAL::Shape_detection::Point_set::make_k_neighbor_query(
        point_set, CGAL::parameters::k_neighbors(k));
    Sorting sorting = CGAL::Shape_detection::Point_set::make_least_squares_plane_fit_sorting(point_set, neighbor_query);
    sorting.sort();
    Region_type region_type = CGAL::Shape_detection::Point_set::make_least_squares_plane_fit_region(
        point_set,
        CGAL::parameters::
        maximum_distance(max_distance).
        maximum_angle(max_angle).
        minimum_region_size(min_region_size));
    // Create an instance of the region growing class.
    Region_growing region_growing(
        point_set, sorting.ordered(), neighbor_query, region_type);
    // Run the algorithm.
    Output_range output_range;
    std::size_t number_of_regions = 0;
    Point_inserter inserter(
        point_set.point_map(),
        output_range, number_of_regions);
    region_growing.detect(
        boost::make_function_output_iterator(inserter));
    std::cout << "* number of found planes: " << number_of_regions << std::endl;
    // Save regions to a file.
    std::ofstream out("planes_point_set_3" + std::to_string(counter) + ".ply", std::ios::binary);
    CGAL::IO::set_binary_mode(out);
    out << output_range;
    out.close();
}

Environment

sloriot commented 8 months ago

I can reproduce the error locally but I don't understand it. The function hash_value() does exist in Point_set_3.h...

sloriot commented 8 months ago

OK, that's a matter of inclusion order. Point_set_3.h should be included before utils.h as the overload for hash_value() should be available at the time it is seen in utils.h so that it is considered as a possible overload.

adokhugi commented 8 months ago

Thanks for pointing this out! Merci bien!

Am Mi., 7. Feb. 2024 um 09:27 Uhr schrieb Sebastien Loriot < @.***>:

OK, that's a matter of inclusion order. Point_set_3.h should be included before utils.h as the overload for hash_value() should be available at the time it is seen in utils.h so that it is considered as a possible overload.

— Reply to this email directly, view it on GitHub https://github.com/CGAL/cgal/issues/8012#issuecomment-1931517105, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALYK4YGYOFJ35NUDTMIYFOTYSM3ITAVCNFSM6AAAAABCS4CEVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZRGUYTOMJQGU . You are receiving this because you authored the thread.Message ID: @.***>

-- Dipl.-Ing. Dr. Claus D. Volko, BSc http://www.cdvolko.net/

afabri commented 8 months ago

@sloriot do you refer to this example?

sloriot commented 8 months ago

@sloriot do you refer to this example?

I was using the code provided but it should be similar.

afabri commented 8 months ago

The code provided has no #include so I was wondering.