Skip to content

Commit 20eda92

Browse files
committed
Update to vtkio 0.6
1 parent 1e6497e commit 20eda92

File tree

7 files changed

+66
-22
lines changed

7 files changed

+66
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Otherwise this release contains just some small changes to command line paramete
1919
- CLI: The CLI now also prints detailed profiling/timing output when running in parallel with domain decomposition thanks to the new `profile` macro
2020
- CLI: Add `--domain-min` and `--domain-max` flags to the `convert` subcommand that allows to filter out particles
2121
- CLI: Remove the `--splash-detection-radius` flag as it did not work for a couple of releases
22+
- Lib: Update to [`vtkio`](https://github.com/elrnv/vtkio) 0.6.0
2223

2324
## Version 0.5.1
2425

Cargo.lock

Lines changed: 45 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

splashsurf/src/io/vtk_format.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use splashsurf_lib::vtkio;
1111
use splashsurf_lib::Real;
1212

1313
use vtkio::model::{ByteOrder, DataSet, Version, Vtk};
14-
use vtkio::{export_be, import_be, IOBuffer};
14+
use vtkio::IOBuffer;
1515

1616
/// Tries to read a set of particles from the VTK file at the given path
1717
pub fn particles_from_vtk<R: Real, P: AsRef<Path>>(
@@ -42,6 +42,7 @@ pub fn write_vtk<P: AsRef<Path>>(
4242
let vtk_file = Vtk {
4343
version: Version::new((4, 1)),
4444
title: title.to_string(),
45+
file_path: None,
4546
byte_order: ByteOrder::BigEndian,
4647
data: data.into(),
4748
};
@@ -50,13 +51,15 @@ pub fn write_vtk<P: AsRef<Path>>(
5051
if let Some(dir) = filename.parent() {
5152
create_dir_all(dir).context("Failed to create parent directory of output file")?;
5253
}
53-
export_be(vtk_file, filename).context("Error while writing VTK output to file")
54+
vtk_file
55+
.export_be(filename)
56+
.context("Error while writing VTK output to file")
5457
}
5558

5659
/// Tries to read the given file into a VTK `DataSet`
5760
pub fn read_vtk<P: AsRef<Path>>(filename: P) -> Result<DataSet, vtkio::Error> {
5861
let filename = filename.as_ref();
59-
import_be(filename).map(|vtk| vtk.data)
62+
Vtk::import_legacy_be(filename).map(|vtk| vtk.data)
6063
}
6164

6265
/// Tries to convert a vector of consecutive coordinate triplets into a vector of `Vector3`, also converts between floating point types
@@ -85,7 +88,7 @@ pub fn particles_from_dataset<R: Real>(dataset: DataSet) -> Result<Vec<Vector3<R
8588
if let DataSet::UnstructuredGrid { pieces, .. } = dataset {
8689
if let Some(piece) = pieces.into_iter().next() {
8790
let points = piece
88-
.load_piece_data()
91+
.into_loaded_piece_data(None)
8992
.context("Failed to load unstructured grid piece")?
9093
.points;
9194

splashsurf_lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ smallvec = { version = "1.6", features = ["union"] }
4040
arrayvec = "0.5"
4141

4242
# VTK extras
43-
vtkio = { version = "0.5", optional = true }
43+
vtkio = { version = "0.6", optional = true }
4444

4545
# Needed for profiling feature
4646
lazy_static = { version = "1.4", optional = true }

splashsurf_lib/benches/benches/bench_full.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use criterion::{criterion_group, Criterion};
22
use nalgebra::Vector3;
3-
use splashsurf_lib::{
4-
reconstruct_surface, reconstruct_surface_inplace, Parameters, SpatialDecompositionParameters,
5-
SubdivisionCriterion, SurfaceReconstruction,
6-
};
3+
use splashsurf_lib::{reconstruct_surface, reconstruct_surface_inplace, Parameters, SpatialDecompositionParameters, SubdivisionCriterion, SurfaceReconstruction, ParticleDensityComputationStrategy};
74
use std::time::Duration;
85

96
use super::io::vtk::particles_from_vtk;
@@ -14,7 +11,7 @@ use super::io::vtk::write_vtk;
1411
/*
1512
pub fn surface_reconstruction_canyon(c: &mut Criterion) {
1613
let particle_positions: &Vec<Vector3<f32>> =
17-
&particles_from_xyz("../data/canyon_13353401_particles.xyz").unwrap();
14+
&super::io::xyz::particles_from_xyz("../../canyon_13353401_particles.xyz").unwrap();
1815
1916
let particle_radius = 0.011;
2017
let compact_support_radius = 4.0 * particle_radius;

splashsurf_lib/benches/benches/io.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub mod vtk {
5252
use anyhow::{anyhow, Context};
5353

5454
use vtkio::model::{ByteOrder, DataSet, Version, Vtk};
55-
use vtkio::{export_ascii, import_be, IOBuffer};
55+
use vtkio::IOBuffer;
5656

5757
pub fn particles_from_vtk<R: Real, P: AsRef<Path>>(
5858
vtk_file: P,
@@ -69,6 +69,7 @@ pub mod vtk {
6969
let vtk_file = Vtk {
7070
version: Version::new((4, 1)),
7171
title: title.to_string(),
72+
file_path: None,
7273
byte_order: ByteOrder::BigEndian,
7374
data: data.into(),
7475
};
@@ -77,12 +78,12 @@ pub mod vtk {
7778
if let Some(dir) = filename.parent() {
7879
create_dir_all(dir).context("Failed to create parent directory of output file")?;
7980
}
80-
export_ascii(vtk_file, filename).context("Error while writing VTK output to file")
81+
vtk_file.export_ascii(filename).context("Error while writing VTK output to file")
8182
}
8283

8384
pub fn read_vtk<P: AsRef<Path>>(filename: P) -> Result<DataSet, vtkio::Error> {
8485
let filename = filename.as_ref();
85-
import_be(filename).map(|vtk| vtk.data)
86+
Vtk::import_legacy_be(filename).map(|vtk| vtk.data)
8687
}
8788

8889
pub fn particles_from_coords<RealOut: Real, RealIn: Real>(
@@ -111,7 +112,7 @@ pub mod vtk {
111112
if let DataSet::UnstructuredGrid { pieces, .. } = dataset {
112113
if let Some(piece) = pieces.into_iter().next() {
113114
let points = piece
114-
.load_piece_data()
115+
.into_loaded_piece_data(None)
115116
.context("Failed to load unstructured grid piece")?
116117
.points;
117118

splashsurf_lib/tests/integration_tests/io.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub mod vtk {
99
use anyhow::{anyhow, Context};
1010

1111
use vtkio::model::{ByteOrder, DataSet, Version, Vtk};
12-
use vtkio::{export_ascii, import_be, IOBuffer};
12+
use vtkio::IOBuffer;
1313

1414
pub fn particles_from_vtk<R: Real, P: AsRef<Path>>(
1515
vtk_file: P,
@@ -26,6 +26,7 @@ pub mod vtk {
2626
let vtk_file = Vtk {
2727
version: Version::new((4, 1)),
2828
title: title.to_string(),
29+
file_path: None,
2930
byte_order: ByteOrder::BigEndian,
3031
data: data.into(),
3132
};
@@ -34,12 +35,12 @@ pub mod vtk {
3435
if let Some(dir) = filename.parent() {
3536
create_dir_all(dir).context("Failed to create parent directory of output file")?;
3637
}
37-
export_ascii(vtk_file, filename).context("Error while writing VTK output to file")
38+
vtk_file.export_ascii(filename).context("Error while writing VTK output to file")
3839
}
3940

4041
pub fn read_vtk<P: AsRef<Path>>(filename: P) -> Result<DataSet, vtkio::Error> {
4142
let filename = filename.as_ref();
42-
import_be(filename).map(|vtk| vtk.data)
43+
Vtk::import_legacy_be(filename).map(|vtk| vtk.data)
4344
}
4445

4546
pub fn particles_from_coords<RealOut: Real, RealIn: Real>(
@@ -68,7 +69,7 @@ pub mod vtk {
6869
if let DataSet::UnstructuredGrid { pieces, .. } = dataset {
6970
if let Some(piece) = pieces.into_iter().next() {
7071
let points = piece
71-
.load_piece_data()
72+
.into_loaded_piece_data(None)
7273
.context("Failed to load unstructured grid piece")?
7374
.points;
7475

0 commit comments

Comments
 (0)