Closed hunter1992 closed 1 year ago
Come on folks! any help?
Hi @hunter1992, You just need to add a non-default Attributes struct. In your example, this will be something like
...
data: Attributes {
point: vec![
Attribute::vectors("displacement")
.with_data(vec![0.0f32, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0]),
],
..Default::default()
},
...
There is more documentation about how to create attributes here: https://docs.rs/vtkio/latest/vtkio/model/enum.Attribute.html .
The best place to see examples of how to create vtk files take a look at the tests subdirectory. For instance, there is an example of how to create a vector attribute here.
Hope this helps!
Hello elrnv!
Thank you three contributors for your work!I'm learning to use vtkio and it feels great!
After studying the examples in the readme, I already know how to construct a VTK object(with default attributes) using vtkio, and bufferd write it into a .vtk file. Here is my Rust file:
test_vtkio.rs :
And the above code will generate a vtk file: test2.vtk. Its contents are:
test2.vtk:
The test2.vtk file can be well loaded and visualized by paraview without any data:
However I'm having trouble writing Dataset attributes to a .vtk file in Legacy style using vtkio. I don't know how to write the following point_data into the test2.vtk file in Legacy style,
Please teach me how to construct a VTK object containing point/cell data, thanks a lot!