Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triangle strips 2 Triangles #756

Merged
merged 3 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions fury/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
TransformPolyDataFilter,
TubeFilter,
VectorText,
TriangleFilter,
numpy_support,
)
from fury.shaders import (
Expand Down Expand Up @@ -595,6 +596,7 @@ def streamtube(
lod_points_size=3,
spline_subdiv=None,
lookup_colormap=None,
replace_strips=False
):
"""Use streamtubes to visualize polylines.

Expand Down Expand Up @@ -642,6 +644,10 @@ def streamtube(
lookup_colormap : vtkLookupTable, optional
Add a default lookup table to the colormap. Default is None which calls
:func:`fury.actor.colormap_lookup_table`.
replace_strips : bool, optional
If True it changes streamtube representation from triangle strips to
triangles. Useful with SelectionManager or PickingManager.
Default False.

Examples
--------
Expand Down Expand Up @@ -712,6 +718,12 @@ def streamtube(

# Poly mapper
poly_mapper = set_input(PolyDataMapper(), next_input)
if replace_strips:
triangle_filter = set_input(TriangleFilter(), next_input)
poly_mapper = set_input(PolyDataMapper(), triangle_filter.GetOutputPort())

else:
poly_mapper = set_input(PolyDataMapper(), next_input)
poly_mapper.ScalarVisibilityOn()
poly_mapper.SetScalarModeToUsePointFieldData()
poly_mapper.SelectColorArray('colors')
Expand Down Expand Up @@ -739,6 +751,8 @@ def streamtube(
actor.GetProperty().BackfaceCullingOn()
actor.GetProperty().SetOpacity(opacity)



return actor


Expand Down
1 change: 1 addition & 0 deletions fury/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
ContourFilter = fcvtk.vtkContourFilter
TubeFilter = fcvtk.vtkTubeFilter
Glyph3D = fcvtk.vtkGlyph3D
TriangleFilter = fcvtk.vtkTriangleFilter

##############################################################
# vtkFiltersGeneral Module
Expand Down
11 changes: 11 additions & 0 deletions fury/tests/test_actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,16 @@ def test_streamtube_and_line_actors():

npt.assert_equal(c3.GetProperty().GetRenderLinesAsTubes(), True)

c4 = actor.streamtube(lines, colors, replace_strips=False)

c5 = actor.streamtube(lines, colors, replace_strips=True)

strips4 = c4.GetMapper().GetInput().GetStrips().GetData().GetSize()
strips5 = c5.GetMapper().GetInput().GetStrips().GetData().GetSize()

npt.assert_equal(strips4 > 0, True)
npt.assert_equal(strips5 == 0, True)


def simulated_bundle(no_streamlines=10, waves=False):
t = np.linspace(20, 80, 200)
Expand Down Expand Up @@ -1716,3 +1726,4 @@ def test_actors_primitives_count():
primitives_count = test_case[2]
act = act_func(**args)
npt.assert_equal(primitives_count_from_actor(act), primitives_count)