[vtkusers] Segmentation Fault on vtkRenderWindowInteractor

Marcio Cabral mcabral at lsi.usp.br
Tue Sep 10 12:12:23 EDT 2002


Hi there,

I am running into trouble when I click on the window just opened. The
program crashes seg faulting. Here is the problem (using gdb):

vtkObject::Register(vtkObject*) (this=0x0, .....)
                this->ReferenceCount++;

called by:

    vtkInteractorStyle::FindPokedRenderer(int,int) ( this=0x80500118, x =
128, y = 129)
                this->CurrentRenderer->Register(this);

Does anyone know why the pointer is NULL?

Here is the sample code I am using:

#include "vtkConeSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkVolumeProVP1000Mapper.h"
#include "vtkVolumeProMapper.h"
#include "vtkVolume16Reader.h"
#include "vtkVolume.h"
#include "vtkRenderer.h"
#include "vtkStructuredPointsReader.h"
#include "vtkStructuredPoints.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderWindow.h"
#include "vtkPiecewiseFunction.h"
#include "vtkColorTransferFunction.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkVolumeRayCastMapper.h"


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

  vtkRenderer *ren1 = vtkRenderer::New();
  vtkRenderWindow *renWin = vtkRenderWindow::New();
  renWin->SetSize( 300, 300 );
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);

  //create the reader for the volume
  vtkStructuredPointsReader *reader = vtkStructuredPointsReader::New();
  reader->SetFileName("/usr/VTKData/Data/ironProt.vtk");
  reader->Update();

  //create transfer mapping opacity
  vtkPiecewiseFunction *opacityTransferFunction =
vtkPiecewiseFunction::New();
  opacityTransferFunction->AddPoint(20,0.0);
  opacityTransferFunction->AddPoint(255,0.2);

  //create transfer mapping color
  vtkColorTransferFunction *colorTransferFunction =
vtkColorTransferFunction::New();
  colorTransferFunction->AddRGBPoint(0.0,0.0,0.0,0.0);
  colorTransferFunction->AddRGBPoint(64.0,1.0,0.0,0.0);
  colorTransferFunction->AddRGBPoint(128.0,0.0,0.0,1.0);
  colorTransferFunction->AddRGBPoint(192.0,0.0,1.0,0.0);
  colorTransferFunction->AddRGBPoint(255.0,0.0,0.2,0.0);

  //volume property
  vtkVolumeProperty *volprot = vtkVolumeProperty::New();
  volprot->SetColor(colorTransferFunction);
  volprot->SetScalarOpacity(opacityTransferFunction);

  //raycast
  vtkVolumeRayCastCompositeFunction *compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
  vtkVolumeRayCastMapper *volumeMapper =   vtkVolumeRayCastMapper::New();
  volumeMapper->SetVolumeRayCastFunction(compositeFunction);
  volumeMapper->SetInput(reader->GetOutput());


  /*  //Volumepro mapper
  vtkVolumeProMapper *volumeMapper = vtkVolumeProMapper::New();
  */


  //volume holds the mapper and the property
  vtkVolume *volume = vtkVolume::New();
  volume->SetMapper(volumeMapper);

  ren1->AddVolume(volume);
  //renWin->Render();
  ren1->GetActiveCamera()->Azimuth(20.0);
  ren1->GetActiveCamera()->Dolly(1.60);


  vtkCamera *aCamera = vtkCamera::New();
  aCamera->SetViewUp ( 0, 0, -1);
  aCamera->SetFocalPoint(0, 0, 0);
  aCamera->ComputeViewPlaneNormal();

  ren1->SetActiveCamera(aCamera);
  ren1->ResetCamera();
  aCamera->Dolly(1.5);
  ren1->SetBackground(0,0,.5);

  iren->Initialize();
  iren->SetDesiredUpdateRate(1.0);
  iren->SetStillUpdateRate(0.001);
  iren->Start();

}




Thank's for any reply,

Regards,

_________________________
Marcio Calixto Cabral
Coordenador de Projetos - CAVERNA Digital
Universidade de Sao Paulo





More information about the vtkusers mailing list