[vtkusers] Memory exeption using vtkActorCollection

johan.winell at dynamics.saab.se johan.winell at dynamics.saab.se
Fri Jul 6 10:10:22 EDT 2001


Hello users, 

I have a problem. When executing an exe-file build by the code below (using
Visual Studio), the application crashes due to a memory exeption. I have
located the problem to the vtkActorsCollection. As soon the parameter
"actcol" gets data the program crashes. 
Any suggestions to why?

Best Regards and have a nice weekend

/Johan Winell

----CODE--------------------------------------------------------------------
------
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRendererCollection.h"
#include "vtkActorCollection.h"
#include "vtkTransform.h"
#include "vtkSTLReader.h"
#include "vtk3DSImporter.h"
#include "vtkPolyDataMapper.h"
#include "vtkCamera.h"

main ()
{

  //int i;


  vtkRenderer *aren    = vtkRenderer::New();
  vtkRenderWindow *renWin  = vtkRenderWindow::New();
  renWin->AddRenderer(aren);
  renWin->SetSize(600, 300);
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);
  
  vtk3DSImporter *plane = vtk3DSImporter::New();
  plane->ComputeNormalsOn();
  plane->SetFileName("f14.3ds");
  plane->SetRenderWindow(renWin);

  vtk3DSImporter *ship = vtk3DSImporter::New();
  ship->ComputeNormalsOn();
  //is an aircraft actually
  ship->SetFileName("p38.3ds");
  ship->SetRenderWindow(renWin);

  vtkTransform *shiptrans = vtkTransform::New();
  shiptrans->Translate(0,0,6);
 

  vtkRendererCollection *rencol;
  rencol = renWin->GetRenderers();
  //vtkRenderer *ren1;
  aren = rencol->GetNextItem();
  vtkActorCollection *actcol;
  actcol = aren->GetActors();
  vtkActor *actor1;
  actor1 = actcol->GetNextItem();
  //ren1->GetActors()->GetNextItem()->SetUserTransform(shiptrans);
  actor1->SetUserTransform(shiptrans);
  
  // updating input and Startrendering
  
  plane->Update();
  ship->Update();
  renWin->Render();
  iren->Start();

  // Clean up
  aren->Delete();
  renWin->Delete();
  iren->Delete();
  ship->Delete();
  //ren1->Delete();
  rencol->Delete();
  actcol->Delete();
  actor1->Delete();
}
--------------------------------------------------------- 




More information about the vtkusers mailing list