[vtkusers] Volume export function -- need help

cspl affable at hd2.dot.net.in
Mon Oct 21 03:22:31 EDT 2002


Dear Friends,

I am working on vtkVolumeRaycastMIPFunction.I want to export ray castmip function o/p into buffer 

which is created by me.But it is giving runtime exception at export function.  Please give me 

suggestion.I have written code as follows. I have indicated the line of code raising the 

exception.

Volume *volMIP(Volume *vol)
{
 unsigned short *Buffer = NULL;
 Buffer = (unsigned short *) vol->Mem;
 

 vtkRenderer *renderer =vtkRenderer::New();
 vtkRenderWindow *renWin=vtkRenderWindow::New();
 
 vtkImageImport *Importer = vtkImageImport::New();
 Importer->SetDataExtent(1, vol->width, 1, vol->height, 1,  vol->depth);
 Importer->SetWholeExtent(1, vol->width, 1, vol->height, 1, vol->depth);
 Importer->SetDataScalarTypeToUnsignedShort( );
 Importer->SetImportVoidPointer(vol->Mem);   // Importing the Buffer
 

 
 vtkVolumeProperty *volumeProperty=vtkVolumeProperty::New();
 
 vtkVolumeRayCastIsosurfaceFunction *iso=vtkVolumeRayCastIsosurfaceFunction::New();
 vtkVolumeRayCastMapper *volumeMapper=vtkVolumeRayCastMapper::New();
 
 vtkVolumeRayCastCompositeFunction     

*compositeFunction=vtkVolumeRayCastCompositeFunction::New();
 
 vtkVolumeRayCastMIPFunction *mip=vtkVolumeRayCastMIPFunction ::New();
 vtkVolume *volume1=vtkVolume::New();
  
 
 vtkPiecewiseFunction *opacityTransferFunction=vtkPiecewiseFunction::New();
 opacityTransferFunction->AddPoint(20,0.0);
 opacityTransferFunction->AddPoint(255,0.3);

 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);

    
 volumeProperty->SetColor(colorTransferFunction);
 volumeProperty->SetScalarOpacity(opacityTransferFunction);
 volumeProperty->SetInterpolationTypeToLinear();
 volumeProperty->ShadeOn();
 mip->SetMaximizeMethodToScalarValue();
 mip->SetMaximizeMethodToOpacity();
  
 
 volumeMapper->SetVolumeRayCastFunction(compositeFunction);///for Raycast Technique

 volumeMapper->SetVolumeRayCastFunction(mip);
 
 volumeMapper->SetSampleDistance(0.25);
 volumeMapper->SetInput(Importer->GetOutput());
 
 volume1->SetMapper(volumeMapper);
 volume1->SetProperty(volumeProperty);
 
 vtkImageImport *Importer1 = vtkImageImport::New();
 Importer1->SetDataExtent(1, vol->width, 1, vol->height, 1, vol->depth);
 Importer1->SetWholeExtent(1, vol->width, 1, vol->height, 1, vol->depth);
 Importer1->SetDataScalarTypeToUnsignedShort( );
 Importer1->SetImportVoidPointer(volume1);
 vtkImageExport *Exporter = vtkImageExport::New();
 Exporter->SetInput(Importer->GetOutput());  

******* Exporter->Export(Buffer); // Exporting the buffer exception is coming here
 vol->Mem =Buffer;
 return vol;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20021021/c6199f42/attachment.htm>


More information about the vtkusers mailing list