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

Merge pull request #396 from chakravarthi589/Add_WrapTo

Add wrap to
parents 2e5e3db4 e3d322b8
No related branches found
No related tags found
Loading
......@@ -36,6 +36,7 @@ It would be appreciated if there are any Java VTK experts who could convert any
[Delaunay2D](/Java/Filtering/Delaunay2D) | vtkDelaunay2D | An example to generate set of points and to triangulate using Delaunay2D
[Glyph2D](/Java/Filtering/Glyph2D) | vtkGlyph2D | Example to copy a polydata to everypoint in the input set.
[Glyph3D](/Java/Filtering/Glyph3D) | vtkGlyph3D | This example applies an object at every point using vtkGlyph3D
[WarpTo](/Java/Filtering/WarpTo) | vtkWarpTo | Deform geometry by warping towards a point
## GeometricObjects
......
import vtk.vtkRenderWindow;
import vtk.vtkActor;
import vtk.vtkLineSource;
import vtk.vtkTubeFilter;
import vtk.vtkWarpTo;
import vtk.vtkNativeLibrary;
import vtk.vtkPolyDataMapper;
import vtk.vtkNamedColors;
import vtk.vtkRenderer;
import vtk.vtkRenderWindowInteractor;
public class WarpTo
{
//-----------------------------------------------------------------
// 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("Silver", actorColor);
colors.GetColor("MidnightBlue", Bgcolor);
//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);
//Create a line
vtkLineSource LineSource = new vtkLineSource();
LineSource.SetPoint1(0, 0, 0);
LineSource.SetPoint2(0, 1, 0);
LineSource.SetResolution(20);
LineSource.Update();
//Create a tube (cylinder) around the line
vtkTubeFilter TubeFilter = new vtkTubeFilter();
TubeFilter.SetInputConnection(LineSource.GetOutputPort());
TubeFilter.SetRadius(0.01);
TubeFilter.SetNumberOfSides(50);
TubeFilter.Update();
vtkWarpTo WarpTo = new vtkWarpTo();
WarpTo.SetInputConnection(TubeFilter.GetOutputPort());
WarpTo.SetPosition(10, 1, 0);
WarpTo.SetScaleFactor(5);
WarpTo.AbsoluteOn();
//Create a Mapper and Actor
vtkPolyDataMapper mapper = new vtkPolyDataMapper();
mapper.SetInputConnection(WarpTo.GetOutputPort());
mapper.ScalarVisibilityOff();
vtkActor actor = new vtkActor();
actor.SetMapper(mapper);
actor.GetProperty().SetColor(actorColor);
ren.AddActor(actor);
ren.SetBackground(Bgcolor);
renWin.SetSize(300, 300);
renWin.Render();
iren.Initialize();
iren.Start();
}
}
### Description
vtkWarpTo object is a filter that modifies point coordinates by moving the points towards a user specified position.
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