Skip to content

Commit

Permalink
update tdr
Browse files Browse the repository at this point in the history
  • Loading branch information
Yao-14 committed Sep 7, 2023
1 parent bf75307 commit 783dabc
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions spateo/tdr/widgets/clip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Literal, Optional, Union

import numpy as np
import vtk
Expand Down Expand Up @@ -62,6 +62,9 @@ def _split_model(original_model):
def interactive_rectangle_clip(
model: Union[PolyData, UnstructuredGrid, MultiBlock],
key: str = "groups",
model_style: Union[Literal["points", "surface", "wireframe"], list] = "points",
model_size: Union[float, list] = 8.0,
colormap: str = "Spectral",
invert: bool = False,
bg_model=None,
) -> MultiBlock:
Expand Down Expand Up @@ -107,13 +110,37 @@ def interactive_rectangle_clip(

# Clip model via a 2D rectangle widget.
picked_models, picking_r_list = [], []
p.add_mesh(
model,
scalars=f"{key}_rgba",
rgba=True,
render_points_as_spheres=True,
point_size=10,
)

if model_style == "points":
render_spheres, render_tubes, smooth_shading = True, False, True
elif model_style == "wireframe":
render_spheres, render_tubes, smooth_shading = False, True, False
else:
render_spheres, render_tubes, smooth_shading = False, False, True
if f"{key}_rgba" in model.array_names:
p.add_mesh(
model,
scalars=f"{key}_rgba",
rgba=True,
style=model_style,
render_points_as_spheres=render_spheres,
render_lines_as_tubes=render_tubes,
point_size=model_size,
line_width=model_size,
smooth_shading=smooth_shading,
)
else:
p.add_mesh(
model,
scalars=key,
style=model_style,
render_points_as_spheres=render_spheres,
render_lines_as_tubes=render_tubes,
point_size=model_size,
line_width=model_size,
smooth_shading=smooth_shading,
cmap=colormap,
)
_interactive_rectangle_clip(
plotter=p,
model=model,
Expand Down

0 comments on commit 783dabc

Please sign in to comment.