Giter VIP home page Giter VIP logo

Comments (2)

elrnv avatar elrnv commented on May 30, 2024

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.

dineshadepu avatar dineshadepu commented on May 30, 2024

Thanks. I figured this out earlier.

from vtkio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.