VTK (Visualization Toolkit) is an open source, freely acquired software system, thousands of researchers and developers in the world with 3D computer graphics, image processing, visualization. VTK includes a C class library, numerous translation interface layers, including TCL / TK, Java, Python.
Visualization Toolkit is a support environment for visual application construction and operation. It is developed by object-oriented design methods based on the three-dimensional log library OpenGL. It will often encounter our details during visual development. Shield and package some common algorithms. For example, the Visualization Toolkit is more common in surface reconstruction, and gives us to support in the form of a class, so that we do not have to repeat the MarchingCubes algorithm when it is reconstructed with the three-dimensional rule of data. And use the VTKMarchingCubes class that has been provided directly in the Visualization Toolkit
Visualization Toolkit is a powerful visual development tool for researchers engaged in visual application development work, which has the following characteristics with the principle of the convenience and flexibility of users.
1) Have a powerful three-dimensional graphics function. Visualization Toolkit supports both voxel VOXEL-BASEDRENDERING's body-drawing Volume Rendering, which retains traditional face drawings, which can make full use of existing graphics libraries and graphics hardware at very large improvement visual effects.
2) The Visualization Toolkit architecture makes it a very good stream streaming and cache caps that do not have to consider the restriction of memory resources when processing a large amount of data.
3) Visualization Toolkit can better support network-based tools such as Java and VRML with the development of Web and Internet technology Visualization Toolkit has a good development prospect.
4) Can support multiple colors such as OpenGL, etc.
5) Visualization Toolkit has equipment independence makes its code good portability
6) Visualization Toolkit defines a lot of macros, which simplifies programming work and strengthens consistent object behavior.
7) Visualization Toolkit has a richer data type, supports processing of multiple data types
8) It is easy to work in the Windows operating system and work in the UNIX operating system.
Here is the method of using VTK in JDK1.4.1_02,
1) Upload the latest package from the VTK website (http://www.vtk.org/), version 4.2. Then install it into the C: / VTK42 / directory
2) Download link from Sun official, version 1.4.1_02, then install it to C: /J2SDK1.4.1_02
3) Set the environment variable, system-> Advanced -> Environment Variables -> Path, set to C: /J2SDK1.4.1_02/bin; c: /programfiles/java/j2re1.4.1_02/bin; c: /j2sdk1.4.1 _02 / jre / bin; c: / vtk42 / bin
4) Copy C: /VTK42/bin/*java.dll to the system directory
5) Compilation, run, for convenience, copy C: / vtk42 / examples / tutorial / step1 / java directory, the current directory is D disk
D: /> javac -classpath c: /vtk42/bin/vtk.jar cone.javad: /> java -classpath.; C: /vtk42/bin/vtk.jar CONE
The source code is as follows:
//
// this Example Creates a Polygonal Model of a CONE, AND THEN Renders it to
// The screen. It will rotate The conne 360 deterrees and kiln. The Basic
// setup of source -> mapper -> actor -> renderer -> RenderWindow IS
// Typical of Most VTK Programs.
//
// We import the vtk wrapped classes first.
Import vtk. *;
//. We define ur class.
Public class cone {
// in The Static Contructor We Load in The Native Code.
// The libraries must be in your path to work.
STATIC {
System.loadLibrary ("vtkcommonjava";
System.loadLibrary ("vtkfilteringjava);
System.loadLibrary ("vtkiojava");
System.LoadLibrary ("vtkimagingjava);
System.LoadLibrary ("vtkgraphicsjava);
System.loadLibrary ("vtkrenderingjava);
}
// Now the main program
Public static void main (String [] args) {
//
// next we create an instance of vtkconesource and set some of its
// Properties. The instance of vtkconesource "cone" is part of a
// Visualization Pipeline (IT IS A Source Process Object); IT Products Data
// (Output Type is vtkpolydata) Which Other Filters May Process.
//
Vtkconesource cone = new vtkconesource ();
CONE.SETHEIGHT (3.0);
CONE.SETRADIUS (1.0);
CONE.SETRESOLUTION (10);
//
// in this Example We Terminate The Pipeline with a mapper process object.
// (Intermediate Filters Such as VtkshrinkPolyData Could Be Inserted in
// Between the source and the mapper.) We create an instance of
// vtkpolyDataMapper to map the Polygonal Data INTO Graphics Primitives. WE
// Connect the output of the cone sol to the input of this mapper.//
vtkpolydatamapper conemapper = new vtkpolydataMapper ();
CONEMAPPER.SETINPUT (CONE.GETOUT ());
//
// Create An actor to represent the cone. The actor orchestrates rendering
// of the mapper's graphics primities. An actors Also Refers To Properties
// via a vtkproperty instance, and incrudes an internal transformation
// Matrix. We set this actor's mapper to be conemapper Which We created
// Above.
//
Vtkactor coneactor = new vtkactor ();
CONEACTOR.SETMAPPER (CONEMAPPER);
//
// Create the renderer and assign actors to it. A renderer is like a
// viewport. it is part or all of a window on the screen and it is
// Responsible for Drawing The Actors It Has. We Also Set The Background
// color here
//
vtkrenderer ren1 = new vtkrenderer ();
Ren1.addactor (CONEACTOR);
Ren1.SetBackground (0.1, 0.2, 0.4);
//
// finally we create the render window on the screen
// We Putur renderer Into the render window using addrenderer. WE Also
// set the size to be 300 pixels by 300
//
vtkrenderwindow renwin = new vtkrenderwindow ();
Renwin.addrenderer (ren1);
Renwin.setsize (300, 300);
//
// Now we loop over 360 Degreeees and render the cone each time
//
INT I;
For (i = 0; i <360; i)
{
// render the Image
Renwin.render ();
// rotate the Active Camera by One Degree
Ren1.getactivecamera (). Azimuth (1);
}
}
}