0

I'm struggling to generate UV coordinates on a closed triangle mesh using LSCM with the latest CGAL in header-only mode, on Windows, with VS 2017. The code I have is pretty simple since I can't really have two fixed vertices for the seams, so I'm relying on the default constructor of 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);
}

And it's failing with :

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

I then printed the values of both _idx and data_.size() right before the assertion violation and got the interesting results of 4294967294 (ie 2^32 - 2) and 49128 respectively. Worthy of note is that the mesh in question holds 16376 triangular faces, and 16376 * 3 = 49128. I'm pretty stuck there ; I read the many CGAL examples that deal with planar parameterization, to no avail.

EDIT : upon further inspection, it appears that the biggest number is actually the number returned by PMP::longest_border, which makes sense since I'm using a closed mesh. I'm looking into Seam_mesh to introduce a virtual seam in my mesh.

Matrefeytontias
  • 592
  • 1
  • 4
  • 13
  • LSCM requires the mesh to be a topological disk, and thus not a closed mesh. It seems you know that since you do speak of seams, but your code uses a Surface_mesh, which cannot handle artificial seams. Could you please clarify that bit? – Mael Jul 04 '19 at 07:26
  • Oh that's right, I forgot about that condition. The answer is simply that I'm finding it pretty hard to work off the documentation and the examples. I see the examples using Seam_mesh ; using Two_vertices_parameterizer_3, is it possible to let CGAL arbitrarily chose where to make the seam cut ? Because I'll be processing a variety of meshes, I can't possibly ask for a seam file every time. – Matrefeytontias Jul 04 '19 at 11:23
  • Edited OP with a new discovery. – Matrefeytontias Jul 04 '19 at 12:12
  • Note that with artifical seams via Seam_mesh, the parameterization is not going to be seamless in the sense that the parameterization will not glue nicely on both sides of the borders. – Mael Jul 04 '19 at 14:09
  • 1
    (Pressed enter too early...) There is no automatic way to choose a seam, but you could just pick 2 random points and compute the shortest path and mark that as a seam. Finally CGAL also has a different parameterization method intended for topological ball : Orbifold Tutte parameterization (https://doc.cgal.org/latest/Surface_mesh_parameterization/classCGAL_1_1Surface__mesh__parameterization_1_1Orbifold__Tutte__parameterizer__3.html). In this case, you do not have to construct artifical seams, but you have to provide so-called "cones". – Mael Jul 04 '19 at 14:12
  • That parameterization method uses internally a seam, but the result is seamless. The cones are the equivalent of the random vertices that I was saying you could choose for LSCM and manual "seaming": the internal seam will be the shortest path between the cones. Note that here like for LSCM, their position (and thus the position of the seam) will influence the quality of the output parameterization. – Mael Jul 04 '19 at 14:15
  • Noted. Right now what I'm doing is checking if the mesh is a topological ball. If it is, I go with Orbifold Tutte, if it isn't I assume it's a topological disk and go for LSCM (this is reasonable given my input set). Since LSCM doesn't need a virtual border in case of topological disks, I can just ask for 2 vertex indices in CLI and be done with it. I haven't touched Orbifold Tutte yet but I'll come back to you when I do. – Matrefeytontias Jul 04 '19 at 14:52
  • 1
    As a side remark, you can use [is_closed](https://doc.cgal.org/latest/BGL/group__PkgBGLHelperFct.html#gae04c8044cf1eee6a84baa5b79ab99fef) and [PMP::connected_components](https://doc.cgal.org/latest/Polygon_mesh_processing/index.html#title52). For Orbifold parameterization, you can have a look at the [papers](https://noamaig.github.io/html/projects/orbifold/orbifold_lowres.pdf) to get some inspiration on what good cone placement looks like and maybe devise some automatic way to choose them. – Mael Jul 05 '19 at 08:30

0 Answers0