Skip to content

Conversation

@DescriptiveNachos
Copy link

Summary

This PR adds the option to return a geodesic trace as barycentric coordinates.

Backwards Compatibility

The new option is deactivated by default. The behaviour and return remain unchanged if not explicitely called for by the user.
The change is therefore non-braking and should be entirely backwards compatible.

Motivation

Currently, Potpourri3D does only return a geodesic trace as vertex positions / cartesian points. Internally the points are traced as SurfacePoints which can be directly translated into Potpourri3D barycentric coordinates. Exposing this information allows increased interoperability of the Potpourri3D functions. E.g. a geodesic trace could directly be used to calculate the signed distance from the trace.

Changes

  • added new optional conversion of surface points to 7-vectors including both the cartesian and barycentric coordinates in mesh.cpp
  • optional argument "return_barys" is passed through from mesh.py and is added to bindings accordingly
  • added conversion of the DenseMatrix of 7-vectors to Potpourri3D format xzy and bary points in mesh.py
  • added unit test for return_bary option to tests

Testing

  • unit test of return structure passes successfully
  • confirmed that bary return can directly be used as curves for SignedHeatSolver locally for trace_from_vertex (see attached code snipped and picture)
import potpourri3d as pp3d
import polyscope as ps
import numpy as np

V,F = pp3d.read_mesh('bunny_small.ply')

# --- Trace from a vertex ---
tracer = pp3d.GeodesicTracer(V,F)
trace_pts, barys = tracer.trace_geodesic_from_vertex(
    22, 
    np.array((0.3, 0.5, 0.4)), 
    return_bary=True
)
# --- Compute distance to trace ---
solver = pp3d.MeshSignedHeatSolver(V,F)
signed_dist = solver.compute_distance([barys])

# --- Visualization ---
ps.init()
ps_mesh = ps.register_surface_mesh(
    "bunny",
    V,
    F,
    color=(0.8, 0.8, 0.8),
    smooth_shade=True
)

ps_mesh.add_scalar_quantity("geodesic_dist", signed_dist, enabled=True, cmap="viridis")
ps.register_point_cloud("trace points", trace_pts, color=(0.1, 1.0, 0.1), radius=0.003)
ps.register_curve_network(
    "trace path",
    nodes=trace_pts,
    edges=np.column_stack([np.arange(len(trace_pts) - 1), np.arange(1, len(trace_pts))]),
    color=(1.0, 0.2, 0.2)
)
ps.show()
trace_signed_heat_bunny

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.

1 participant