Skip to content

Commit

Permalink
Support for parsing vtkIdType data type
Browse files Browse the repository at this point in the history
  • Loading branch information
w1th0utnam3 authored and elrnv committed Jul 22, 2023
1 parent 55266f1 commit 38f7204
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
Binary file added assets/triangle_vtkidtype.vtk
Binary file not shown.
1 change: 1 addition & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ fn data_type(input: &[u8]) -> IResult<&[u8], ScalarType> {
map(tag_no_case("unsigned_int"), |_| ScalarType::U32),
map(tag_no_case("unsigned_char"), |_| ScalarType::U8),
map(tag_no_case("unsigned_long"), |_| ScalarType::U64),
map(tag_no_case("vtkIdType"), |_| ScalarType::I32),
))(input)
}

Expand Down
52 changes: 52 additions & 0 deletions tests/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,3 +1053,55 @@ fn binary_dodecagon_test() {
test_b!(parse_be(in1) => out1);
test_b!(parse_be(in2) => out1);
}

#[test]
fn triangle_vtkidtype_test() {
let in1 = include_bytes!("../assets/triangle_vtkidtype.vtk");
let out1 = Vtk {
version: Version::new_legacy(5, 1),
byte_order: ByteOrder::BigEndian,
title: String::from("vtk output"),
file_path: None,
data: DataSet::inline(UnstructuredGridPiece {
points: vec![
1.837499976158142,
2.9874446392059326,
0.23750001192092896,
1.8249998092651367,
2.9850914478302,
0.23750001192092896,
1.8249998092651367,
2.985128402709961,
0.25,
]
.into(),
cells: Cells {
cell_verts: VertexNumbers::XML {
connectivity: vec![1, 2, 0],
offsets: vec![0, 3],
},
types: vec![CellType::Triangle],
},
data: Attributes {
point: vec![Attribute::Field {
name: String::from("FieldData"),
data_array: vec![DataArrayBase {
name: String::from("vtkOriginalPointIds"),
elem: 1,
data: vec![95364, 95538, 95691].into(),
}],
}],
cell: vec![Attribute::Field {
name: String::from("FieldData"),
data_array: vec![DataArrayBase {
name: String::from("vtkOriginalCellIds"),
elem: 1,
data: vec![186229].into(),
}],
}],
},
}),
};

test_b!(parse_be(in1) => out1);
}

0 comments on commit 38f7204

Please sign in to comment.