我正在尝试在CGAL中实现泊松重建功能,但是,我受到了大量错误的轰炸。
我知道造成错误的行是这一行:
Poisson_reconstruction_function function(points.begin(), points.end(),CGAL::First_of_pair_property_map<PointVectorPair>(),CGAL::Second_of_pair_property_map<PointVectorPair>());
这不完全是文档上的内容,他们有:
Poisson_reconstruction_function function(points.begin(), points.end(), CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type()) );
但是这条线也带来了许多错误。
非常感谢任何帮助,如果您需要更多信息,请告诉我们!
谢谢!
这是我的完整代码:
(头文件)
#ifndef __Tutorials__CGALDelaunayTriangulation__
#define __Tutorials__CGALDelaunayTriangulation__
#include <stdio.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Triangulation_3.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/convex_hull_3_to_polyhedron_3.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <list>
#include <vector>
#include "BufferActions.h"
#include <ros/console.h>
#include "ros/ros.h"
#include <Eigen/Dense>
#include <CGAL/trace.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 <CGAL/pca_estimate_normals.h>
#include <CGAL/mst_orient_normals.h>
#include <CGAL/property_map.h>
#include <utility>
#include <CGAL/Cartesian.h>
#include <algorithm>
using namespace std;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Delaunay_triangulation_3<Kernel> Triangulation;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3;
typedef Triangulation::Cell_handle Cell_handle;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Locate_type Locate_type;
typedef Polyhedron_3::Vertex_iterator Vertex_iterator;
typedef Polyhedron_3::Halfedge_around_facet_circulator HF_circulator;
//typedef Triangulation::Point Point;
typedef CGAL::Triangulation_3<CGAL::Epick, CGAL::Default> Triangulation_3;
typedef Kernel::FT FT;
typedef Kernel::Point_3 Point;
typedef Kernel::Vector_3 Vector;
typedef CGAL::Point_with_normal_3<Kernel> Point_with_normal;
typedef Kernel::Sphere_3 Sphere;
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;
typedef pair<Point, Vector> PointVectorPair;
typedef std::vector<Point_with_normal> PointList;
class CGALDelaunay
{
public:
static void TriangulateUsingCGAL(vector<vector<float> > * PointsToBeInserted, Triangulation * T, vector<float> *bufferPointer, int*totalVertices);
static Point Transform_Vector_To_Point(vector<float> tempVec);
};
#endif
CPP档案:
#include "mesh_map/CGALDelaunayTriangulation.h"
using Eigen::MatrixXd;
// CGALDelaunay::TriangulateUsingCGAL(vector<Vertex_handle> * DelaunayTriangulationVertices, vector<vector<float> > * PointsToBeInserted, Triangulation * T, vector<float> *bufferPointer, vector<float> *colorPointer, int*totalVertices);
void CGALDelaunay::TriangulateUsingCGAL(vector<vector<float> > * PointsToBeInserted, Triangulation * T, vector<float> *bufferPointer, int*totalVertices)
{
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.
std::list<PointVectorPair> points;
// Estimates normals direction.
// Note: pca_estimate_normals() requires an iterator over points
// as well as property maps to access each point's position and normal.
for(int i = 0; i<PointsToBeInserted->size();i++)
{
vector<float> tempVec = PointsToBeInserted->at(i);
points.push_back(make_pair(Point(tempVec.at(0),tempVec.at(1),tempVec.at(2)), Vector(0.0,0.0,0.0)));
}
ROS_INFO("before estimating normal");
const int nb_neighbors = 12; // K-nearest neighbors = 3 rings
CGAL::pca_estimate_normals(points.begin(), points.end(),
CGAL::First_of_pair_property_map<PointVectorPair>(),
CGAL::Second_of_pair_property_map<PointVectorPair>(),
nb_neighbors);
ROS_INFO("after estimating normal");
// Orients normals.
// Note: mst_orient_normals() requires an iterator over points
// as well as property maps to access each point's position and normal.
ROS_INFO("before orienting normals");
std::list<PointVectorPair>::iterator unoriented_points_begin =
CGAL::mst_orient_normals(points.begin(), points.end(),
CGAL::First_of_pair_property_map<PointVectorPair>(),
CGAL::Second_of_pair_property_map<PointVectorPair>(),
nb_neighbors);
ROS_INFO("after orienting normals");
Poisson_reconstruction_function function(points.begin(), points.end(),CGAL::First_of_pair_property_map<PointVectorPair>(),CGAL::Second_of_pair_property_map<PointVectorPair>());
}
完整的错误消息:
In file included from /usr/include/CGAL/IO/output_surface_facets_to_polyhedron.h:25:0,
from /home/mrsl_student/git/catkin_ws/src/mesh_map/include/mesh_map/CGALDelaunayTriangulation.h:28,
from /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 by 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:47:140: required from 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(std::vector<std::vector<float> >*, Triangulation*, std::vector<float>*, int*)’:
/home/mrsl_student/git/catkin_ws/src/mesh_map/src/CGALDelaunayTriangulation.cpp:47:140: error: no matching function for call to ‘make_normal_of_point_with_normal_pmap(std::vector<CGAL::Point_with_normal_3<CGAL::Epick> >::value_type)’
Poisson_reconstruction_function function(points.begin(), points.end(), CGAL::make_normal_of_point_with_normal_pmap(PointList::value_type()));
^
/home/mrsl_student/git/catkin_ws/src/mesh_map/src/CGALDelaunayTriangulation.cpp:47:140: note: candidate is:
In file included from /usr/include/CGAL/Reconstruction_triangulation_3.h:25:0,
from /usr/include/CGAL/Poisson_reconstruction_function.h:35,
from /home/mrsl_student/git/catkin_ws/src/mesh_map/include/mesh_map/CGALDelaunayTriangulation.h:29,
from /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)