Commit 28d597d1 authored by Kenneth Moreland's avatar Kenneth Moreland

Re add example to bottom of README

parent d2caf445
......@@ -78,7 +78,7 @@ Optional dependencies are:
includes (optionally built) OpenGL rendering classes.
+ The OpenGL rendering classes require that you have a extension
binding library and one rendering library. A windowing library is
not needed expect for some optional tests.
not needed except for some optional tests.
+ Extension Binding
+ [GLEW](
+ Rendering Canvas
......@@ -110,6 +110,68 @@ A more detailed description of building VTK-m is available in the [VTK-m
Users Guide].
## Example##
The VTK-m source distribution includes a number of examples. The goal of the
VTK-m examples is to illustrate specific VTK-m concepts in a consistent and
simple format. However, these examples only cover a small part of the
capabilities of VTK-m.
Below is a simple example of using VTK-m to load a VTK image file, run the
Marching Cubes algorithm on it, and render the results to an image:
vtkm::io::reader::VTKDataSetReader reader("path/to/vtk_image_file");
inputData = reader.ReadDataSet();
vtkm::Float64 isovalue = 100.0f;
std::string fieldName = "pointvar";
// Create an isosurface filter
vtkm::filter::MarchingCubes filter;
filter.SetIsoValue(0, isovalue);
vtkm::filter::Result result = filter.Execute( inputData,
inputData.GetField(fieldName) );
filter.MapFieldOntoOutput(result, inputData.GetField(fieldName));
// compute the bounds and extends of the input data
vtkm::Bounds coordsBounds = inputData.GetCoordinateSystem().GetBounds();
vtkm::Vec<vtkm::Float64,3> totalExtent( coordsBounds.X.Length(),
coordsBounds.Z.Length() );
vtkm::Float64 mag = vtkm::Magnitude(totalExtent);
// setup a camera and point it to towards the center of the input data
vtkm::rendering::Camera camera;
camera.SetLookAt(totalExtent*(mag * .5f));
camera.SetViewUp(vtkm::make_Vec(0.f, 1.f, 0.f));
camera.SetClippingRange(1.f, 100.f);
camera.SetPosition(totalExtent*(mag * 2.f));
vtkm::rendering::ColorTable colorTable("thermal");
// Create a mapper, canvas and view that will be used to render the scene
vtkm::rendering::Scene scene;
vtkm::rendering::MapperRayTracer mapper;
vtkm::rendering::CanvasRayTracer canvas(512, 512);
vtkm::rendering::Color bg(0.2f, 0.2f, 0.2f, 1.0f);
// Render an image of the output isosurface
vtkm::cont::DataSet& outputData = result.GetDataSet();
vtkm::rendering::View3D view(scene, mapper, canvas, camera, bg);
## License ##
VTK-m is distributed under the OSI-approved BSD 3-clause License.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment