GithubHelp home page GithubHelp logo

danw97 / readvtk.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from juliavtk/readvtk.jl

0.0 0.0 0.0 328 KB

Julia package for reading VTK XML files

Home Page: https://juliavtk.github.io/ReadVTK.jl

License: MIT License

Julia 100.00%

readvtk.jl's Introduction

ReadVTK.jl

Docs-stable Docs-dev Build Status Coveralls License: MIT

With ReadVTK.jl you can read in data from VTK XML files in Julia. It aims to complement the excellent package WriteVTK.jl. ReadVTK is part of the JuliaVTK Framework.

Note: ReadVTK was mainly motivated by wanting to write proper tests for Trixi2Vtk.jl. A lot of useful features are still missing (see below), and community contributions to improve this package are welcome!

Usage

First, load the package with

using ReadVTK

Open a VTK file by creating a VTKFile object and passing the filename to the constructor:

vtk = VTKFile(get_example_file("celldata_appended_binary_compressed.vtu"))

To retrieve information about the cell data, use

cell_data = get_cell_data(vtk)

The return object of type VTKCellData allows access to the individual VTKDataArrays using a dictionary-like syntax:

element_ids = cell_data["element_ids"]

Finally, the actual data can be obtained by executing

data = get_data(element_ids)

Full example including REPL output:

julia> using ReadVTK

julia> vtk = VTKFile(get_example_file("celldata_appended_binary_compressed.vtu"))
VTKFile("celldata_appended_binary_compressed.vtu", <XMLDocument>, "UnstructuredGrid", "1.0.0", "LittleEndian", "vtkZLibDataCompressor", <appended_data>, 4434, 3085)

julia> cell_data = get_cell_data(vtk)
VTKData()

julia> element_ids = cell_data["element_ids"]
VTKDataArray("element_ids")

julia> data = get_data(element_ids)
3085-element reinterpret(Int64, ::Vector{UInt8}):
    1
    2
    3
    
 3083
 3084
 3085

Further example VTK files can be found in the ReadVTK_examples repository.

What works

  • Reading in VTK XML files of type UnstructuredGrid, StructuredGrid, RectilinearGrid,ImageData, PUnstructuredGrid,PStructuredGrid PRectilinearGrid,PImageData, or PolyData
  • Extracting cell or point data
  • Extracting point coordinates
  • Extracting information about cell types
  • Only for ImageData,PImageData files: get origin, spacing, and extent information
  • Only for RectilinearGrid,PRectiLinearGrid files: get 1D coordinate vectors
  • Only for StructuredGrid,PStructuredGrid files: get coordinate arrays
  • Reading PolyData files containing vortices, lines, and/or polygons
  • Reading PVD files
  • Reading ParaView VTK files that are in-line binary (experimental, only UnstructuredGrid type tested)

What does not work

  • Reading VTK files not stored in the VTK XML format
  • Reading VTK files of other type than what is listed under What works above
  • Multiblock files
  • Different byte orders in file and host system
  • Probably reading from VTK files that were not created by WriteVTK.jl will fail, specifically since
    • compressed data is assumed to be stored as a single block
    • appended data is assumed to be stored as raw
    • header_type is hardcoded to UInt64
  • Extracting primitives from PolyData files other than vortices, lines, and/or polygons
  • Likely anything else that is not specifically mentioned under What works

Development

Helpful resources for working with (i.e., reading and writing) VTK XML files:

  • VTK file format documentation (incomplete!) as a PDF
  • VTK XML formats wiki article
  • Blog post on encoding binary data
  • Mailing list message on encoding binary data

We use JuliaFormatter.jl to keep a consistent code formatting. If you have installed JuliaFormatter.jl, just run

using JuliaFormatter; format(".")

in the top-level directory of ReadVTK.jl to update the formatting.

Authors

ReadVTK is maintained by the Trixi authors. Its principal developers are Michael Schlottke-Lakemper (RWTH Aachen University, Germany) and Hendrik Ranocha (Johannes Gutenberg University Mainz, Germany).

Further contributions to ReadVTK have been made by the following people:

License and contributing

ReadVTK is licensed under the MIT license (see LICENSE.md). Since ReadVTK is an open-source project, we are very happy to accept contributions from the community. Please refer to CONTRIBUTING.md for more details. To get in touch with the developers, join us on Trixi's Slack workspace or create an issue.

Acknowledgments

This package would not exist without the nice work of Juan Ignacio Polanco and his cleanly written and well-documented package WriteVTK.jl.

readvtk.jl's People

Contributors

sloede avatar ranocha avatar boriskaus avatar matthew-whisenant avatar dependabot[bot] avatar jorgepz avatar ondrejkincl avatar github-actions[bot] avatar

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.