import vtk.vtkDataSet;
import vtk.vtkPoints;
import vtk.vtkPolyData;
import vtk.vtkProgrammableFilter;
import vtk.vtkUnstructuredGrid;


public class FiltreGeo extends vtkProgrammableFilter {
	public FiltreGeo() {
		SetExecuteMethod(this,"filtre");
	}
	
	public void filtre() {
		// pour vtkWriter
		//vtkPolyData data = this.GetPolyDataInput();
//		this.GetPolyDataOutput().CopyStructure(data);
//		this.GetPolyDataOutput().GetPointData().PassData(this.GetPolyDataInput().GetPointData());		
		
		// Pour vtkDoubleCutter
		vtkUnstructuredGrid data = this.GetUnstructuredGridInput();
		this.GetUnstructuredGridOutput().CopyStructure(data);
		this.GetUnstructuredGridOutput().GetPointData().PassData(this.GetUnstructuredGridInput().GetPointData());
		
		vtkPoints oldPoints = data.GetPoints();
		vtkPoints newPoints = new vtkPoints();
		
		double[] coord = new double[3];
		
		for(int i=0;i<oldPoints.GetNumberOfPoints();i++){
			coord = oldPoints.GetPoint(i);
			// VtkWriter
			//double d = this.GetPolyDataInput().GetPointData().GetScalars().GetTuple1(i);
			
//			if ((i%16)==0) {
			//coord[0]=coord[0]+d;
			//coord[1]=coord[1]+d;
//			coord[2]=coord[2]+d;
//			}
			coord[0] = coord[0] + 20;
			newPoints.InsertNextPoint(coord);
		}

		// VtkWriter
		//this.GetPolyDataOutput().SetPoints(newPoints);
		
		this.GetUnstructuredGridOutput().SetPoints(newPoints);
		
	}

}
