[vtkusers] I just get an isosurface with vtkSurfaceReconstructionFilter and vtkContourFilter?
David Jakobsson
david.jakobsson at weaidu.com
Thu Jun 23 04:46:07 EDT 2005
Hi all,
I have an unorganized point cloud of a surface, x, y and z-coordinates, with a scalar value for each point. I make a vtkPolyData object of the points and scalars, and then I use vtkSurfaceReconstructionFilter and vtkContrastFilter to generate a surface and display it. It works fine except I just get an isosurface. I wish to see the scalars on the surface. How do I achieve that and what am I doing wrong???
Any help is greatly appreciated! I started to learn VTK last week.
Thank you for your time,
David
Below is parts of my code (Java):
...
// Points
vtkPoints p = new vtkPoints();
// Vertices
vtkCellArray verts = new vtkCellArray();
// Scalars
vtkDoubleArray intensities = new vtkDoubleArray();
int index = 0;
for (int i = 0; i < borders.sliceCount(); i++) {
for (int j = 0; j < borders.rowCount(); j++) {
for (int k = 0; k < borders.columnCount(); k++) {
if (borders.getBoolean(i, j, k)) {
p.InsertPoint(index, i, j, k);
verts.InsertNextCell(1);
verts.InsertCellPoint(index);
intensities.InsertTuple1(index, intensities);
index++;
}
}
}
}
// Insert points, vertices and scalars
pointCloud = new vtkPolyData();
pointCloud.SetPoints(p);
pointCloud.SetVerts(verts);
pointCloud.GetPointData().SetScalars(intensities);
// Contruct a surface reconstruction filter
vtkSurfaceReconstructionFilter surfaceFilter = new vtkSurfaceReconstructionFilter();
surfaceFilter.SetInput(pointCloud);
vtkImageData id = surfaceFilter.GetOutput();
// Contour filter
vtkContourFilter cf = new vtkContourFilter();
cf.SetInput(id);
cf.SetValue(0,0);
brainSurface = cf.GetOutput();
...
vtkPolyDataMapper pointMapper = new vtkPolyDataMapper();
pointMapper.SetInput(bss.getPointCloud());
pointMapper.ScalarVisibilityOff();
vtkPolyDataMapper surfaceMapper = new vtkPolyDataMapper();
surfaceMapper.SetInput(bss.getBrainSurface());
surfaceMapper.SetScalarRange(0,1000);
surfaceMapper.ScalarVisibilityOn();
vtkActor pointActor = new vtkActor();
pointActor.SetMapper(pointMapper);
vtkActor surfaceActor = new vtkActor();
surfaceActor.SetMapper(surfaceMapper);
// Remove light
surfaceActor.GetProperty().SetAmbient(1);
surfaceActor.GetProperty().SetDiffuse(0);
surfaceActor.GetProperty().SetSpecular(0);
vtkRenderer ren1 = new vtkRenderer();
ren1.AddActor(pointActor);
ren1.SetBackground(0.1, 0.2, 0.4);
ren1.SetViewport(0.0, 0.0, 0.5, 1.0);
vtkRenderer ren2 = new vtkRenderer();
ren2.AddActor(surfaceActor);
ren2.SetBackground(0.1, 0.2, 0.4);
ren2.SetViewport(0.5, 0.0, 1.0, 1.0);
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer(ren1);
renWin.AddRenderer(ren2);
renWin.SetSize(600, 300);
More information about the vtkusers
mailing list