Simple Cone - Groovy Way
Show a VTK cone using Groovy's SwingBuilder.
import groovy.swing.SwingBuilder
import javax.swing.JFrame
import vtk.*
/*
* Create a cone and display it in an application window using Groovy's SwingBuilder
*/
// Setup VTK rendering panel, this also loads VTK native libraries
def renWin = new vtkPanel()
// Setup cone rendering pipeline
def cone = new vtkConeSource()
cone.SetResolution(8)
def coneMapper = new vtkPolyDataMapper()
coneMapper.SetInputConnection(cone.GetOutputPort())
def coneActor = new vtkActor()
coneActor.SetMapper(coneMapper)
renWin.GetRenderer().AddActor(coneActor)
renWin.GetRenderer().ResetCamera()
// Create the main application window
new SwingBuilder().frame(
title: "GroovyCone",
defaultCloseOperation: JFrame.DISPOSE_ON_CLOSE,
show: true,
pack: true) {
widget(renWin)
}