Grass and Vtk - Grass-wiki
-
Upload
samuel-fernando-mesa-giraldo -
Category
Documents
-
view
213 -
download
0
Transcript of Grass and Vtk - Grass-wiki
8/22/2019 Grass and Vtk - Grass-wiki
http://slidepdf.com/reader/full/grass-and-vtk-grass-wiki 1/3
GRASS and VTK
From GRASS-Wiki
See also the GRASS and Paraview wiki page
Contents
1 Export for VTK
2 Workflows
3 vtkGRASSBridge
3.1 Using vtkGRASSBridge in Python
3.2 Import of VTK data into GRASS
4 Links
Export for VTK
Modules
r.out.vtk (http://grass.osgeo.org/grass64/manuals/r.out.vtk.html) - export raster data for VTK
r3.out.vtk (http://grass.osgeo.org/grass64/manuals/r3.out.vtk.html) - export 3D raster (voxel) data for
VTK
v.out.vtk (http://grass.osgeo.org/grass64/manuals/v.out.vtk.html) - export vector maps for VTK
r.colors.out_vtk addon script - export GRASS color rules for use with VTK
Workflows
Load 3D model data into GRASS with r3.in.ascii (http://grass.osgeo.org/grass64/manuals
/r3.in.ascii.html) . (see Help with 3D)
1.
Split 3D raster map into individual layers, and stack them all into one map. (see the r.stack addon
module)
2.
Run r.colors (http://grass.osgeo.org/grass64/manuals/r.colors.html) with the -e equalize histogram flag
to balance the colors nicely over the entire 3D dataset.
3.
Export the new color rules with r.colors.out_vtk.4.
Load in Paraview or similar, create a movie. (animated screenshot (http://stormy.msrc.sunysb.edu
/diecast/DieCAST_GoM_yr43_July16-30.gif) )
5.
vtkGRASSBridge
vtkGRASSBrige provides a VTK/C++ interface to most of the GRASS GIS raster and vector C library
functions. Its using an intuitive class structure to hide the complexity of the GRASS libraries.
ASS and VTK - GRASS-Wiki http://grasswiki.osgeo.org/wiki/GRASS_and_VTK
3 31/07/2013 22:08
8/22/2019 Grass and Vtk - Grass-wiki
http://slidepdf.com/reader/full/grass-and-vtk-grass-wiki 2/3
Additionally, the vtkGRASSBridge provides access to GRASS C library functions for Python and Java,
using the VTK wrapper.
Reader to convert GRASS datasets (raster, vector) into VTK datasets are provided for raster and vector data.
All vtkImage- and vtkPolyDataAlgorithms can be used to process GRASS raster and vector data. vtkImages
can be directly written as GRASS raster maps into a GRASS location.
This library can be used to build comprehensive 3D visualisation of GRASS GIS data with Java, Python and
C++, as well as base for complex multithreaded image and vector filter to process GRASS GIS datasets i.e:
as backend for WPS server.
Using vtkGRASSBridge in Python
Here a small Python example to triangulate vector points from the North Carolina demo data set with the
VTK delaunay filter class:
# The purpose of this example is
# to read a grass vector map without topology information
# into the VTK poly data format and processing that map with vtkDelaunay2D.# The processed data is written as VTK XML file to the file system
# Init grass variables
init = vtkGRASSInit()
# Now build the pipeline
# read the vector map without creating topology
reader = vtkGRASSVectorPolyDataReader() # The reader does not need topology information
reader.SetVectorName("elev_lid792_randpts")
# Setup the delaunay triangulation
delaunay = vtkDelaunay2D()
delaunay.SetInputConnection(reader.GetOutputPort())
# write the data as XML with base64 encoding
writer = vtkXMLPolyDataWriter()
writer.SetFileName("/tmp/test.vtk")
writer.SetInputConnection(delaunay.GetOutputPort())
writer.Write()
Import of VTK data into GRASS
Implemented in the VTK-GRASS-Bridge:
http://code.google.com/p/vtk-grass-bridge/source/browse/trunk/IO/vtkGRASSRasterImageWriter.h
http://code.google.com/p/vtk-grass-bridge/source/browse/trunk/IO/vtkGRASSVectorPolyDataWriter.h
http://code.google.com/p/vtk-grass-bridge/source/browse/trunk/IO/vtkGRASSRaster3dImageWriter.h
Links
http://code.google.com/p/vtk-grass-bridge/
Retrieved from "http://grasswiki.osgeo.org/grass-wiki/index.php?title=GRASS_and_VTK&oldid=18968"
Categories: Development Linking to other languages VTK 3D Python
This page was last modified on 18 June 2013, at 17:37.
This page has been accessed 1,962 times.
ASS and VTK - GRASS-Wiki http://grasswiki.osgeo.org/wiki/GRASS_and_VTK
3 31/07/2013 22:08
8/22/2019 Grass and Vtk - Grass-wiki
http://slidepdf.com/reader/full/grass-and-vtk-grass-wiki 3/3
Content is available under GNU Free Documentation License 1.2.
ASS and VTK - GRASS-Wiki http://grasswiki.osgeo.org/wiki/GRASS_and_VTK
3 31/07/2013 22:08