我正在努力在封闭三角形网格上使用 LSCM 和最新的 CGAL 在 Windows 上使用 VS 2017 生成 UV 坐标。我拥有的代码非常简单,因为我真的不能有两个固定顶点接缝,所以我依赖SMP::Two_vertices_parameterizer_3
.
typedef CGAL::Simple_cartesian<double> Kerneld;
typedef Kerneld::Point_3 Pointd;
typedef CGAL::Surface_mesh<Pointd> Meshd;
// ...
if (parameterizeMesh)
{
std::cout << "Parameterizing mesh with Least-Squares Conformal Mapping ... " << std::endl;
Meshd meshd;
PMP::polygon_soup_to_polygon_mesh(vd, polys, meshd);
SMP::LSCM_parameterizer_3<Meshd, SMP::Two_vertices_parameterizer_3<Meshd>> param;
Meshd::Property_map<Meshd::Vertex_index, Kerneld::Point_2> uvmap = meshd.add_property_map<Meshd::vertex_index, Kerneld::Point_2>("v:uv").first;
SMP::parameterize(meshd, param, PMP::longest_border(meshd).first, uvmap);
}
它失败了:
CGAL error: assertion violation!
Expression : _idx < data_.size()
File : C:\dev\CGAL-4.14\include\CGAL/Surface_mesh/Properties.h
Line : 206
Explanation:
Refer to the bug-reporting instructions at https://www.cgal.org/bug_report.html
然后,我在断言违反之前打印了_idx
和的值,并分别得到了(ie ) 和data_.size()
的有趣结果。值得注意的是,有问题的网格包含 16376 个三角形面,并且 16376 * 3 = 49128。我很困在那里;我阅读了许多处理平面参数化的 CGAL 示例,但无济于事。4294967294
2^32 - 2
49128
编辑:经过进一步检查,似乎最大的数字实际上是返回的数字PMP::longest_border
,这是有道理的,因为我使用的是封闭网格。我正在考虑Seam_mesh
在我的网格中引入一个虚拟接缝。