<div>
<div>Hello all,</div>
<div>&nbsp;</div>
<div>I&#39;m a relatively new VTK developer.&nbsp; I am using Java as the gui for my VTK applications.&nbsp; I had a hard time getting started and finding examples written in Java.&nbsp; I have ported a dozen examples to Java to get familiar with it.&nbsp; I wanted to post my examples so other Java enthusiasts could get up to speed on VTK a bit more easily.&nbsp; I hope this helps. 
</div>
<div>&nbsp;</div>
<div>Best Regards,</div>
<div>Todd</div></div>
<div>&nbsp;</div>
<div>
<p>package examples;<br>import vtk.*;<br>//import vtk.util.VtkUtil;</p>
<p>import javax.swing.*;<br>import java.awt.*;<br>import java.awt.event.WindowAdapter;<br>import java.awt.event.WindowEvent;</p>
<p>/**<br>&nbsp;*&nbsp; This example shows how to use cutting (vtkCutter) and how it<br>&nbsp;*&nbsp; compares with extracting a plane from a computational grid.<br>&nbsp;*/<br>public class CutCombustor extends JPanel {</p>
<p>&nbsp; public CutCombustor() {<br>&nbsp;&nbsp;&nbsp; // Setup VTK rendering panel<br>&nbsp;&nbsp;&nbsp; vtkPanel renWin = new vtkPanel();</p>
<p>&nbsp;&nbsp;&nbsp; // Read some data.<br>&nbsp;&nbsp;&nbsp; vtkPLOT3DReader pl3d = new vtkPLOT3DReader();<br>&nbsp;&nbsp;&nbsp; pl3d.SetXYZFileName(&quot;c:/user/VTK/Data/combxyz.bin&quot;);<br>&nbsp;&nbsp;&nbsp; pl3d.SetQFileName(&quot;c:/user/VTK/Data/combq.bin&quot;);<br>&nbsp;&nbsp;&nbsp; 
pl3d.SetScalarFunctionNumber(100);<br>&nbsp;&nbsp;&nbsp; pl3d.SetVectorFunctionNumber(202);<br>&nbsp;&nbsp;&nbsp; pl3d.Update();</p>
<p>&nbsp;&nbsp;&nbsp; // The cutter uses an implicit function to perform the cutting.<br>&nbsp;&nbsp;&nbsp; // Here we define a plane, specifying its center and normal.<br>&nbsp;&nbsp;&nbsp; // Then we assign the plane to the cutter.<br>&nbsp;&nbsp;&nbsp; vtkPlane plane = new vtkPlane();
<br>&nbsp;&nbsp;&nbsp; plane.SetOrigin(pl3d.GetOutput().GetCenter());<br>&nbsp;&nbsp;&nbsp; plane.SetNormal(-0.287, 0, 0.9579);<br>&nbsp;&nbsp;&nbsp; vtkCutter planeCut = new vtkCutter();<br>&nbsp;&nbsp;&nbsp; planeCut.SetInput(pl3d.GetOutput());<br>&nbsp;&nbsp;&nbsp; planeCut.SetCutFunction(plane);
<br>&nbsp;&nbsp;&nbsp; vtkPolyDataMapper cutMapper = new vtkPolyDataMapper();<br>&nbsp;&nbsp;&nbsp; cutMapper.SetInput(planeCut.GetOutput());<br>&nbsp;&nbsp;&nbsp; cutMapper.SetScalarRange(pl3d.GetOutput().GetPointData().GetScalars().GetRange());<br>&nbsp;&nbsp;&nbsp; vtkActor cutActor = new vtkActor();
<br>&nbsp;&nbsp;&nbsp; cutActor.SetMapper(cutMapper);</p>
<p>&nbsp;&nbsp;&nbsp; // Here we extract a computational plane from the structured grid.<br>&nbsp;&nbsp;&nbsp; // We render it as wireframe.<br>&nbsp;&nbsp;&nbsp; vtkStructuredGridGeometryFilter compPlane = new vtkStructuredGridGeometryFilter();<br>&nbsp;&nbsp;&nbsp; compPlane.SetInput
(pl3d.GetOutput());<br>&nbsp;&nbsp;&nbsp; compPlane.SetExtent(0, 100, 0, 100, 9, 9);<br>&nbsp;&nbsp;&nbsp; vtkPolyDataMapper planeMapper = new vtkPolyDataMapper();<br>&nbsp;&nbsp;&nbsp; planeMapper.SetInput(compPlane.GetOutput());<br>&nbsp;&nbsp;&nbsp; planeMapper.ScalarVisibilityOff
();<br>&nbsp;&nbsp;&nbsp; vtkActor planeActor = new vtkActor();<br>&nbsp;&nbsp;&nbsp; planeActor.SetMapper(planeMapper);<br>&nbsp;&nbsp;&nbsp; planeActor.GetProperty().SetRepresentationToWireframe();<br>&nbsp;&nbsp;&nbsp; planeActor.GetProperty().SetColor(0, 0, 0);</p>
<p>&nbsp;&nbsp;&nbsp; // The outline of the data puts the data in context.<br>&nbsp;&nbsp;&nbsp; vtkStructuredGridOutlineFilter outline = new vtkStructuredGridOutlineFilter();<br>&nbsp;&nbsp;&nbsp; outline.SetInput(pl3d.GetOutput());<br>&nbsp;&nbsp;&nbsp; vtkPolyDataMapper outlineMapper = new vtkPolyDataMapper();
<br>&nbsp;&nbsp;&nbsp; outlineMapper.SetInput(outline.GetOutput());<br>&nbsp;&nbsp;&nbsp; vtkActor outlineActor = new vtkActor();<br>&nbsp;&nbsp;&nbsp; outlineActor.SetMapper(outlineMapper);<br>&nbsp;&nbsp;&nbsp; outlineActor.GetProperty().SetColor(0, 0, 0);</p>
<p>&nbsp;&nbsp;&nbsp; // Add the actors to the renderer, set the background and size<br>&nbsp;&nbsp;&nbsp; renWin.GetRenderer().AddActor(outlineActor);<br>&nbsp;&nbsp;&nbsp; renWin.GetRenderer().AddActor(planeActor);<br>&nbsp;&nbsp;&nbsp; renWin.GetRenderer().AddActor(cutActor);</p>

<p>&nbsp;&nbsp;&nbsp; renWin.GetRenderer().SetBackground(1, 1, 1);<br>&nbsp;&nbsp;&nbsp; renWin.setSize(400, 300);</p>
<p>&nbsp;&nbsp;&nbsp; vtkCamera cam1 = renWin.GetRenderer().GetActiveCamera();<br>&nbsp;&nbsp;&nbsp; cam1.SetClippingRange(11.1034, 59.5328);<br>&nbsp;&nbsp;&nbsp; cam1.SetFocalPoint(9.71821, 0.458166, 29.3999);<br>&nbsp;&nbsp;&nbsp; cam1.SetPosition(-2.95748, -26.7271, 44.5309);
<br>&nbsp;&nbsp;&nbsp; cam1.SetViewUp(0.0184785, 0.479657, 0.877262);</p>
<p>&nbsp;&nbsp;&nbsp; // Place renWin in the center of this panel<br>&nbsp;&nbsp;&nbsp; setLayout(new BorderLayout());<br>&nbsp;&nbsp;&nbsp; add(renWin, BorderLayout.CENTER);<br>&nbsp; }</p>
<p><br>&nbsp; public static void main(String s[]) {<br>&nbsp;&nbsp;&nbsp; CutCombustor panel = new CutCombustor();</p>
<p>&nbsp;&nbsp;&nbsp; JFrame frame = new JFrame(&quot;CutCombustor&quot;);<br>&nbsp;&nbsp;&nbsp; frame.addWindowListener(new WindowAdapter() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void windowClosing(WindowEvent e) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.exit(0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; });<br>&nbsp;&nbsp;&nbsp; 
frame.getContentPane().add(&quot;Center&quot;, panel);<br>&nbsp;&nbsp;&nbsp; frame.pack();<br>&nbsp;&nbsp;&nbsp; frame.setVisible(true);<br>&nbsp; }<br>}</p>
<p>&nbsp;</p></div>