MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / write_vtk

Function write_vtk

splashsurf_lib/src/io/vtk_format.rs:188–209  ·  view source on GitHub ↗

Tries to write `data` that is convertible to a VTK `DataSet` into a big endian VTK file

(
    data: impl IntoVtkDataSet,
    filename: P,
    title: &str,
)

Source from the content-addressed store, hash-verified

186
187/// Tries to write `data` that is convertible to a VTK `DataSet` into a big endian VTK file
188pub fn write_vtk<P: AsRef<Path>>(
189 data: impl IntoVtkDataSet,
190 filename: P,
191 title: &str,
192) -> Result<(), anyhow::Error> {
193 profile!("write_vtk");
194 let vtk_file = Vtk {
195 version: Version::new_legacy(4, 2),
196 title: title.to_string(),
197 file_path: None,
198 byte_order: ByteOrder::BigEndian,
199 data: data.into_dataset(),
200 };
201
202 let filename = filename.as_ref();
203 if let Some(dir) = filename.parent() {
204 create_dir_all(dir).context("Failed to create parent directory of output file")?;
205 }
206 vtk_file
207 .export_be(filename)
208 .context("Error while writing VTK output to file")
209}
210
211/// Tries to read the given VTK file
212pub fn read_vtk<P: AsRef<Path>>(filename: P) -> Result<Vtk, anyhow::Error> {

Callers 10

particles_to_vtkFunction · 0.85
reconstructFunction · 0.85
mainFunction · 0.85
write_meshFunction · 0.85
test_basic_pipelineFunction · 0.85
test_basic_pipeline_fineFunction · 0.85

Calls 1

into_datasetMethod · 0.80