Giter Site home page Giter Site logo

vn-os / vtktoolbox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kit-ibt/vtktoolbox

0.0 1.0 0.0 68.51 MB

A MEX interface to the VTK library. It provides MATLAB functions to read and write VTK files and to apply VTK filters to datasets.

License: Mozilla Public License 2.0

CMake 1.61% MATLAB 20.76% C++ 76.95% C 0.68%

vtktoolbox's Introduction

vtkToolbox for MATLAB

Overview

vtkToolbox is a MEX interface to the VTK library. It provides functions to read and write VTK files and to apply VTK filters to VTK datasets. Currently, two types of datasets are supported: vtkPolyData and vtkUnstructuredGrid (both represented as vtkPointSet). The toolbox is based on two functions for converting a vtkPointSet into a MATLAB struct and vice versa: vtkToStruct() and structToVtk().

Format of the MATLAB struct

The following format is used to represent a VTK dataset as a MATLAB struct:

myStruct.points:    [numPoints x numDim double/single/(u)intN], numDim <= 3
myStruct.cells:     [numCells x maxNumPointsPerCell int32]
myStruct.cellTypes: [numCells x 1 uint8] (see https://vtk.org/doc/nightly/html/vtkCellType_8h_source.html)
myStruct.pointData: [1 x 1 struct of point data arrays] (optional)
myStruct.cellData:  [1 x 1 struct of cell data arrays]  (optional)
myStruct.fieldData: [1 x 1 struct of field data arrays] (optional)

File input/output

The functions vtkRead() and vtkWrite() can be used to read and write various types of files supported by the VTK library.

Filters

The general procedure used by filters in the toolbox is:

  • A MATLAB struct is passed to the MEX function and converted into a vtkPointSet using structToVtk().
  • Desired VTK filters are applied to the vtkPointSet.
  • The vtkPointSet is converted back to a MATLAB struct using vtkToStruct() and returned by the MEX function.

Building the MEX functions

Before you can use the toolbox, you first have to compile the MEX functions for your platform:

  • Install VTK (either using a package manager or from source โ€“ see https://vtk.org/Wiki/VTK/Configure_and_Build)
  • Compile the MEX functions using CMake. In the folder "vtkToolbox", run:
    mkdir build
    cd build
    cmake ..
    make
    

Adding new functions

The functionality of the toolbox can easily be extended by creating and compiling new functions:

  • Duplicate the folder vtkTEMPLATE and replace "TEMPLATE" in file names and the cxx file.

  • Adapt the cxx file by parsing the needed inputs and adding the desired operation(s) or filter(s) to the section "Apply operations to pointSet".

  • Rerun CMake after adjusting "CMakeLists.txt" as follows:

    • Add a new line with all C++ source files of your MEX function to the section "Build MEX functions".
    • You might have to add more VTK components under the section "Set up VTK dependency".
  • Duplicate MATLAB/vtkTEMPLATE.m and adapt it accordingly. This script is only needed for providing a function help and a function hint.

License

All source code is subject to the terms of the Mozilla Public License, v. 2.0.
Copyright 2020 Steffen Schuler, Karlsruhe Institute of Technology.

Contact

Steffen Schuler
Institute of Biomedical Engineering
Karlsruhe Institute of Technology
www.ibt.kit.edu

vtktoolbox's People

Contributors

steffenschuler avatar

Watchers

 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.