Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
ci/run_tests.sh
fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v5.0.2
if: ${{ matrix.coverage }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
13 changes: 10 additions & 3 deletions fury/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ def load_polydata(file_name):


@warn_on_args_to_kwargs()
def save_polydata(polydata, file_name, *, binary=False, color_array_name=None):
def save_polydata(
polydata, file_name, *, binary=False, color_array_name=None, legacy_vtk_format=False
):
"""Save a vtk polydata to a supported format file.

Save formats can be VTK, FIB, PLY, STL and XML.
Expand All @@ -392,8 +394,10 @@ def save_polydata(polydata, file_name, *, binary=False, color_array_name=None):
polydata : vtkPolyData
file_name : string
binary : bool
color_array_name: ndarray

color_array_name: string
Name of the color array in the polydata to save in the file.
legacy_vtk_format: bool
If True, save the file in legacy VTK format (42).
"""
# get file extension (type)
file_extension = file_name.split(".")[-1].lower()
Expand Down Expand Up @@ -426,6 +430,9 @@ def save_polydata(polydata, file_name, *, binary=False, color_array_name=None):
if color_array_name is not None and file_extension == "ply":
writer.SetArrayName(color_array_name)

# Only applicable for VTK files
if legacy_vtk_format and file_extension in ["vtk", "vtp", "fib"]:
writer.SetFileVersion(42)
if binary:
writer.SetFileTypeToBinary()
writer.Update()
Expand Down
6 changes: 6 additions & 0 deletions fury/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def test_save_and_load_options():
{
"binary": True,
},
{
"legacy_vtk_format": True,
},
]
fname = "temp-io"

Expand Down Expand Up @@ -100,6 +103,9 @@ def test_save_and_load_options():
{
"binary": False,
},
{
"legacy_vtk_format": False,
},
]
for ext, option in zip(l_ext, l_options):
with InTemporaryDirectory() as odir:
Expand Down
Loading