[vtkusers] vtk actor disappearing

johnsonjonaris jgadel2 at uic.edu
Sun Jun 30 01:28:18 EDT 2013


Dear All
I am trying to mimic the behavior in the example posted in 
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Medical/GenerateModelsFromLabels
except that I want to display the generated labels as separate actors while
the example saves them into files which I successfully can do.
I have generated that code which threshold a vtkImage called brain using a
vtkImageThreshold, then generate a surface using marching cubes algorithm. I
loop over the different label values (lblValues is a vector of integer) by
changing the threshold value. Then I create a mapper and an actor to display
it in a renderer. The problem is that the actors appear then disappear one
by one.

    vtkSmartPointer<vtkImageThreshold> threshold =
vtkSmartPointer<vtkImageThreshold>::New();;
    threshold->SetOutValue(0);
    threshold->SetInput(brain);
    threshold->ReleaseDataFlagOn();
    vtkSmartPointer<vtkMarchingCubes> mcubes =
vtkSmartPointer<vtkMarchingCubes>::New();
    mcubes->SetInputConnection(threshold->GetOutputPort());
    for (uint i = 0;i <5;i++) { 
        threshold->ThresholdBetween(lblValues(i),lblValues(i));
        mcubes->SetValue(0,lblValues(i));
        vtkSmartPointer<vtkPolyDataMapper> isoMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
        isoMapper->SetInput(mcubes->GetOutput());
        vtkSmartPointer<vtkActor> isoActor =
vtkSmartPointer<vtkActor>::New();
        isoActor->SetMapper(isoMapper);
        renderer->AddActor(isoActor);
        renWin->Render();
    }


Thanks
Johnson



-----
Johnson Jonaris 
PhD Candidate
Electrical & Computer Eng 
University of IL at Chicago
--
View this message in context: http://vtk.1045678.n5.nabble.com/vtk-actor-disappearing-tp5721684.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list