[vtkusers] why is interacting with an assembly of many vtkLODActors much slower than interacting directly with many vtkLODActors?

Tracy Hu tracy.hu at yahoo.com
Fri May 8 18:23:16 EDT 2009


I added a bunch of vtkLODActor into a renderer and set  up abortcheck event. Interacting with window is quick. But if I put all vtkLODActors into an vtkAssembly and add only that assembly into renderer, the interaction with window become much slower although the assembly also becomes point cloud during interaction. Is there any way to make interaction with assembly quicker or it's just not possible?

Thanks a lot for any hint

Tracy

====================================
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkStructuredPointsReader.h"
#include "vtkPiecewiseFunction.h"
#include "vtkVolumeProperty.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkVolumeRayCastMapper.h"
#include "vtkVolume.h"
#include "vtkColorTransferFunction.h"
#include "vtkCamera.h"
#include "vtkStructuredPoints.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkCommand.h"
#include "time.h"
#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkLODActor.h"
#include "vtkConeSource.h"
#include "vtkGlyph3D.h"
#include "vtkAssembly.h"
#include "vtkProp3DCollection.h"

class InteractionCallBack : public vtkCommand {

public:

  static InteractionCallBack* New() {
    return new InteractionCallBack;
  }

  virtual void Execute(vtkObject* caller, unsigned long, void* data) {
    vtkRenderWindow* renWin = vtkRenderWindow::SafeDownCast(caller);
    if (renWin->GetEventPending()) {
      renWin->SetAbortRender(1);
    }
  }

};

int main( int argc, char *argv[] )
{

    vtkSphereSource *sphere = vtkSphereSource::New();
        sphere->SetThetaResolution(80);
        sphere->SetPhiResolution(80);

    vtkConeSource *cone = vtkConeSource::New();
    vtkGlyph3D *glyph = vtkGlyph3D::New();
        glyph->SetInputConnection(sphere->GetOutputPort());
        glyph->SetSourceConnection(cone->GetOutputPort());
        glyph->SetVectorModeToUseNormal();
        glyph->SetScaleModeToScaleByVector();
        glyph->SetScaleFactor(0.5);
    vtkPolyDataMapper *spikeMapper = vtkPolyDataMapper::New();
        spikeMapper->SetInput(glyph->GetOutput());
    vtkLODActor *spikeActor = vtkLODActor::New();
        spikeActor->SetMapper(spikeMapper);


    vtkRenderer *renderer = vtkRenderer::New();
        renderer->SetBackground(0.5, 0.5, 0.5);
        renderer->AddActor(spikeActor);
        renderer->ResetCamera();


    //make a lot of spike actors
    vtkAssembly *assembly = vtkAssembly::New();
    renderer->AddActor(assembly);
    for(int i=0; i<200; ++i)
    {
        vtkLODActor *actor = vtkLODActor::New();
        actor->SetMapper(spikeMapper);
        actor->SetPosition(i*0.1, 0.0, 0.0);
       // renderer->AddActor(actor);  //this line is used if next line is comment out.
        assembly->AddPart(actor);  //this line is used if above line is comment out
    }

    vtkRenderWindow *renWindow = vtkRenderWindow::New();
        renWindow->SetSize(400,400);
        renWindow->SetPosition(600, 400);
        renWindow->AddRenderer(renderer);
    vtkRenderWindowInteractor *interactor = vtkRenderWindowInteractor::New();
        interactor->SetRenderWindow(renWindow);
    vtkInteractorStyleTrackballCamera *style = vtkInteractorStyleTrackballCamera::New();
        interactor->SetInteractorStyle(style);

    InteractionCallBack* icb = InteractionCallBack::New();
    renWindow->AddObserver(vtkCommand::AbortCheckEvent, icb);
    
   

    renWindow->Render();

    

    interactor->Start();

    return 0;

}







      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090508/d7f764a4/attachment.htm>


More information about the vtkusers mailing list