001/* 002 * Copyright 2010, 2011 Institut Pasteur. 003 * 004 * This file is part of ICY. 005 * 006 * ICY is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * ICY is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with ICY. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package plugins.tutorial.vtk; 020 021import icy.painter.Overlay; 022import icy.painter.VtkPainter; 023import vtk.vtkActor; 024import vtk.vtkPolyDataMapper; 025import vtk.vtkProp; 026import vtk.vtkSphereSource; 027 028/** 029 * @author stephane 030 */ 031public class VtkSpherePainter extends Overlay implements VtkPainter 032{ 033 private vtkActor aSphere; 034 035 public VtkSpherePainter() 036 { 037 super("VTK sphere"); 038 039 init(); 040 } 041 042 // init vtk objects 043 private void init() 044 { 045 // source 046 final vtkSphereSource sphere = new vtkSphereSource(); 047 sphere.SetRadius(100); 048 sphere.SetThetaResolution(18); 049 sphere.SetPhiResolution(18); 050 051 // mapper 052 final vtkPolyDataMapper map = new vtkPolyDataMapper(); 053 map.SetInputConnection(sphere.GetOutputPort()); 054 055 // actor 056 aSphere = new vtkActor(); 057 aSphere.SetMapper(map); 058 aSphere.GetProperty().SetColor(0, 0, 1); // color blue 059 } 060 061 @Override 062 public vtkProp[] getProps() 063 { 064 return new vtkProp[] {aSphere}; 065 } 066}