[vtkusers] problem with vtkvolume16reader->GetOutput()->GetScalarPointer()??

Veerapuram Varadhan v.varadhan at californiadigital.com
Tue May 4 04:58:11 EDT 2004


Hi Amy,

Probably we might have to reflect the said change in
VTK/Examples/Medical/Cxx/Medical1.cxx
VTK/Examples/Medical/Cxx/Medical2.cxx and
VTK/Examples/Medical/Cxx/Medical3.cxx
as well.

V. Varadhan.

> Hi Nicolas,
>
> This problem is very similar to your previous problem. In this case, the
> scalars haven't been filled in yet because the data has not been read from
> the file. Add v16->Update(); before you try to access this reader's
> output.
> This is true for all readers, filters, etc. in VTK. Their output is not
> valid until Update has been called on them. The VTK rendering process
> updates your visualization pipeline for you, which is why you don't have
> to
> call Update yourself if you are rendering the results without modifying
> them first.
>
> - Amy
>
> At 06:06 AM 5/1/2004, Dumont Nicolas wrote:
>>Hello users!!
>>
>>I wish to make a copy of my volume data in a new vtkimagedata object, so
>>after that i could modify the scalar data at the voxels (for example to
>>make a spherical hole inside the volume).
>>
>>The code I wrote works well with
>>
>>vtkPNGreader->GetOutput()->GetScalarPointer();
>>
>>but the same code adapted for
>>
>>vtkVolume16reader->GetOutput()->GetScalarPointer();
>>
>>returns me the error that GetScalarPointer() points to memory
>> 0x0000000000
>>and so cant be read.
>>
>>Any body has an idea why it is so ?
>>
>>Nicolas D.
>>Ulg, Belgium
>>
>>
>>
>>Here are both pieces of code:
>>
>>****************************************************
>>vtkPNGReader * reader = vtkPNGReader::New();
>>         reader->SetFilePattern("MR/%d.png");
>>         reader->SetDataExtent(1,256,1,256,0,126);
>>         reader->SetDataSpacing(1,1,1.5);
>>         reader->SetDataOrigin(0,0,0);
>>         reader->UpdateWholeExtent();
>>
>>
>>vtkImageData *imageData = vtkImageData::New();
>>         imageData->SetDimensions(256,256,126);
>>         imageData->SetSpacing(1,1,1.5);
>>         imageData->SetOrigin(0.0,0.0,0.0);
>>         imageData->SetScalarTypeToUnsignedChar();
>>         imageData->SetNumberOfScalarComponents(1);
>>         imageData->AllocateScalars();
>>         imageData->GetPointData()->CopyScalarsOn();
>>
>>unsigned char *ptrReader =
>>(unsigned char *) reader->GetOutput()->GetScalarPointer();
>>unsigned char *ptrData =
>>(unsigned char *) imageData->GetScalarPointer();
>>
>>for (int i=0; i<256*256*126; i++)
>>{
>>         *ptrData = *ptrReader;
>>         ptrData++;
>>         ptrReader++;
>>}
>>
>>//...
>>     volumeMapper->SetInput(imageData);
>>//...
>>
>>***********************************************************************
>>vtkVolume16Reader *v16 = vtkVolume16Reader::New();
>>     v16->SetDataDimensions(64,64);
>>     v16->SetDataByteOrderToLittleEndian();
>>     v16->SetFilePrefix ("quarter");
>>     v16->SetImageRange(1, 93);
>>     v16->SetDataSpacing (3.2, 3.2, 1.5);
>>
>>vtkImageData *imageData = vtkImageData::New();
>>         imageData->SetDimensions(64,64,93);
>>         imageData->SetSpacing(3.2,3.2,1.5);
>>         imageData->SetOrigin(0.0,0.0,0.0);
>>         imageData->SetScalarTypeToUnsignedChar();
>>         imageData->SetNumberOfScalarComponents(1);
>>         imageData->AllocateScalars();
>>         imageData->GetPointData()->CopyScalarsOn();
>>
>>unsigned char *ptr2 =
>>(unsigned char *) v16->GetOutput()->GetScalarPointer();
>>unsigned char *ptr =
>>(unsigned char *) imageData->GetScalarPointer();
>>
>>for (int i=0; i<64*64*93; i++)
>>{
>>         *ptr = *ptr2;
>>         ptr++;
>>         ptr2++;
>>}
>>//...
>>     volumeMapper->SetInput(imageData);
>>//...
>>
>>
>>_______________________________________________
>>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://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
> _______________________________________________
> 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://www.vtk.org/mailman/listinfo/vtkusers
>




More information about the vtkusers mailing list