Skip to content

Commit 40c9ec6

Browse files
committed
used sanitized faces for geodesics
1 parent a795174 commit 40c9ec6

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

src/napari_stress/_measurements/geodesics.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ def geodesic_distance_matrix(surface: SurfaceData) -> np.ndarray:
2626
2727
"""
2828
import gdist
29+
from .._utils import sanitize_faces
2930

3031
# Reorder the faces of the surface to ensure consistent orientation
31-
faces = np.asarray(surface[1], dtype=np.int32)
32-
vertices = np.asarray(surface[0], dtype=np.float64)
32+
sanitized_surface = sanitize_faces(surface)
33+
vertices = sanitized_surface[0]
34+
faces = sanitized_surface[1]
3335

3436
distance_matrix = gdist.local_gdist_matrix(
3537
vertices, faces, max_distance=1e9).toarray()
@@ -62,8 +64,13 @@ def geodesic_path(
6264
6365
"""
6466
import potpourri3d as pp3d
67+
from .._utils import sanitize_faces
6568

66-
path_solver = pp3d.EdgeFlipGeodesicSolver(surface[0], surface[1])
69+
sanitized_surface = sanitize_faces(surface)
70+
vertices = sanitized_surface[0]
71+
faces = sanitized_surface[1]
72+
73+
path_solver = pp3d.EdgeFlipGeodesicSolver(vertices, faces)
6774
path = path_solver.find_geodesic_path(index_1, index_2)
6875

6976
# convert points to vectors from point to point
@@ -224,8 +231,10 @@ def local_extrema_analysis(
224231
- `min_max_pair_distances`: Distances between all pairs of local minima and maxima.
225232
- `min_max_pair_anisotropies`: Difference in input value `(vertices, faces, values)` between all pairs of local minima and maxima.
226233
"""
227-
triangles = surface[1]
234+
from .._utils import sanitize_faces
228235
feature = surface[2]
236+
surface = sanitize_faces(surface)
237+
triangles = surface[1]
229238

230239
quad_fit = len(feature)
231240

src/napari_stress/_reconstruction/reconstruct_surface.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ def reconstruct_surface_from_quadrature_points(
2121
2222
Returns
2323
-------
24-
Sphere_Triangulation_Array : TYPE
25-
DESCRIPTION.
24+
tuple
25+
Tuple of points and faces
2626
2727
"""
2828
from scipy.spatial import Delaunay
29-
29+
from .._utils import sanitize_faces
3030
from .._stress import lebedev_write_SPB as lebedev_write
3131

3232
n_quadrature_points = len(points)
@@ -52,15 +52,4 @@ def reconstruct_surface_from_quadrature_points(
5252
delauney_triangles[tri_i, vert_ind] = vertex
5353
vert_ind = vert_ind + 1
5454

55-
# go through every triangle and make sure that they are all oriented
56-
# counter-clockwise with respect to the center point
57-
for i in range(num_tris):
58-
p1 = points[int(delauney_triangles[i, 0])]
59-
p2 = points[int(delauney_triangles[i, 1])]
60-
p3 = points[int(delauney_triangles[i, 2])]
61-
62-
# check if the triangle is oriented clockwise
63-
if np.cross(p2 - p1, p3 - p1)[2] < 0:
64-
delauney_triangles[i] = delauney_triangles[i][::-1]
65-
66-
return (points, delauney_triangles.astype(int))
55+
return sanitize_faces((points, delauney_triangles.astype(int)))

0 commit comments

Comments
 (0)