[vtkusers] Rendering slow with multiple actors
Jothy
jothybasu at gmail.com
Tue Jul 19 16:11:57 EDT 2011
Hi all,
I am trying to overlay some ROIs on DICOM slices, cut from several
(e.g:10) surfaces. I instantiate vtkRenderer in the constructor of the
mainWindow as shown below
//Setup axial widget
this->axialRenderer=vtkRenderer::New();
vtkInteractorStyleImage *axialStyle = vtkInteractorStyleImage::New();
this->ui->AxialWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(axialStyle);
this->ui->AxialWidget->GetRenderWindow()->AddRenderer(this->axialRenderer);
and I cut the ROIs using vtkCutter from the meshes
as shown below
vtkActor* MainWindow::cutAxialROI(vtkPolyData* mesh,float
sliceNo,double R,double G,double B)
{
// Create a plane to cut
vtkSmartPointer<vtkPlane> plane =
vtkSmartPointer<vtkPlane>::New();
plane->SetOrigin(0,0,sliceNo);
plane->SetNormal(0,0,1);
// qDebug()<<sliceNo<<"ROI slice";
// Create cutter
vtkSmartPointer<vtkCutter> cutter =
vtkSmartPointer<vtkCutter>::New();
cutter->SetCutFunction(plane);
cutter->SetInput(mesh);
vtkSmartPointer<vtkPolyDataMapper> cutterMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
cutterMapper->SetInputConnection(cutter->GetOutputPort());
// Create plane actor
vtkActor* axialROI=vtkActor::New();
axialROI->GetProperty()->SetColor(R,G,B);
axialROI->GetProperty()->SetLineWidth(1.5);
axialROI->SetMapper(cutterMapper);
return axialROI;
axialROI->Delete();
}
When I repeat render at several planes , the rendering becomes slow
(1s for rendering). But I would expect even more faster, since it is
rendered faster in other programs using VTK.
Rendering is updated on axial scroll changed as shown below
this->axialRenderer->RemoveAllViewProps();
float scrollValue=this->ui->AxialScrollBar->value();
this->showAxial(scrollValue);
// create text for axial sliceNo
QString leftLowerText;
leftLowerText.append("Z:");
QString axialSliceValue;
axialSliceValue.setNum(scrollValue,'g',4);//
leftLowerText.append(axialSliceValue);
leftLowerText.append(" mm");
CO.createAnnotation(1,1,0,leftLowerText);
this->axialAnnotation=CO.annotation;
this->axialRenderer->AddViewProp(this->axialAnnotation);
for (int i=0;i<this->NumberOfROIs;i++)
{
double r=this->ROIColors[i][0]/255;
double g=this->ROIColors[i][1]/255;
double b= this->ROIColors[i][2]/255;
vtkActor* axialROI=vtkActor::New();
axialROI=this->cutAxialROI(this->meshList[i],scrollValue,r,g,b);
this->axialRenderer->AddActor(axialROI);
axialROI->Delete();
}
this->ui->AxialWidget->GetRenderWindow()->Render();
Is there anything wrong in the pipeline or any other efficient methods
of doing this?
Thanks
Jothy
More information about the vtkusers
mailing list