c++ - Surface Mesh Generation Code in CGAL, not compiling -
i trying utilize surface reconstruction feature of cgal (taken here, yet keep getting error:
in file included /usr/include/cgal/io/output_surface_facets_to_polyhedron.h:25:0, /home/mrsl_student/git/catkin_ws/src/mesh_map/include/mesh_map/cgaldelaunaytriangulation.h:14, /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:3: /usr/include/cgal/value_type_traits.h: in instantiation of ‘struct cgal::value_type_traits<cgal::point_with_normal_3<cgal::epick> >’: /usr/include/cgal/point_with_normal_3.h:165:1: required substitution of ‘template<class iter> cgal::normal_of_point_with_normal_pmap<typename cgal::kernel_traits<typename cgal::value_type_traits<t>::type>::kernel> cgal::make_normal_of_point_with_normal_pmap(iter) [with iter = cgal::point_with_normal_3<cgal::epick>]’ /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:21:113: required here /usr/include/cgal/value_type_traits.h:40:56: error: no type named ‘value_type’ in ‘struct std::iterator_traits<cgal::point_with_normal_3<cgal::epick> >’ typedef typename std::iterator_traits<t>::value_type type; ^ /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp: in static member function ‘static void cgaldelaunay::triangulateusingcgal()’: /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:21:113: error: no matching function call ‘make_normal_of_point_with_normal_pmap(std::vector<cgal::point_with_normal_3<cgal::epick> >::value_type)’ cgal::make_normal_of_point_with_normal_pmap(pointlist::value_type()) ); ^ /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:21:113: note: candidate is: in file included /usr/include/cgal/reconstruction_triangulation_3.h:25:0, /usr/include/cgal/poisson_reconstruction_function.h:35, /home/mrsl_student/git/catkin_ws/src/mesh_map/include/mesh_map/cgaldelaunaytriangulation.h:15, /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:3: /usr/include/cgal/point_with_normal_3.h:165:1: note: template<class iter> cgal::normal_of_point_with_normal_pmap<typename cgal::kernel_traits<typename cgal::value_type_traits<t>::type>::kernel> cgal::make_normal_of_point_with_normal_pmap(iter) make_normal_of_point_with_normal_pmap(iter) ^ /usr/include/cgal/point_with_normal_3.h:165:1: note: substitution of deduced template arguments resulted in errors seen above /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:24:47: error: no matching function call ‘cgal::poisson_reconstruction_function<cgal::epick>::compute_implicit_function()’ if ( ! function.compute_implicit_function() ) ^ /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:24:47: note: candidates are: in file included /home/mrsl_student/git/catkin_ws/src/mesh_map/include/mesh_map/cgaldelaunaytriangulation.h:15:0, /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:3: /usr/include/cgal/poisson_reconstruction_function.h:366:8: note: template<class sparselinearalgebratraits_d, class visitor> bool cgal::poisson_reconstruction_function<gt>::compute_implicit_function(sparselinearalgebratraits_d, visitor, double, double) [with sparselinearalgebratraits_d = sparselinearalgebratraits_d; visitor = visitor; gt = cgal::epick] bool compute_implicit_function( ^ /usr/include/cgal/poisson_reconstruction_function.h:366:8: note: template argument deduction/substitution failed: /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:24:47: note: candidate expects 4 arguments, 0 provided if ( ! function.compute_implicit_function() ) ^ in file included /home/mrsl_student/git/catkin_ws/src/mesh_map/include/mesh_map/cgaldelaunaytriangulation.h:15:0, /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:3: /usr/include/cgal/poisson_reconstruction_function.h:519:8: note: template<class sparselinearalgebratraits_d> bool cgal::poisson_reconstruction_function<gt>::compute_implicit_function(sparselinearalgebratraits_d, bool) [with sparselinearalgebratraits_d = sparselinearalgebratraits_d; gt = cgal::epick] bool compute_implicit_function(sparselinearalgebratraits_d solver, bool smoother_hole_filling = false) ^ /usr/include/cgal/poisson_reconstruction_function.h:519:8: note: template argument deduction/substitution failed: /home/mrsl_student/git/catkin_ws/src/mesh_map/src/cgaldelaunaytriangulation.cpp:24:47: note: candidate expects 2 arguments, 0 provided if ( ! function.compute_implicit_function() )
i have absolutely no idea why isn't working, , advice appreciated.
code below:
(header file) #include <cgal/trace.h> #include <cgal/exact_predicates_inexact_constructions_kernel.h> #include <cgal/polyhedron_3.h> #include <cgal/io/polyhedron_iostream.h> #include <cgal/surface_mesh_default_triangulation_3.h> #include <cgal/make_surface_mesh.h> #include <cgal/implicit_surface_3.h> #include <cgal/io/output_surface_facets_to_polyhedron.h> #include <cgal/poisson_reconstruction_function.h> #include <cgal/point_with_normal_3.h> #include <cgal/property_map.h> #include <cgal/io/read_xyz_points.h> #include <cgal/compute_average_spacing.h> #include <vector> #include <fstream> using namespace std; // type typedef cgal::exact_predicates_inexact_constructions_kernel kernel; typedef kernel::ft ft; typedef kernel::point_3 point; typedef cgal::point_with_normal_3<kernel> point_with_normal; typedef kernel::sphere_3 sphere; typedef std::vector<point_with_normal> pointlist; typedef cgal::polyhedron_3<kernel> polyhedron; typedef cgal::poisson_reconstruction_function<kernel> poisson_reconstruction_function; typedef cgal::surface_mesh_default_triangulation_3 str; typedef cgal::surface_mesh_complex_2_in_triangulation_3<str> c2t3; typedef cgal::implicit_surface_3<kernel, poisson_reconstruction_function> surface_3; class cgaldelaunay { public: static void triangulateusingcgal(); };
cpp file:
#include "mesh_map/cgaldelaunaytriangulation.h" void cgaldelaunay::triangulateusingcgal() { // poisson options ft sm_angle = 20.0; // min triangle angle in degrees. ft sm_radius = 30; // max triangle size w.r.t. point set average spacing. ft sm_distance = 0.375; // surface approximation error w.r.t. point set average spacing. // reads point set file in points[]. // note: read_xyz_points_and_normals() requires iterator on points // + property maps access each point's position , normal. // position property map can omitted here use iterators on point_3 elements. pointlist points; // creates implicit function read points using default solver. // note: method requires iterator on points // + property maps access each point's position , normal. // position property map can omitted here use iterators on point_3 elements. poisson_reconstruction_function function(points.begin(), points.end(), cgal::make_normal_of_point_with_normal_pmap(pointlist::value_type()) ); // computes poisson indicator function f() // @ each vertex of triangulation. if ( ! function.compute_implicit_function() ) return exit_failure; // computes average spacing ft average_spacing = cgal::compute_average_spacing(points.begin(), points.end(), 6 /* knn = 1 ring */); // gets 1 point inside implicit surface // , computes implicit function bounding sphere radius. point inner_point = function.get_inner_point(); sphere bsphere = function.bounding_sphere(); ft radius = std::sqrt(bsphere.squared_radius()); // defines implicit surface: requires defining // conservative bounding sphere centered @ inner point. ft sm_sphere_radius = 5.0 * radius; ft sm_dichotomy_error = sm_distance*average_spacing/1000.0; // dichotomy error must << sm_distance surface_3 surface(function, sphere(inner_point,sm_sphere_radius*sm_sphere_radius), sm_dichotomy_error/sm_sphere_radius); // defines surface mesh generation criteria cgal::surface_mesh_default_criteria_3<str> criteria(sm_angle, // min triangle angle (degrees) sm_radius*average_spacing, // max triangle size sm_distance*average_spacing); // approximation error // generates surface mesh manifold option str tr; // 3d delaunay triangulation surface mesh generation c2t3 c2t3(tr); // 2d complex in 3d delaunay triangulation cgal::make_surface_mesh(c2t3, // reconstructed mesh surface, // implicit surface criteria, // meshing criteria cgal::manifold_with_boundary_tag()); // require manifold mesh }
as documented here, overload of compute_implicit_function()
not need solver parameter available if cgal_eigen3_enabled defined. you'll need have eigen installed , available compiler.
at cmake level, done these commands
find_package(eigen3 3.1.0) if (eigen3_found) include( ${eigen3_use_file} ) endif()
also return value in function expecting void return type.
Comments
Post a Comment