import java.awt.BorderLayout;

import javax.swing.JFrame;

import vtk.vtkActor;
import vtk.vtkAlgorithmOutput;
import vtk.vtkDataSetMapper;
import vtk.vtkDataSetReader;
import vtk.vtkJPEGReader;
import vtk.vtkPanel;
import vtk.vtkTexture;
import vtk.vtkTextureMapToCylinder;
import vtk.vtkTextureMapToPlane;
import vtk.vtkTextureMapToSphere;


public class MyControlActor {

		
	public MyControlActor() {		

	}

	public static void main(String[] args) {

		vtkPanel panel = new vtkPanel();
		//
		vtkDataSetReader reader = new vtkDataSetReader();
		reader.SetFileName("spacecraft.vtk");
		reader.Update();
		reader.CloseVTKFile();
		
		//vtkDataSet data = reader.GetOutput();
		vtkAlgorithmOutput output = reader.GetOutputPort();
		vtkDataSetMapper mapper = new vtkDataSetMapper();
		vtkActor actor = new vtkActor();
		
		vtkJPEGReader jpg = new vtkJPEGReader();
		jpg.SetFileName("texture.jpg");
		jpg.Update();
		
		vtkTexture texture = new vtkTexture();
		texture.SetInputConnection(jpg.GetOutputPort());
		
		vtkTextureMapToSphere mtoplan = new vtkTextureMapToSphere();
		mtoplan.SetInputConnection(output);
		
		mapper.SetInputConnection(mtoplan.GetOutputPort());
		
		// acteur en blanc
		actor.GetProperty().SetColor(1,1,1);
		// mapper n'utilise pas les couleurs des datas initiales
		mapper.SetScalarVisibility(0);
		
		actor.SetTexture(texture);
		actor.SetMapper(mapper);
		
		
		panel.GetRenderer().AddActor(actor);
		
		//
		JFrame f = new JFrame("Cutting test");
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setSize(500, 500);
		f.setLocationRelativeTo(null);
		f.getContentPane().setLayout(new BorderLayout());
		f.getContentPane().add(panel, BorderLayout.CENTER);
		f.setVisible(true);		

	}

}
