正在访问表面网格的 属性 地图

Accessing property map for surface mesh

我有一个 CGAL::Surface_mesh<Point_3>,我在其中添加了一个 属性 地图

Mesh::Property_map<Mesh::Face_index, CGAL::Color>
    color_map = tin_colored_mesh.add_property_map<Mesh::Face_index, CGAL::Color>("f:color").first;

我填充了这张地图。

之后,我尝试再次访问此 属性 地图,如下所示:

std::string name = "f:color";
const Mesh::Property_map<Mesh::Face_index, CGAL::Color> ans = tin_colored_mesh.property_map(name).first;

但是这会引发错误:

/Users/<path to file>:197:82: error: no matching member function for call to 'property_map'
  const Mesh::Property_map<Mesh::Face_index, CGAL::Color> ans = tin_colored_mesh.property_map(name).first;
                                                                
/usr/local/include/CGAL/Surface_mesh/Surface_mesh.h:1974:40: note: candidate template ignored: couldn't infer template argument 'I'
    std::pair<Property_map<I, T>,bool> property_map(const std::string& name) const

我不知道如何正确使用这里的模板。

根据the documentation for CGAL::Surface_mesh the property_map member function is a template,正如您在上面使用的add_property_map成员函数。

如错误所述,C++ 无法推断函数模板 CGAL::Surface_mesh::property_map 期望的模板参数 I。一个潜在的解决方案是像 add_property_map:

一样提供所需的模板参数
const Mesh::Property_map<Mesh::Face_index, CGAL::Color> ans
  = tin_colored_mesh.property_map<Mesh::Face_index, CGAL::Color>(name).first;
//                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^