[vtkusers] help with marchingcubes with dicom slices set

Rodrigo Lovera lobo.theslayer at gmail.com
Fri Nov 16 16:16:24 EST 2012


Hello everyone,

I've got a set of dicom slices which I use for rendering a volume, now I
tried to apply marching cubes to try surface rendering buy i'm only getting
some kind of box and not the head that shold be forming.

I'm using atm the following code

vtkSmartPointer< vtkDICOMImageReader > reader =
vtkSmartPointer< vtkDICOMImageReader >::New();
reader->SetDataByteOrderToLittleEndian();
//reader->SetDirectoryName(argv[1]);
reader->SetDirectoryName("C:\\VTK5.10\\DATA\\DICOM");
reader->SetDataSpacing(1, 1, 1);
reader->SetDataOrigin(0.0, 0.0, 0.0);
reader->Update();

vtkSmartPointer< vtkMarchingCubes > surface =
vtkSmartPointer< vtkMarchingCubes >::New();
surface->SetInputConnection(reader->GetOutputPort());
surface->ComputeNormalsOn();
surface->SetValue(0, 5);
 vtkSmartPointer< vtkRenderer > surfacerenderer =
vtkSmartPointer< vtkRenderer >::New();
surfacerenderer->SetBackground(0.1, 0.2, 0.3);

vtkSmartPointer< vtkRenderWindow > renderwin =
vtkSmartPointer< vtkRenderWindow >::New();
renderwin->AddRenderer(surfacerenderer);
 vtkSmartPointer< vtkRenderWindowInteractor > intersurf =
vtkSmartPointer< vtkRenderWindowInteractor >::New();
intersurf->SetRenderWindow(renderwin);

vtkSmartPointer< vtkPolyDataNormals > premapper =
vtkSmartPointer< vtkPolyDataNormals >::New();
premapper->SetInputConnection(surface->GetOutputPort());
premapper->ComputeCellNormalsOn();
 vtkSmartPointer< vtkPolyDataMapper > surfacemapper =
vtkSmartPointer< vtkPolyDataMapper >::New();
surfacemapper->SetInputConnection(premapper->GetOutputPort());
//surfacemapper->SetInputConnection(surface->GetOutputPort());

vtkSmartPointer< vtkActor > actor =
vtkSmartPointer< vtkActor >::New();
actor->SetMapper(surfacemapper);

vtkSmartPointer< vtkProperty > backFaces =
vtkSmartPointer< vtkProperty >::New();
backFaces->SetSpecular(0.0);
backFaces->SetDiffuse(0.0);
backFaces->SetAmbient(1.0);
backFaces->SetAmbientColor(1.0000, 0.3883, 0.2784);
backFaces->SetOpacity(256);

actor->SetBackfaceProperty(backFaces);

surfacerenderer->AddActor(actor);
renderwin->SetSize(800,600);
//renderWindow->Render();
intersurf->Start();

this->ui->vtksurface->GetRenderWindow()->AddRenderer(surfacerenderer);

I'd appreciate any kind of help, example code or advice. Thx in advance.

-- 
*Rodrigo Lovera *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121116/830994a0/attachment.htm>


More information about the vtkusers mailing list