Comments (2)
Sorry for missing this post, somehow it has slipped through my notifications. There are a few examples in tests/vtkio.rs
that may be of use to you. The way to do it is to construct a Vtk
struct and populate all the relevant fields as is done in tests/vtkio.rs
. Perhaps I should include some more examples for this.
Currently the parser expects there to be a CELLS and CELL_TYPES fields for unstructured grid. So adding
CELLS 0 0
CELL_TYPES 0
will work for your example.
For the specific example you provided, something like the following will work:
let vtk_model = Vtk {
version: Version::new((3, 0)),
title: String::from("Time some"),
data: DataSet::UnstructuredGrid {
points: vec![
-0.8999f32, -0.0003, 0.0,
-0.6000, -0.0003, 0.0,
-0.3000, -0.0003, 0.0,
0.0000, -0.0003, 0.0,
-0.8999, 0.2997, 0.0,
-0.6000, 0.2997, 0.0,
-0.3000, 0.2997, 0.0,
0.0000, 0.2997, 0.0,
-0.8999, 0.5997, 0.0,
-0.6000, 0.5997, 0.0,
-0.3000, 0.5997, 0.0,
0.0000, 0.5997, 0.0,
-0.8999, 0.8997, 0.0,
-0.6000, 0.8997, 0.0,
-0.3000, 0.8997, 0.0,
0.0000, 0.8997, 0.0,
].into(),
cells: Cells {
num_cells: 0,
vertices: vec![],
},
cell_types: vec![],
data: Attributes {
point: vec![
(
String::from("Diameter"),
Attribute::Scalars {
num_comp: 1,
lookup_table: None,
data: vec![
0.1500f32; 16
].into(),
},
),
(
String::from("Force"),
Attribute::Vectors {
data: vec![
1464120.5000f32, 437985.7188, 0.0000,
406.5037, -1765.8165, 0.0000,
0.0000, -1765.8000, 0.0000,
0.0000, -1765.8000, 0.0000,
1464120.5000, 437985.6562, 0.0000,
406.5037, -1765.8165, 0.0000,
0.0000, -1765.8000, 0.0000,
0.0000, -1765.8000, 0.0000,
1464120.5000, 437985.5938, 0.0000,
406.5037, -1765.8165, 0.0000,
0.0000, -1765.8000, 0.0000,
0.0000, -1765.8000, 0.0000,
1464120.2500, 437985.9688, 0.0000,
406.5037, -1765.8165, 0.0000,
0.0000, -1765.8000, 0.0000,
0.0000, -1765.8000, 0.0000,
].into(),
},
),
],
cell: vec![],
},
},
};
vtkio::export_ascii(vtk_model, &std::path::PathBuf::from("test.vtk"))
.expect("Failed to write to vtk file.");
This will write your example file into "test.vtk" in your crate's root directory.
Thank you for this issue!
from vtkio.
Thanks. I figured this out earlier.
from vtkio.
Related Issues (20)
- Improve version handling
- Update references to vtk file format docs
- VTKIO Real-World Video Tutorial
- Extracting Data HOT 2
- creating a Circle approximated by a BezierCurve HOT 7
- providing examples for each CellType HOT 4
- Clarify the connection between xml VTK file extensions and VTKFile tag type
- Unable to import various VTK and VTU file types HOT 10
- The Paraview import issue for exported compressed VTU and VTI files HOT 6
- ParaView cannot read XML vtp files whose `connectivity` and `offsets` are `UInt64`. HOT 2
- Future compatibility for nom version 3 HOT 2
- Error importing VTU with `<AppendedData encoding="raw">` block HOT 3
- Support for CRLF line endings in legacy VTK files
- unresolved imports `vtkio::export_ascii`, `vtkio::import` HOT 1
- Request an example of constructing a VTK object containing point/cell data in Legacy style HOT 2
- Exported data for point cloud is not readable by Paraview 5.11 HOT 3
- Add configuration options for exporting files
- Improve documentation for creating point clouds
- Too many complex enum types, sometimes unnecessarily HOT 2
- `0.7.0` is not available on crates.io
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vtkio.