Skip to content
Snippets Groups Projects
Commit f236a143 authored by Andrew Maclean's avatar Andrew Maclean Committed by GitHub
Browse files

Merge pull request #393 from chakravarthi589/Add_TransformFilter

Add transform filter

Former-commit-id: 2e5e3db4
parents 7003a977 0abf47a7
No related branches found
No related tags found
No related merge requests found
......@@ -154,6 +154,7 @@ It would be appreciated if there are any Java VTK experts who could convert any
[MeshQuality](/Java/PolyData/MeshQuality) | vtkMeshQuality | MeshQuality
[ColorCellsWithRGB](/Java/PolyData/ColorCellsWithRGB) | vtkColorCellsWithRGB | ColorCellsWithRGB
[Reflection](/Java/PolyData/Reflection) | vtkReflection | Reflection
[TransformFilter](/Java/PolyData/TransformFilter) | vtkTransformFilter | Transforms points, associated normals and vectors
| Example Name | Classes Demonstrated | Description | Image |
......
import vtk.vtkRenderWindow;
import vtk.vtkActor;
import vtk.vtkArrowSource;
import vtk.vtkNativeLibrary;
import vtk.vtkPolyDataMapper;
import vtk.vtkNamedColors;
import vtk.vtkRenderer;
import vtk.vtkRenderWindowInteractor;
import vtk.vtkTransform;
import vtk.vtkTransformFilter;
public class TransformFilter
{
//-----------------------------------------------------------------
// Load VTK library and print which library was not properly loaded
static
{
if (!vtkNativeLibrary.LoadAllNativeLibraries())
{
for (vtkNativeLibrary lib : vtkNativeLibrary.values())
{
if (!lib.IsLoaded())
{
System.out.println(lib.GetLibraryName() + " not loaded");
}
}
}
vtkNativeLibrary.DisableOutputWindow(null);
}
// -----------------------------------------------------------------
public static void main(String args[])
{
vtkNamedColors colors = new vtkNamedColors();
//For Actor Color
double actorColor[] = new double[4];
//Renderer Background Color
double Bgcolor[] = new double[4];
colors.GetColor("SteelBlue", actorColor);
colors.GetColor("BurlyWood", Bgcolor);
//Create an Arrow
vtkArrowSource arrowSource = new vtkArrowSource();
vtkTransform Transform = new vtkTransform();
Transform.Scale(5, 1, 1);
vtkTransformFilter TransformFilter = new vtkTransformFilter();
TransformFilter.SetTransform(Transform);
TransformFilter.SetInputConnection(arrowSource.GetOutputPort());
TransformFilter.SetTransform(Transform);
vtkPolyDataMapper mapper = new vtkPolyDataMapper();
mapper.SetInputConnection(TransformFilter.GetOutputPort());
vtkActor actor = new vtkActor();
actor.SetMapper(mapper);
actor.GetProperty().SetColor(actorColor);
// Create the renderer, render window and interactor.
vtkRenderer ren = new vtkRenderer();
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer(ren);
vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow(renWin);
// Visualize the actor
ren.AddActor(actor);
ren.SetBackground(Bgcolor);
renWin.SetSize(300, 300);
renWin.Render();
iren.Initialize();
iren.Start();
}
}
### Description
vtkTransformFilter is an object to transform point coordinates, and associated point normals and vectors, as well as cell normals and vectors.
Transformed data array will be stored in a float array or a double array. Other point and cel data are passed through the filter, unless TransformAllInputVectors is set to true, in this case all other 3 components arrays from point and cell data will be transformed as well.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment