Search code examples
c++algorithmboostcgal

Boost error with CGAL SDF algorithm


I'm currently trying to use the SDF algorithm of CGAL but I have some boost errors and I don't know where it's from. I followed the example code from CGAL doc

Here's the part of my code :

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/mesh_segmentation.h>
#include <CGAL/property_map.h>

[...]

    void ShapeDiameterFunction_Component::SDF_Algorithm(PolyhedronPtr pMesh)
    {
        pMesh->triangulate();

        srand((unsigned)time(NULL));

        // create a property-map for segment-ids
        typedef std::map<Polyhedron::Facet_const_handle, std::size_t> Facet_int_map;
        Facet_int_map internal_segment_map;
        boost::associative_property_map<Facet_int_map> segment_property_map(internal_segment_map);

        // calculate SDF values and segment the mesh using default parameters.
        std::size_t number_of_segments = CGAL::segmentation_via_sdf_values(pMesh, segment_property_map);
        std::cout << "Number of segments: " << number_of_segments << std::endl;
    }

I'm getting an error when I use the "segmentation_via_sdf_values" function :

/usr/include/boost/mpl/eval_if.hpp|38|error: no type named ‘type’ in ‘boost::mpl::eval_if<boost::detail::has_vertex_property_type<boost::shared_ptr<Enriched_polyhedron<CGAL::Simple_cartesian<double>, Enriched_items> >, mpl_::bool_<false> >, boost::detail::get_vertex_property_type<boost::shared_ptr<Enriched_polyhedron<CGAL::Simple_cartesian<double>, Enriched_items> > >, boost::no_property>::f_ {aka struct boost::no_property}’|

I don't know if it's from my boost installation or from the code itself. I'm using the 1.55 version of libboost-dev and the 4.5.2 version for CGAL. I'm using Ubuntu 15.04 version and my compiler is the GCC compiler 4.9.2.

I tried the example from CGAL documentation is another project and it did compile.

[EDIT] Here is my compiler log.

Thanks, CornFlex


Solution

  • I found my problem, I use the MEPP library which uses the CGAL library. The MEPP library is redefining the typedef declaration of "Polyhedron" and the "pMesh" sent to the sdf_values function isn't the same type as the "Polyhedron" wanted. Of course, the type is checked with boost (eval_if) and that's why it gives me this error.

     typedef CGAL::Exact_predicates_inexact_constructions_kernel KernelSDF;
     typedef CGAL::Polyhedron_3<KernelSDF> PolyhedronSDF;
    
     PolyhedronSDF mesh;
    
     typedef std::map< PolyhedronSDF::Facet_const_handle, double> Facet_double_map;
     Facet_double_map internal_map;
     boost::associative_property_map<Facet_double_map> sdf_property_map(internal_map);
     // compute SDF values
     std::pair<double, double> min_max_sdf = CGAL::sdf_values(mesh, sdf_property_map);
    

    Now I just have to copy my pMesh into my mesh object !

    Thanks.