[vtkusers] HELP! vtkImagePlaneWidget causing an access violation in vtkimaging.dll

Alex Peckham ap0345 at bris.ac.uk
Thu Mar 4 18:01:42 EST 2004


Hi,

I today discovered a problem whereby after interacting with a 
vtkImagePlaneWidget for several minutes (5 or 6) an access violation 
sometimes occurs. The thing is I have no idea how to correct this 
because the access violation is occuring in vtkimaging.dll and not my 
application itself...

Here is the error:

AppName: accessviolate.exe     AppVer: 0.0.0.0     
ModName: vtkimaging.dll
ModVer: 0.0.0.0     Offset: 0013e702

My code is below. It uses vtkBMPReader to read a volume, the volume 
rendering works fine.. but I need to use the vtkImagePlaneWidget to show 
a slice through the volume interactively... this works perfectly too 
except for the seemingly random access violation..

Am I doing something wrong? I can't see any problems, and it all 
compiles perfectly with MS Visual C 6.0...
Any help would be very much appreciated!

Thanks,

Alex Peckham
University of Bristol

// We create the basic parts of a pipeline and connect them
  this->renderer = vtkRenderer::New();
  this->renWin = vtkRenderWindow::New();
  this->renWin->AddRenderer(this->renderer);

  // setup the parent window
  this->renWin->SetParentId(hwnd);
  this->iren = vtkRenderWindowInteractor::New();
  this->iren->SetRenderWindow(this->renWin);

  this->renderer->SetBackground(0.2,0.4,0.3);
  this->renWin->SetSize(1000,1000);

    this->BMPreader = vtkBMPReader::New();
    this->BMPreader->SetDataSpacing(1.0,1.0,1.0);
    this->BMPreader->SetDataExtent(0,180,0,144,0,30);
    this->BMPreader->SetFilePrefix("G:/project/scratch/sub.bmp");
    this->BMPreader->SetDataScalarTypeToShort();
    this->BMPreader->Update();

    this->volLum = vtkImageLuminance::New();
    this->volLum->SetInput(this->BMPreader->GetOutput());
    this->volLum->Update();
       
    this->outline = vtkOutlineFilter::New();
    this->outline->SetInput((vtkDataSet*)this->BMPreader->GetOutput());

    this->outlineMapper = vtkPolyDataMapper::New();
    this->outlineMapper->SetInput(this->outline->GetOutput());
           
    this->outlineActor = vtkActor::New();
    this->outlineActor->SetMapper(outlineMapper);

    this->opacityTransferFunction = vtkPiecewiseFunction::New();

    this->opacityTransferFunction->AddPoint(0.0,   1.0);
    this->opacityTransferFunction->AddPoint(32.0,  1.0);
    this->opacityTransferFunction->AddPoint(64.0,  1.0);
    this->opacityTransferFunction->AddPoint(96.0,  1.0);
    this->opacityTransferFunction->AddPoint(128.0, 1.0);
    this->opacityTransferFunction->AddPoint(160.0, 1.0);
    this->opacityTransferFunction->AddPoint(192.0, 1.0);
    this->opacityTransferFunction->AddPoint(224.0, 1.0);
    this->opacityTransferFunction->AddPoint(255.0, 1.0);

    this->greyfun = vtkPiecewiseFunction::New();
   
    this->greyfun->AddPoint(0.0,   0.0);
    this->greyfun->AddPoint(16.0,  0.0625);
    this->greyfun->AddPoint(32.0,  0.125);
    this->greyfun->AddPoint(48.0,  0.1875);
    this->greyfun->AddPoint(64.0,  0.25);
    this->greyfun->AddPoint(80.0,  0.3125);
    this->greyfun->AddPoint(96.0,  0.375);
    this->greyfun->AddPoint(112.0, 0.4375);
    this->greyfun->AddPoint(128.0, 0.5);
    this->greyfun->AddPoint(144.0, 0.5625);
    this->greyfun->AddPoint(160.0, 0.625);
    this->greyfun->AddPoint(176.0, 0.6875);
    this->greyfun->AddPoint(192.0, 0.75);
    this->greyfun->AddPoint(208.0, 0.8125);
    this->greyfun->AddPoint(224.0, 0.875);
    this->greyfun->AddPoint(240.0, 0.9375);
    this->greyfun->AddPoint(255.0, 1.0);

    this->volumeProperty = vtkVolumeProperty::New();

  this->volumeProperty->SetColor(greyfun);
  this->volumeProperty->SetScalarOpacity(opacityTransferFunction);
    //this->volumeProperty->ShadeOn();
  this->volumeProperty->SetInterpolationTypeToLinear();
    
    // Now define raycast function

    this->raycastFunction = vtkVolumeRayCastCompositeFunction::New();

    this->volumeMapper = vtkVolumeRayCastMapper::New();
  this->volumeMapper->SetVolumeRayCastFunction(raycastFunction);
    this->volumeMapper->SetInput(volLum->GetOutput());

    this->volume = vtkVolume::New();
  this->volume->SetMapper(volumeMapper);
  this->volume->SetProperty(volumeProperty);

    //this->renderer->AddVolume(this->volume); just want to see the 
plane for now
    this->renderer->AddActor(outlineActor);

    this->planeWidget = vtkImagePlaneWidget::New();
    this->planeWidget->PlaceWidget(0,100,0,100,0,100);
    this->planeWidget->SetInteractor(this->iren);
   
    this->planeWidget->SetInput((vtkDataSet*)this->volLum->GetOutput());
    this->planeWidget->On();

  // Finally we start the interactor so that event will be handled
  this->renWin->Render();





More information about the vtkusers mailing list