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~