我正在尝试使用Polyhedron_3的CGAL的isotropic_remeshing方法。但我收到编译器错误,我不明白。这是一个最小的例子:
#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polygon_mesh_processing/remesh.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Polyhedron_3<Kernel> Meshtype;
typedef Meshtype::Halfedge_handle Halfedge_handle;
int main()
{
Meshtype* plane = new Meshtype;
Halfedge_handle h = plane->make_triangle(Point_3(0.0, 0.0, 0.0),
Point_3(1.0, 1.0, 0.0),
Point_3(0.0, 1.0, 0.0));
//split triangle at (p1, p3) edge and insert p2.
Halfedge_handle h_new = plane->split_edge(h->next());
h_new->vertex()->point() = Point_3(1.0, 0.0, 0.0);
CGAL::Polygon_mesh_processing::isotropic_remeshing (
faces(*plane),
0.3,
*plane);
std::cout << plane->size_of_vertices();
delete plane;
}
这会导致编译器错误:
In file included from /usr/include/boost/graph/named_function_params.hpp:26:0,
from /home/tom/cgal-releases-CGAL-4.11/BGL/include/CGAL/boost/graph/named_function_params.h:58,
from /home/tom/cgal-releases-CGAL-4.11/HalfedgeDS/include/CGAL/boost/graph/graph_traits_HalfedgeDS.h:26,
from /home/tom/cgal-releases-CGAL-4.11/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h:26,
from /home/tom/cgal-releases-CGAL-4.11/Polyhedron/include/CGAL/Polyhedron_3.h:1543,
from /home/tom/dev/tmp/main.cpp:4:
/usr/include/boost/property_map/shared_array_property_map.hpp: In instantiation of ‘class boost::shared_array_property_map<boost::default_color_type, bool>’:
/usr/include/boost/graph/depth_first_search.hpp:325:80: required from ‘void boost::graph::detail::depth_first_search_impl<Graph>::operator()(const Graph&, const ArgPack&) const [with ArgPack = boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::visitor, const boost::detail::components_recorder<CGAL::internal::Dynamic_property_map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > >, long unsigned int> > >, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::vertex_index_map, const bool>, boost::parameter::aux::empty_arg_list> >; Graph = boost::filtered_graph<CGAL::Dual<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> > >, CGAL::Polygon_mesh_processing::internal::No_border<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >, CGAL::Polygon_mesh_processing::internal::Border_constraint_pmap<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >, CGAL::Iterator_range<CGAL::Prevent_deref<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > > > >, bool> >, boost::keep_all>]’
/usr/include/boost/graph/depth_first_search.hpp:330:5: required from ‘typename boost::result_of<boost::graph::detail::depth_first_search_impl<Param0>(Param0, const ArgPack&)>::type boost::graph::depth_first_search_with_named_params(const Param0&, const ArgPack&) [with Param0 = boost::filtered_graph<CGAL::Dual<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> > >, CGAL::Polygon_mesh_processing::internal::No_border<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >, CGAL::Polygon_mesh_processing::internal::Border_constraint_pmap<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >, CGAL::Iterator_range<CGAL::Prevent_deref<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > > > >, bool> >, boost::keep_all>; ArgPack = boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::visitor, const boost::detail::components_recorder<CGAL::internal::Dynamic_property_map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > >, long unsigned int> > >, boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::graph::keywords::tag::vertex_index_map, const bool>, boost::parameter::aux::empty_arg_list> >; typename boost::result_of<boost::graph::detail::depth_first_search_impl<Param0>(Param0, const ArgPack&)>::type = void]’
/usr/include/boost/graph/depth_first_search.hpp:333:3: required from ‘typename boost::result_of<boost::graph::detail::depth_first_search_impl<Param0>(Param0, const typename boost::detail::convert_bgl_params_to_boost_parameter<boost::bgl_named_params<T, Tag, Base> >::type&)>::type boost::depth_first_search(const Param0&, const boost::bgl_named_params<T, Tag, Base>&) [with Param0 = boost::filtered_graph<CGAL::Dual<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> > >, CGAL::Polygon_mesh_processing::internal::No_border<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >, CGAL::Polygon_mesh_processing::internal::Border_constraint_pmap<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >, CGAL::Iterator_range<CGAL::Prevent_deref<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > > > >, bool> >, boost::keep_all>; P = boost::detail::components_recorder<CGAL::internal::Dynamic_property_map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > >, long unsigned int> >; T = boost::graph_visitor_t; R = boost::bgl_named_params<bool, boost::vertex_index_t, boost::no_property>; typename boost::result_of<boost::graph::detail::depth_first_search_impl<Param0>(Param0, const typename boost::detail::convert_bgl_params_to_boost_parameter<boost::bgl_named_params<T, Tag, Base> >::type&)>::type = void]’
/usr/include/boost/graph/connected_components.hpp:76:23: required from ‘typename boost::property_traits<IndexMap>::value_type boost::connected_components(const Graph&, ComponentMap, const boost::bgl_named_params<P, T, R>&, typename boost::enable_if_c<(boost::is_base_and_derived<boost::vertex_list_graph_tag, typename boost::graph_traits<Graph>::traversal_category>::value), boost::graph::detail::no_parameter>::type) [with Graph = boost::filtered_graph<CGAL::Dual<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> > >, CGAL::Polygon_mesh_processing::internal::No_border<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >, CGAL::Polygon_mesh_processing::internal::Border_constraint_pmap<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >, CGAL::Iterator_range<CGAL::Prevent_deref<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > > > >, bool> >, boost::keep_all>; ComponentMap = CGAL::internal::Dynamic_property_map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > >, long unsigned int>; P = bool; T = boost::vertex_index_t; R = boost::no_property; typename boost::property_traits<IndexMap>::value_type = long unsigned int; typename boost::enable_if_c<(boost::is_base_and_derived<boost::vertex_list_graph_tag, typename boost::graph_traits<Graph>::traversal_category>::value), boost::graph::detail::no_parameter>::type = boost::graph::detail::no_parameter]’
/home/tom/cgal-releases-CGAL-4.11/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/connected_components.h:238:37: required from ‘typename boost::property_traits<IndexMap>::value_type CGAL::Polygon_mesh_processing::connected_components(const PolygonMesh&, FaceComponentMap, const NamedParameters&) [with PolygonMesh = CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >; FaceComponentMap = CGAL::internal::Dynamic_property_map<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > >, long unsigned int>; NamedParameters = CGAL::pmp_bgl_named_params<bool, CGAL::internal_np::face_index_t, CGAL::pmp_bgl_named_params<CGAL::Polygon_mesh_processing::internal::Border_constraint_pmap<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >, CGAL::Iterator_range<CGAL::Prevent_deref<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > > > >, bool>, CGAL::internal_np::edge_is_constrained_t, boost::no_property> >; typename boost::property_traits<IndexMap>::value_type = long unsigned int]’
/home/tom/cgal-releases-CGAL-4.11/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Isotropic_remeshing/remesh_impl.h:193:38: required from ‘CGAL::Polygon_mesh_processing::internal::Connected_components_pmap<PM, EdgeIsConstrainedMap, FaceIndexMap>::Connected_components_pmap(PM&, EdgeIsConstrainedMap, CGAL::Polygon_mesh_processing::internal::Connected_components_pmap<PM, EdgeIsConstrainedMap, FaceIndexMap>::FIMap, bool) [with PM = CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >; EdgeIsConstrainedMap = CGAL::Polygon_mesh_processing::internal::Border_constraint_pmap<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >, CGAL::Iterator_range<CGAL::Prevent_deref<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > > > >, bool>; FaceIndexMap = bool; CGAL::Polygon_mesh_processing::internal::Connected_components_pmap<PM, EdgeIsConstrainedMap, FaceIndexMap>::FIMap = bool]’
/home/tom/cgal-releases-CGAL-4.11/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h:181:29: required from ‘void CGAL::Polygon_mesh_processing::isotropic_remeshing(const FaceRange&, const double&, PolygonMesh&, const NamedParameters&) [with PolygonMesh = CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >; FaceRange = CGAL::Iterator_range<CGAL::Prevent_deref<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > > > >; NamedParameters = CGAL::pmp_bgl_named_params<bool, CGAL::internal_np::all_default_t>]’
/home/tom/cgal-releases-CGAL-4.11/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/remesh.h:264:22: required from ‘void CGAL::Polygon_mesh_processing::isotropic_remeshing(const FaceRange&, const double&, PolygonMesh&) [with PolygonMesh = CGAL::Polyhedron_3<CGAL::Simple_cartesian<double> >; FaceRange = CGAL::Iterator_range<CGAL::Prevent_deref<CGAL::internal::In_place_list_iterator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > >, std::allocator<CGAL::HalfedgeDS_in_place_list_face<CGAL::I_Polyhedron_facet<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Simple_cartesian<double>, CGAL::I_Polyhedron_derived_items_3<CGAL::Polyhedron_items_3>, std::allocator<int> >, CGAL::Boolean_tag<true>, CGAL::Plane_3<CGAL::Simple_cartesian<double> > > > > > > > >]’
/home/tom/dev/tmp/main.cpp:31:19: required from here
/usr/include/boost/property_map/shared_array_property_map.hpp:23:56: error: no type named ‘key_type’ in ‘struct boost::property_traits<bool>’
typedef typename property_traits<IndexMap>::key_type key_type;
^
我不确定我对isotropic_remeshing的调用有什么问题。在CGAL提供的示例中,使用了surface_mesh数据结构,但在我的情况下需要Polyhedron_3。谢谢你的帮助!
答案 0 :(得分:0)
如文档所述,各向同性remesing需要face_index属性映射。在示例中,surface_mesh有一个默认的面部索引图,所以这个重载是有效的,但是Polyhedron_3没有,所以你必须为你的多面体创建一个并将它作为命名参数提供给函数。
您可以这样做:
typedef boost::graph_traits<Meshtype>::face_descriptor
face_descriptor;
std::map<face_descriptor, std::size_t> fi_map;
std::size_t id =0;
BOOST_FOREACH(face_descriptor f, faces(plane))
{
fi_map[f]=id++;
}
CGAL::Polygon_mesh_processing::isotropic_remeshing (
faces(*plane),
0.3,
*plane,
CGAL::parameters::face_index_map(
boost::make_assoc_property_map(fi_map)));
此外,如果你使用split_edge,你会得到一个非三角形的面,当isotropic_remeshing需要对该区域进行三角剖分时,要么不要分割边缘,要么添加一条边来获得两个三角形而不是四边形。