[vtkusers] ColorIsoComb example for Java
Todd Simons
todd.a.simons at gmail.com
Wed Dec 20 10:22:24 EST 2006
Hello all,
I'm a relatively new VTK developer. I am using Java as the gui for my VTK
applications. I had a hard time getting started and finding examples
written in Java. I have ported a dozen examples to Java to get familiar
with it. I wanted to post my examples so other Java enthusiasts could get
up to speed on VTK a bit more easily. I hope this helps.
Best Regards,
Todd
package examples;
/*
* Bare Tcl source: combColorIso.tcl
* CS Facility path:
/sys/www/classes/cs5630/vtk/tcl/graphics/examplesTcl/combColorIso.tcl
*/
import vtk.*;
public class ColorIsoComb {
// 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");
}
public static void main(String s[]) {
// create pipeline
// ----------------
vtkPLOT3DReader pl3d2 = new vtkPLOT3DReader();
pl3d2.SetXYZFileName("c:/user/VTK/Data/combxyz.bin");
pl3d2.SetQFileName("c:/user/VTK/Data/combq.bin");
pl3d2.SetScalarFunctionNumber(153);
pl3d2.Update();
vtkPLOT3DReader pl3d = new vtkPLOT3DReader();
pl3d.SetXYZFileName("c:/user/VTK/Data/combxyz.bin");
pl3d.SetQFileName("c:/user/VTK/Data/combq.bin");
pl3d.SetScalarFunctionNumber(100);
pl3d.SetVectorFunctionNumber(202);
pl3d.Update();
vtkContourFilter iso = new vtkContourFilter();
iso.SetInput(pl3d.GetOutput());
iso.SetValue(0, .24);
vtkProbeFilter probe2 = new vtkProbeFilter();
probe2.SetInput(iso.GetOutput());
probe2.SetSource(pl3d2.GetOutput());
vtkCastToConcrete cast2 = new vtkCastToConcrete();
cast2.SetInput(probe2.GetOutputDataObject(0));
vtkPolyDataNormals normals = new vtkPolyDataNormals();
//normals.SetMaxRecursionDepth(100);
normals.SetInput(cast2.GetPolyDataOutput());
normals.SetFeatureAngle(45);
vtkPolyDataMapper isoMapper = new vtkPolyDataMapper();
isoMapper.SetInput(normals.GetOutput());
isoMapper.ScalarVisibilityOn();
isoMapper.SetScalarRange(0, 1500);
vtkLODActor isoActor = new vtkLODActor();
isoActor.SetMapper(isoMapper);
isoActor.SetNumberOfCloudPoints(1000);
isoActor.GetProperty().SetColor(0.1, 0.3, 0.1); //Bisque?
vtkStructuredGridOutlineFilter outline = new
vtkStructuredGridOutlineFilter();
outline.SetInput(pl3d.GetOutput());
vtkPolyDataMapper outlineMapper = new vtkPolyDataMapper();
outlineMapper.SetInput(outline.GetOutput());
vtkActor outlineActor = new vtkActor();
outlineActor.SetMapper(outlineMapper);
//Add the actors to the renderer, set the background and size
vtkRenderer ren1 = new vtkRenderer ();
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer(ren1);
// Add the actors to the renderer, set the background and size
ren1.AddActor(outlineActor);
ren1.AddActor(isoActor);
ren1.SetBackground(1, 1, 1);
renWin.SetSize(500, 500);
ren1.SetBackground (0.1, 0.2, 0.4);
vtkCamera cam1=ren1.GetActiveCamera();
cam1.SetClippingRange(3.95297, 50);
cam1.SetFocalPoint(9.71821, 0.458166, 29.3999);
cam1.SetPosition(2.7439, -37.3196, 38.7167);
cam1.SetViewUp(-0.16123, 0.264271, 0.950876);
vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow(renWin);
renWin.SetSize(500, 500);
renWin.Render();
iren.Start();
}//main
}//class
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061220/0a98a476/attachment.htm>
More information about the vtkusers
mailing list