[vtkusers] vtkStructuredPoints question

jose manjon jmanjon at fis.upv.es
Thu Sep 27 13:37:46 EDT 2001


Hi All,

I have 200 MRI images of 256x256 covering all the brain and I have done
a DICOM class in VC++ for reading them so I have the data on a
double [n x windth x height]

now I want to make a volume rendering of this data in my program.

I puted my data on a vtkStructuredPoints object and I put it them on
a vtkStructuredPointsSource for passing to a  vtkVolumeTextureMapper2D
object ¿is this right?¿why dont works?

the code I putted in the view  is this:


 // reading my data

  data=vtkStructuredPoints::New();
 data->SetDimensions(pDoc->m_ani[0].Rows,pDoc->m_ani[0].Columns,pDoc->fuentes);

  data->SetScalarType(VTK_UNSIGNED_LONG);
  data->SetNumberOfScalarComponents(1);
  data->AllocateScalars();

  unsigned long * ptr=(unsigned long *) data->GetScalarPointer();

  for(int i=0;i<pDoc->fuentes;i++)
  for(int y=0;y<pDoc->m_ani[0].Columns;y++)
  for(int x=0;x<pDoc->m_ani[0].Rows;x++)
  {
           *ptr++ = pDoc->m_ani[i].PixelData[y*pDoc->m_ani[0].Rows+x];
  }

  vtkStructuredPointsSource * datos=vtkStructuredPointsSource::New();
  datos->SetOutput(data);

  // using LOD

        vtkLODProp3D *volumeLOD;
        volumeLOD=vtkLODProp3D::New();

  // Create a transfer function mapping scalar value to opacity
        vtkPiecewiseFunction *opacity = vtkPiecewiseFunction::New();
        opacity->AddPoint(0.0,0.0);
     opacity->AddPoint(250,1.0);

     vtkColorTransferFunction
*colorTransferFunction=vtkColorTransferFunction::New();
        colorTransferFunction->AddRGBPoint(100.0,0.0,0.0,0.0);
        colorTransferFunction->AddRGBPoint(255.0,1.0,1.0,1.0);

        // Create a property for the volume and set the transfer
functions.
        vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
        volumeProperty->SetColor(colorTransferFunction);
        volumeProperty->SetScalarOpacity(opacity);

        // LOD Level of detail

        vtkImageResample *resampler1=vtkImageResample::New();
        resampler1->SetInput(datos->GetOutput());
        resampler1->SetAxisMagnificationFactor(0,0.2);
        resampler1->SetAxisMagnificationFactor(1,0.2);
        resampler1->SetAxisMagnificationFactor(2,0.2);

        vtkImageResample *resampler2=vtkImageResample::New();
        resampler2->SetInput(datos->GetOutput());
        resampler2->SetAxisMagnificationFactor(0,0.6);
        resampler2->SetAxisMagnificationFactor(1,0.6);
        resampler2->SetAxisMagnificationFactor(2,0.6);

        vtkVolumeTextureMapper2D
*lowresMapper=vtkVolumeTextureMapper2D::New();
        lowresMapper->SetInput(resampler1->GetOutput());

        vtkVolumeTextureMapper2D
*medresMapper=vtkVolumeTextureMapper2D::New();
        medresMapper->SetInput(resampler2->GetOutput());

        vtkVolumeTextureMapper2D
*hiresMapper=vtkVolumeTextureMapper2D::New();
        hiresMapper->SetInput(datos->GetOutput());

        volumeLOD->AddLOD(lowresMapper,volumeProperty,0.0);
        volumeLOD->AddLOD(medresMapper,volumeProperty,0.0);
        volumeLOD->AddLOD(hiresMapper,volumeProperty,0.0);

  // render

  this->Renderer->AddProp(volumeLOD);
  this->Renderer->ResetCamera();

  this->vtkMFCRenderView::OnUpdate(pSender, lHint, pHint);

thanks

jose




More information about the vtkusers mailing list