Skip to content

Commit

Permalink
Set VTK file format version depending on extension
Browse files Browse the repository at this point in the history
Workaround for vtkio issue elrnv/vtkio#12
  • Loading branch information
w1th0utnam3 committed Nov 3, 2021
1 parent ea4ec9e commit 89f42fa
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/io/vtk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,20 @@ where
if let Some(parent) = filepath.parent() {
create_dir_all(parent)?;
}

// Set VTK format version depending on detected file extension
// Workaround for vtkio not setting version number automatically depending on format
// Issue: https://github.com/elrnv/vtkio/issues/12
let extension = filepath
.extension()
.map(|os_str| os_str.to_string_lossy().to_ascii_lowercase());
let version = match extension.as_ref().map(|s| s.as_str()) {
Some("vtu") => Version { major: 2, minor: 2 },
Some("vtk") | _ => Version { major: 4, minor: 1 },
};

Vtk {
// TODO: What to choose here? Depends on format?
version: Version { major: 4, minor: 1 },
version,
// If we don't have a title then just make the filepath the title
title: self.title.clone().unwrap_or(fallback_title),
byte_order: ByteOrder::BigEndian,
Expand Down

0 comments on commit 89f42fa

Please sign in to comment.