[vtkusers] Performance problems with large number of actors

George Buzzell gbuzzell at memcad.com
Mon Jul 17 17:28:30 EDT 2000


I am experiencing very significant performance degradation when using a
large number (~1000) of actors composed of unstructured grids. Each of
these actors represent one part of an assembly; each part is to be
colored and added to the display individually. When the geometry is
added as a single actor, the performance is acceptable, though I cannot
color and select geometry directly. The performance problem results from
dividing the geometry into a number of separate actors.

Initially the code I developed created each actor with its own mapper,
then I switched to using a single mapper to alleviate the performance
degradation problem using an AppendFilter as its input (since the
mappers acommodate only a single input on their own), but the
performance only got worse.

Has anyone in vtkuser land run across and (hopefully solved) this
problem? I have scanned the archives and have found no mention of it
yet. My (rather dirty) assembly function code follows.

Thanks for your help,

G.B.


vtkAssembly *GetAssembly2()
{
  UGridReader *ugr = UGridReader::New(); //creates my multi-output
reader
  ugr->Initialize();
  vtkAssembly *assy = vtkAssembly::New();
  srand( 100 );
  float dval = RAND_MAX;
  int outputs = ugr->GetNumberOfOutputs();
  vtkDataSetMapper *ugridMapper = vtkDataSetMapper::New();
  vtkAppendFilter *ugridFilter = vtkAppendFilter::New();
  ugridMapper->SetInput(ugridFilter->GetOutput());
  ugridMapper->ImmediateModeRenderingOn();
 for (int i=0;i<outputs;i++)
  {
    float rvalr = rand()/dval;
    float rvalg = rand()/dval;
    float rvalb = rand()/dval;

    vtkUnstructuredGrid* ugrid = ugr->GetOutput(i);

    ugridFilter->AddInput(ugr->GetOutput(i));


    vtkActor *ugridActor = vtkActor::New();
      ugridActor->SetMapper(ugridMapper);
      ugridActor->GetProperty()->SetBackfaceCulling(1);
      ugridActor->GetProperty()->SetColor(0.8,
                                          rvalg==0.0?1.0:.8+rvalg,
                                          rvalb==0.0?1.0:.8+rvalb);
      ugridActor->AddPosition(0,0.001,0);

    vtkActor *wireActor = vtkActor::New();
      wireActor->SetMapper(ugridMapper);
      wireActor->GetProperty()->SetRepresentationToWireframe();
      wireActor->GetProperty()->SetColor(0,0,0);

      assy->AddPart(ugridActor);
      assy->AddPart(wireActor);

      //ugrid->Delete();
      //ugridMapper->Delete();
      ugridActor->Delete();
      wireActor->Delete();
  }
  ugridMapper->Delete();
  return (assy);
}






More information about the vtkusers mailing list