[vtkusers] Use marching cubes on MINC data
Tanweer Rashid
trash001 at odu.edu
Mon Mar 12 13:28:54 EDT 2012
Hi all,
I am trying to extract surfaces from a MINC (.mnc) data file using
vtkMarchingCubes. The code I am using is based on the VTK wiki's Marching
cubes on a sphere example, and is as follows:
void marching_cubes() {
vtkMINCImageReader* minc = vtkMINCImageReader::New();
minc->SetFileName("/home/trash001/Desktop/AtlasGrey.mnc");
vtkVoxelModeller* voxelModeller = vtkVoxelModeller::New();
voxelModeller->SetSampleDimensions(197, 233, 189);
voxelModeller->SetModelBounds(-98, 99, -134, 99, -72, 117);
voxelModeller->SetScalarTypeToFloat();
voxelModeller->SetMaximumDistance(.01);
voxelModeller->SetInputConnection(minc->GetOutputPort());
vtkMarchingCubes* surface = vtkMarchingCubes::New();
surface->SetInputConnection(voxelModeller->GetOutputPort());
surface->ComputeNormalsOn();
surface->SetValue(0, 0.5);
vtkRenderer* renderer = vtkRenderer::New();
renderer->SetBackground(.1, .2, .3);
vtkRenderWindow* renderWindow = vtkRenderWindow::New();
renderWindow->AddRenderer(renderer);
vtkRenderWindowInteractor* interactor =
vtkRenderWindowInteractor::New();
interactor->SetRenderWindow(renderWindow);
vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
mapper->SetInputConnection(surface->GetOutputPort());
vtkActor* actor = vtkActor::New();
actor->SetMapper(mapper);
renderer->AddActor(actor);
renderWindow->Render();
interactor->Start();
return;
}
When I run this code, I get a blank window. I suspect that the problem is
that I cannot provide the MINC data to vtkMarchingCubes in a suitable
format, but I could be wrong. Any help would be appreciated.
Thanks,
--
Tanweer Rashid
Graduate Teaching & Research Assistant
Department of Modeling, Simulation and Visualization Engineering
Old Dominion University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120312/ac0a4a32/attachment.htm>
More information about the vtkusers
mailing list