import vtk.*; /** * @author schatela * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ public class SocketClient { //============================== static { System.loadLibrary("vtkCommonJava"); System.loadLibrary("vtkParallelJava"); } //============================== private vtkSocketCommunicator comm; private vtkSocketController contr; private vtkOutputPort op; //============================== public SocketClient() { this.createSocket("ltspc8.epfl.ch", 100); this.sendImageData("/home/schatela/BRAINATLAS/rob_t1.h33"); } //============================== public void createSocket(String hostname, int port) { contr = new vtkSocketController(); contr.Initialize(); comm = new vtkSocketCommunicator(); System.out.println("Waiting connection"); comm.WaitForConnection(port); System.out.println("Connection established"); contr.SetCommunicator(comm); vtkOutputPort op = new vtkOutputPort(); op.SetController(contr); op.SetTag(45); } //============================== public void sendImageData(String fname) { vtkImageSinusoidSource sinusoidSource = new vtkImageSinusoidSource(); sinusoidSource.SetWholeExtent(0, 15, 0, 15, 0, 15); sinusoidSource.SetAmplitude(1); sinusoidSource.GetOutput().SetSpacing(0.94 * 16, 0.94 * 16, 0.94 * 16); sinusoidSource.GetOutput().SetOrigin(0, 0, 0); sinusoidSource.UpdateWholeExtent(); sinusoidSource.Update(); vtkImageData id = new vtkImageData(); id.DeepCopy(sinusoidSource.GetOutput()); op.SetInput(id); op.WaitForUpdate(); } //============================== public static void main(String[] args) { SocketClient sc = new SocketClient(); } //============================== }