meshpro / pygalmesh

:spider_web: A Python interface to CGAL's meshing tools
GNU General Public License v3.0
597 stars 57 forks source link

Where is the exuding time limit set? #136

Closed truenicoco closed 3 years ago

truenicoco commented 3 years ago

First of all, thanks for this great project which makes CGAL usable for C++ allergic people like me.

Using generate_from_array, the exuding phase of the mesh optimization process always stops because of TIME_LIMIT_REACHED, outputting a mesh with slivers. I don't mind letting it run as long as possible, so is there a simple way to set this limit higher? I am trying to find my way through CGAL's docs and code, but it is not easy…

nschloe commented 3 years ago

No idea either. Let me know when you find anything. (Their mailing lists and bug trackers are usually very responsive.)

nschloe commented 3 years ago

Closing for lack of response. Feel free to reopen at any time.

lrineau commented 3 years ago

Late answer, because I was not subscribed to pygalmesh before.

@truenicoco The python function named generate_from_array calls the function generate_from_inr from file pygalmesh/src/generate_from_inr.cpp. In that function, there is that C++ code:

  C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(
      cgal_domain,
      criteria,
      lloyd ? CGAL::parameters::lloyd() : CGAL::parameters::no_lloyd(),
      odt ? CGAL::parameters::odt() : CGAL::parameters::no_odt(),
      perturb ? CGAL::parameters::perturb() : CGAL::parameters::no_perturb(),
      exude ? CGAL::parameters::exude() : CGAL::parameters::no_exude()
      );

See the call to CGAL::parameters::exude(), documented here. That C++ function actually has two parameters: one to define a time limit, and another one for a bound on the dihedral angle of slivers. The default parameters are documented here in the documentation of make_mesh_3: the time limit is set to the measured time of the mesh refinement step of the algorithm.

Note that, whatever parameter you pass, that function is best effort: just using our sliver exudation algorithm (implemented from the algorithm of the article "Siu-Wing Cheng, Tamal K. Dey, Herbert Edelsbrunner, Michael A. Facello, and Shang-Hua Teng. Sliver exudation. J. ACM, 47(5):883–904, 2000") will not be enough to remove all slivers in all configurations. Our best algorithm to remove slivers is the sliver perturber, that is slower in most cases.

Here I refer to the documentation of CGAL-5.3. Depending on which CGAL version was used to compile your version of pygalmesh, details might differ.

nschloe commented 3 years ago

Thanks Laurent for the reply! I should probably expose time_limit to Python. Is the exude time the only relevant limit here? What's the default?

lrineau commented 3 years ago

Thanks Laurent for the reply! I should probably expose time_limit to Python. Is the exude time the only relevant limit here? What's the default?

As I said:

The default parameters are documented here in the documentation of make_mesh_3: the time limit is set to the measured time of the mesh refinement step of the algorithm.

So, the default behavior, without parameter, is to spend as much time on sliver exudation as the algorithm spent on the mesh generation. That is a heuristic we chose, long ago.

lrineau commented 3 years ago

And another "default": if you pass 0 as the time limit, it means "no limit", and the algorithm will exhaust its internal priority queue without any time limit.

nschloe commented 3 years ago

It's all exposed now via exude_time_limit and exude_sliver_bound.