[vtkusers] Slicing on the VTK points
Maarten Beek
beekmaarten at yahoo.com
Tue Nov 5 09:25:20 EST 2013
In the past, I have used vtkExtractPolyDataGeometry with a vtkBoxWidget2 to get 6 planes for the implicit function. Worked with a triangulated surface; can't see why it wouldn't work with vertices.
Maarten
On Tuesday, November 5, 2013 6:09:24 AM, mahendra <mahendra123awale at gmail.com> wrote:
OK let me try one more time!
Below is java source code, which generate the vtkpoints and displays it.
The attached image shows the generated view
//========================================================================================
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import vtk.*;
public class cutter {
static vtkRenderWindowPanel renderWindowPanel = new
vtkRenderWindowPanel();
static vtkPoints points = new vtkPoints();
static vtkPointData pointdata = new vtkPointData();
static vtkUnsignedCharArray colors = new vtkUnsignedCharArray();
static vtkCellArray vtkCellArray = new vtkCellArray();
static vtkPolyData polydata = new vtkPolyData();
static vtkPolyDataMapper mainMapper = new vtkPolyDataMapper();
static vtkInteractorStyleTrackballCamera vInStylCamera = new
vtkInteractorStyleTrackballCamera();
static vtkActor mainActor = new vtkActor();
static vtkInteractorStyleImage vInStylImage = new
vtkInteractorStyleImage();
static {
System.loadLibrary("vtkCommonJava");
System.loadLibrary("vtkFilteringJava");
System.loadLibrary("vtkIOJava");
System.loadLibrary("vtkImagingJava");
System.loadLibrary("vtkGraphicsJava");
System.loadLibrary("vtkRenderingJava");
}
public static void main(String[] args) throws FileNotFoundException,
IOException {
//Read the points
readPoints02();
polydata.SetPoints(points);
polydata.GetPointData().SetScalars(colors);
polydata.SetVerts(vtkCellArray);
mainMapper.SetInput(polydata);
//create a plane to cut
vtkPlane plane = new vtkPlane();
plane.SetOrigin(mainMapper.GetInput().GetCenter());
plane.SetNormal(1, 0, 0);
//create cutter, map it and set the actor
vtkCutter cutter = new vtkCutter();
cutter.SetCutFunction(plane);
cutter.SetInput(mainMapper.GetInput());
cutter.Update();
vtkPolyDataMapper cutterMapper = new vtkPolyDataMapper();
cutterMapper.SetInputConnection(cutter.GetOutputPort());
//create plane actor
vtkActor planeActor = new vtkActor();
planeActor.GetProperty().SetColor(1.0, 1, 0);
planeActor.GetProperty().SetLineWidth(20);
planeActor.SetMapper(cutterMapper);
//Another actor for my data
vtkActor myActor = new vtkActor();
myActor.SetMapper(mainMapper);
//create renderers and add actors of plane and cube
vtkRenderer ren = new vtkRenderer();
ren.AddActor(planeActor);
ren.AddActor(myActor);
//Add renderer to renderwindow and render
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer(ren);
renWin.SetSize(600, 600);
vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow(renWin);
ren.SetBackground(0, 0, 0);
renWin.Render();
iren.Start();
}
static void readPoints02() throws FileNotFoundException, IOException {
colors.SetNumberOfComponents(3);
for (int a = 0; a < 10000; a++) {
double randomX = Math.random();
double randomY = Math.random();
double randomZ = Math.random();
points.InsertPoint(a, randomX*300, randomY*300, randomZ*300);
vtkCellArray.InsertNextCell(1);
vtkCellArray.InsertCellPoint(a);
colors.InsertTuple3(a, 255, 255, 0);
}
}
}
//=====================================================================================
<http://vtk.1045678.n5.nabble.com/file/n5724301/view.png>
I wanted to allow user to make the cut on this points with predefined box. I
mean user should place the box where he want and i want to display only
those part (subparts of the whole view).
Looking forward for suggestions!!!!
Thanks
--
View this message in context: http://vtk.1045678.n5.nabble.com/Slicing-on-the-VTK-points-tp5724228p5724301.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131105/e12eea14/attachment.html>
More information about the vtkusers
mailing list