Skip to content

Commit

Permalink
Added cy_mesh.pyi and floodfill.pyi
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-abdelgawad committed Aug 10, 2024
1 parent 84be9ad commit 3ed5b04
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module = [
ignore_missing_imports = true

[tool.ruff]
include = ["pyproject.toml", "invesalius/**/*.py",'setup.py','app.py']
include = ["pyproject.toml", "invesalius/**/*.py",'setup.py','app.py',"typings/**/*.pyi"]
line-length = 100
# extend-exclude = ["plugins"]

Expand Down
28 changes: 28 additions & 0 deletions typings/invesalius_cy-stubs/cy_mesh.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from vtk import vtkPolyData

class Mesh:
def __init__(self, pd: vtkPolyData | None = None, other: Mesh | None = None) -> None: ...
def copy_to(self, other: Mesh) -> None:
"""
Copies self content to other.
"""
def to_vtk(self) -> vtkPolyData:
"""
Converts Mesh to vtkPolyData.
"""

def ca_smoothing(mesh: Mesh, T: float, tmax: float, bmin: float, n_iters: int) -> None:
"""
This is a implementation of the paper "Context-aware mesh smoothing for
biomedical applications". It can be used to smooth meshes generated by
binary images to remove its staircase artifacts and keep the fine features.
Params:
mesh: Mesh
T: Min angle (between vertex faces and stack_orientation) to consider a
vertex a staircase artifact
tmax: max distance the vertex must be to its nearest artifact vertex
to considered to calculate the weight
bmin: The minimum weight
n_iters: Number of iterations.
"""
28 changes: 28 additions & 0 deletions typings/invesalius_cy-stubs/floodfill.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from typing import Iterable

import numpy as np

def floodfill(
data: np.ndarray,
i: int,
j: int,
k: int,
v: int,
fill: int,
out: np.ndarray | None,
) -> np.ndarray | None: ...
def floodfill_threshold(
data: np.ndarray,
seeds: list[Iterable[int]],
t0: int,
t1: int,
fill: int,
strct: np.ndarray,
out: np.ndarray | None,
) -> np.ndarray | None: ...
def floodfill_auto_threshold(
data: np.ndarray, seeds: list[Iterable[int]], p: float, fill: int, out: np.ndarray | None
) -> np.ndarray | None: ...
def fill_holes_automatically(
mask: np.ndarray, labels: np.ndarray, nlabels: int, max_size: int
) -> bool: ...

0 comments on commit 3ed5b04

Please sign in to comment.