Skip to content

Conversation

@jf---
Copy link
Collaborator

@jf--- jf--- commented Dec 10, 2025

Summary

  • HeatGeodesicSolver class with precomputation for repeated queries
  • heat_geodesic_distances function for single-shot usage
  • uses CGAL Heat_method_3 with intrinsic Delaunay triangulation
  • ~30% faster than libigl heat in compas_slicer workflow

New API

from compas_cgal.geodesics import heat_geodesic_distances, HeatGeodesicSolver

Test plan

  • builds successfully
  • tested with compas_slicer curved slicing workflow

- HeatGeodesicSolver class with precomputation for repeated queries
- heat_geodesic_distances function for single-shot usage
- uses CGAL Heat_method_3 with intrinsic Delaunay triangulation
- ~30% faster than libigl heat in compas_slicer workflow
@tomvanmele
Copy link
Member

@jf--- sorry to keep pointing this out, but you need to add an entry to the changelog to make the PR checks pass...

@tomvanmele
Copy link
Member

@petrasvestartas can you help review the technical aspects of the binding? thanks!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new geodesics module to compas_cgal that provides geodesic distance computation using CGAL's Heat_method_3 algorithm. The implementation offers approximately 30% performance improvement over libigl's heat method in compas_slicer workflows.

Key changes:

  • Added HeatGeodesicSolver class for efficient repeated geodesic queries with precomputation
  • Added heat_geodesic_distances function for single-shot distance calculations
  • Integrated CGAL Heat_method_3 with intrinsic Delaunay triangulation for accuracy

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/geodesics.h C++ header declaring the heat geodesic distance function interface
src/geodesics.cpp C++ implementation with HeatGeodesicSolver class and nanobind bindings
src/compas_cgal/geodesics.py Python wrapper providing Mesh-based API for geodesic distance computation
CMakeLists.txt Build configuration update to include the new geodesics module
CHANGELOG.md Documentation of new features added in this release

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@tomvanmele tomvanmele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few thoughts about the C++ docstrings...
other than that LGTM

Comment on lines 107 to 120
"Parameters\n"
"----------\n"
"vertices : array-like\n"
" Vertex positions as Nx3 matrix (float64)\n"
"faces : array-like\n"
" Face indices as Mx3 matrix (int32)\n"
"sources : list[int]\n"
" Source vertex indices\n"
"\n"
"Returns\n"
"-------\n"
"array\n"
" Geodesic distances from sources to all vertices (Nx1)",
"vertices"_a,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jf--- although i appreciate the effort, we don't actually use this anywhere. it will not be parsed and it will not be visible to anyone.

and since it is just another docstring to maintain and coordinate, and therefore can get out-of-sync quite easily, i think it would be better to just add a one-liner...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as i am concerned, a docstring is not even needed here. the Python wrapper already provides it. in the C++ code i would prefer to only add developer oriented comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough but help aligning things upstream / on the python end

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up below.

"sources"_a);

nanobind::class_<HeatGeodesicSolver>(m, "HeatGeodesicSolver",
"Precomputed heat method solver for repeated geodesic queries.\n\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think removal is a good idea

@jf--- jf--- mentioned this pull request Dec 11, 2025
@petrasvestartas
Copy link
Collaborator

petrasvestartas commented Dec 12, 2025

I am doing a few changes to this PR currently, from include cgal new features from this old discussion: CGAL/cgal#5885

@petrasvestartas
Copy link
Collaborator

petrasvestartas commented Dec 12, 2025

example_geodesics I added the isocurves and mesh splitting from isocurves.

I remove excessive comments from cpp nanobind wrappers because we wrap them in another python function
They are never seen by a user.

@petrasvestartas petrasvestartas self-assigned this Dec 12, 2025
Remove unnecessary docstring from test file.
@jf---
Copy link
Collaborator Author

jf--- commented Dec 12, 2025

@petrasvestartas absolutely remarkable work! the refine_mesh_at_isolevel is incredible... phenomenal!

@jf---
Copy link
Collaborator Author

jf--- commented Dec 12, 2025

oops unintended
image

I'll backport the slicing back to compas_slicer, when merged.
@tomvanmele you do the honours?

super stoked how this turned out!

@petrasvestartas
Copy link
Collaborator

@tomvanmele can you approve and merge?

@tomvanmele tomvanmele merged commit 8c60783 into compas-dev:main Dec 12, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants