Skip to content

Commit

Permalink
make helper functions private
Browse files Browse the repository at this point in the history
  • Loading branch information
m-reuter committed Dec 16, 2024
1 parent b92fc48 commit ed32f0d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lapy/tria_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ def level_length(self, vfunc, level):
raise ValueError("No lengths computed, should never get here.")

@staticmethod
def reduce_edges_to_path(edges, start_idx=None, get_edge_idx=False):
def __reduce_edges_to_path(edges, start_idx=None, get_edge_idx=False):
"""Static helper to reduce undirected unsorted edges to path.
Parameters
Expand Down Expand Up @@ -1263,7 +1263,7 @@ def reduce_edges_to_path(edges, start_idx=None, get_edge_idx=False):
return path

@staticmethod
def resample_polygon(path3d: np.ndarray, n_points: int = 100) -> np.ndarray:
def __resample_polygon(path3d: np.ndarray, n_points: int = 100) -> np.ndarray:
# Helper: Cumulative Euclidean distance between successive polygon points.
# This will be the "x" for interpolation
d = np.cumsum(np.r_[0, np.sqrt((np.diff(path3d, axis=0) ** 2).sum(axis=1))])
Expand All @@ -1278,14 +1278,13 @@ def resample_polygon(path3d: np.ndarray, n_points: int = 100) -> np.ndarray:
return xy_interp

@staticmethod
def iterative_resample_polygon(
path3d: np.ndarray, n_points: int = 100, n_iter: int = 3
) -> np.ndarray:
def __iterative_resample_polygon(
path3d: np.ndarray, n_points: int = 100, n_iter: int = 3) -> np.ndarray:
# Helper: resample multiple times to numerically stabilize the result to be
# truly equidistant
path3d_resampled = TriaMesh.resample_polygon(path3d, n_points)
path3d_resampled = TriaMesh.__resample_polygon(path3d, n_points)
for _ in range(n_iter - 1):
path3d_resampled = TriaMesh.resample_polygon(path3d_resampled, n_points)
path3d_resampled = TriaMesh.__resample_polygon(path3d_resampled, n_points)
return path3d_resampled

def level_path(self, vfunc, level, get_tria_idx=False, n_points=None):
Expand Down Expand Up @@ -1374,13 +1373,13 @@ def level_path(self, vfunc, level, get_tria_idx=False, n_points=None):
# compute path from unordered, not-directed edge list
# and return path as list of points, and path length
if get_tria_idx:
path, edge_idx = TriaMesh.reduce_edges_to_path(
path, edge_idx = TriaMesh.__reduce_edges_to_path(
edge_idxs, get_edge_idx=get_tria_idx
)
# translate local edge id to global tria id
tria_idx = t_idx[edge_idx]
else:
path = TriaMesh.reduce_edges_to_path(edge_idxs, get_tria_idx)
path = TriaMesh.__reduce_edges_to_path(edge_idxs, get_tria_idx)
# remove duplicate vertices (happens when levelset hits a vertex almost
# perfectly)
path3d = p[path, :]
Expand All @@ -1397,5 +1396,5 @@ def level_path(self, vfunc, level, get_tria_idx=False, n_points=None):
return path3d, llength, tria_idx
else:
if n_points:
path3d = TriaMesh.iterative_resample_polygon(path3d, n_points)
path3d = TriaMesh.__iterative_resample_polygon(path3d, n_points)
return path3d, llength

0 comments on commit ed32f0d

Please sign in to comment.