[vtkusers] vtkStructuredPoints question

Lisa Sobierajski Avila lisa.avila at kitware.com
Thu Sep 27 22:55:08 EDT 2001


Hello Jose,

There are a couple of problems. First, you generally don't set the output 
of a source or filter - this is something generated for you. You do not 
need the structured points source - you can just use the data you create 
directly.

Second, vtkVolumeTextureMapper2D can handle only unsigned short or unsigned 
char input data - you'll need to produce data in this format or use 
something like vtkImageShiftScale to convert.

Lisa



At 01:37 PM 9/27/2001, jose manjon wrote:
>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
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: 
><http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers





More information about the vtkusers mailing list