[vtkusers] actor not showing
johnsonjonaris
jgadel2 at uic.edu
Thu Jun 27 22:31:42 EDT 2013
Dear All
I made a pipeline which visualize a set of shapes from a vtkImageData volume
with integral data (integer values). The pipeline executes but the output is
not rendered in the rendering window, although I can save the output and
load it in PARAVIEW.
Moreover, I know that the actors I create are there since I can probe their
color property later.
Please help
the code is:
vtkSmartPointer<vtkImageThreshold> threshold =
vtkSmartPointer<vtkImageThreshold>::New();;
threshold->SetOutValue(0);
threshold->SetInput(brain3D);
threshold->ReleaseDataFlagOn();
vtkSmartPointer<vtkImageToStructuredPoints> imgToStrPnts =
vtkSmartPointer<vtkImageToStructuredPoints>::New();
imgToStrPnts->SetInputConnection(threshold->GetOutputPort());
imgToStrPnts->ReleaseDataFlagOn();
// create an isosurface, note that vtkMarchingCubes is better than
// vtkContourFilter
vtkSmartPointer<vtkMarchingCubes> mcubes =
vtkSmartPointer<vtkMarchingCubes>::New();
mcubes->SetInputConnection(imgToStrPnts->GetOutputPort());
mcubes->ComputeNormalsOff();
mcubes->ComputeGradientsOff();
mcubes->ComputeScalarsOff();
mcubes->GetOutput()->ReleaseDataFlagOn();
// try to reduce the number of triangles
vtkSmartPointer<vtkDecimatePro> decimator =
vtkSmartPointer<vtkDecimatePro>::New();
decimator->SetInputConnection(mcubes->GetOutputPort());
decimator->SetFeatureAngle(60);
decimator->SetMaximumError(1);
decimator->SplittingOff();
decimator->PreserveTopologyOn();
decimator->SetTargetReduction(0.5);
decimator->ReleaseDataFlagOn();
// smooth the result of the iso vtkMarchingCubes
vtkSmartPointer<vtkWindowedSincPolyDataFilter> smoother =
vtkSmartPointer<vtkWindowedSincPolyDataFilter>::New();
smoother->SetInputConnection(decimator->GetOutputPort());
smoother->SetNumberOfIterations(10);
smoother->BoundarySmoothingOff();
smoother->FeatureEdgeSmoothingOff();
smoother->SetPassBand(0.1);
smoother->GetOutput()->ReleaseDataFlagOn();
// compute normals and point normals
vtkSmartPointer<vtkPolyDataNormals> normals =
vtkSmartPointer<vtkPolyDataNormals>::New();
normals->SetInputConnection(smoother->GetOutputPort());
normals->ComputePointNormalsOn();
normals->SetFeatureAngle(60);
normals->SetSplitting(true);
normals->ReleaseDataFlagOn();
// stripper: create triangle out of polygons
vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer< vtkStripper
>::New();
stripper->SetInputConnection(normals->GetOutputPort());
stripper->GetOutput()->ReleaseDataFlagOn();
// map smoothed data
vtkSmartPointer<vtkPolyDataMapper> isoMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
isoMapper->SetInputConnection(stripper->GetOutputPort());
isoMapper->ScalarVisibilityOff(); // utilize actor's property I set
// render isosurfaces
for (uint i = 0;i <20;i++) {
// update the threshold according to the new label
threshold->ThresholdBetween(lblValues(i),lblValues(i)); // lblValues
contain the values of the labels
mcubes->SetValue(0,lblValues(i));
stripper->GetOutput()->Update();
// create actor
vtkSmartPointer<vtkActor> isoActor =
vtkSmartPointer<vtkActor>::New();
isoActor->SetMapper(isoMapper);
isoMapper->Update();
QColor c = ctable.at(lblValues(i));
isoActor->GetProperty()->SetColor(c.red()/255.0,c.green()/255.0,c.blue()/255.0);
lblsActors.append(isoActor);
MainRenderer->AddActor(isoActor);
vtkWidget->GetRenderWindow()->Render();
}
Regards
Johnson
-----
Johnson Jonaris
PhD Candidate
Electrical & Computer Eng
University of IL at Chicago
--
View this message in context: http://vtk.1045678.n5.nabble.com/actor-not-showing-tp5721647.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list