Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Wednesday, June 13, 2007

Point and Line Plotter in VTK - A simple wrapper class

*Purpose: Beginners of VTK usually create a lot of actors for some primitive geometric objects (e.g. such as some simple points and lines). It is a waste to construct so many high level objects. Instead, we can always group multiple geometric primitives into a single actor. The rendering speed increases a lot when you do so.

I have created two simple wrapper classes to help us do the job. Their names are MyVTKPointPlotter and MyVTKLinePlotter. The classes are not well designed yet, but it works for many cases.

Sample usage:
// In demo.cpp

// Generate some random line and random points to plot
for (....)
{
pointPlotter.PlotPoint(....)
linePlotter.PlotLine(....)
}

// Add actors to the renderer
ren->AddActor(pointPlotter.CreateActor());
ren->AddActor(linePlotter.CreateActor());



(Please first follow the VTK installation guide to build VTK from source)




(P.S.) I haven't update this blog for almost a month. Sorry~

Thursday, April 19, 2007

Camera model in VTK

*Purpose: There are two wonderful examples to explain the camera model used in the VTK textbook. Unfortunately, they are in tcl scripts and not ready to run using C++. I have made some modifications and ported them to C++.

You can notice that we have only one version of roll (they are the same no matter you are at the camera position or at the focal point)!

(Please first follow the VTK installation guide to build VTK from source)



Sunday, April 15, 2007

Text output in VTK (2D and 3D)

*Purpose: VTK supports both 2D and 3D text rendering. For 2D, it usually uses vtkTextActor. We can control its font, shadow and display position (in 2D screen coordinates). For 3D, many possible options can be used. One favorable option is to use vtkVectorText with vtkLinearExtrusionFilter. It gives high-quality 3D text rendering.

(Please first follow the VTK installation guide to build VTK from source)




There major VTK classes are used in this demo: vtkTextActor, vtkVectorText, vtkLinearExtrusionFilter.

Friday, April 13, 2007

Multiple vtkRenderers

*Purpose: Create simple source objects. Demo the functionalities of multiple renderers.

(Please first follow the VTK installation guide to build VTK from source)





Many standard objects are used in this demo: cone, sphere, cube, disk, cylinder and arrow.

A simple interactive sphere in VTK

*Purpose: Create a simple sphere, users can interact with it.

(Please first follow the VTK installation guide to build VTK from source)






Basic interaction functionalities:

Mouse: zoom, pan, rotate...
'w': wireframe
's': surface rendering
'p': picking - highlight the bounding box of selected object
'+': increase resolution of the sphere
'-': decrease resolution of the sphere
'c': choose a random color for the sphere