import vtk.vtkFloatArray;
import vtk.vtkPolyData;
import vtk.vtkProgrammableFilter;

public class FiltreData extends vtkProgrammableFilter {
	public FiltreData() {
		SetExecuteMethod(this, "filtre");
	}

	public void filtre() {
		vtkPolyData data = this.GetPolyDataInput();
		this.GetPolyDataOutput().CopyStructure(data);
		this.GetPolyDataOutput().GetPointData().PassData(
				this.GetPolyDataInput().GetPointData());

		int nbPoint = data.GetPoints().GetNumberOfPoints();
		vtkFloatArray floatarray = new vtkFloatArray();
		for (int i = 0; i < nbPoint; i++) {
			double d = this.GetPolyDataInput().GetPointData().GetScalars()
					.GetTuple1(i);
			if ((i % 4) == 0)
				d = d * 4;
			floatarray.InsertNextTuple1(d);

		}

		this.GetPolyDataOutput().GetPointData().SetScalars(floatarray);
		// this.GetPolyDataOutput().SetPoints(newPoints);

	}

}
