[Paraview] Image Doesn't load correctly

Dean, Kevin kevin.dean at decisionsciencescorp.com
Mon May 4 12:52:57 EDT 2015


So I am still having a few issues with the reader. I have checked the
output from the information Panel. And it seems as if all the information
is the same. So maybe the data is getting deleted somehow (I'm not
sure...., but here is a snippet of my code);

int vtkPVPROTOImageReader::RequestInformation (
   vtkInformation*,
   vtkInformationVector**,
   vtkInformationVector* outputVector)
{
   vtkInformation* outInfo = outputVector->GetInformationObject(0);
   vtkDataObject::SetPointDataActiveScalarInfo(outInfo, VTK_UNSIGNED_CHAR,
1);

   return 1;
}

int vtkPVPROTOImageReader::RequestData(vtkInformation *vtkNotUsed(request),
                                       vtkInformationVector **inputVector,
                                       vtkInformationVector *outputVector)
{
   ... conversion code from protobuf

  /* Convert from protobuf to vtkImageData */
  vtkSmartPointer<vtkImageData> image = "function converting to protobuf";

  vtkDataArray* scalars = image->GetPointData()->GetScalars();
  scalars->SetName("ReconstructionData");

  /* Get the info object */
  vtkInformation *outInfo = outputVector->GetInformationObject(0);
  outInfo->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkImageData");

  /* Get the output */
  vtkImageData* output = vtkImageData::GetData(outputVector);

//  output->SetSpacing(image->GetSpacing());
//  output->SetOrigin(image->GetOrigin());
//  output->AllocateScalars(outInfo);
//  output->GetPointData()->SetScalars(image->GetPointData()->GetScalars());
//  output->SetDimensions(image->GetDimensions());

  output->ShallowCopy(image);

  int* dimensions = output->GetDimensions();

  std::cout << "\nNumber of points: " << output->GetNumberOfPoints() <<
std::endl;
  std::cout << "Number of cells: " << output->GetNumberOfCells() << "\n" <<
std::endl;

// print out the pixel values to see if they are actually present
  for (int z = 0; z < dimensions[2]; z++)
  {
    for (int y = 0; y < dimensions[1]; y++)
    {
      for (int x = 0; x < dimensions[0]; x++)
      {
        double* pixel =
static_cast<double*>(output->GetScalarPointer(x,y,z));
        // do something with v
        std::cout << "pixel value: " << pixel[0] << "\n";
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }

  // write output to file and compare in visualization window...
  vtkSmartPointer<vtkXMLImageDataWriter> vtk_writer =
vtkSmartPointer<vtkXMLImageDataWriter>::New();
  vtk_writer->SetInputData(output);
  vtk_writer->SetFileName( "/home/kdean/tmp/foo.vti" );
  vtk_writer->Update();
  vtk_writer->Write();

  return 1;
}


Another Problem I ran into:
So I had to hardcode a file for the char *FileName into the RequestData
Function in order to read any protobuf file. I ran a debugger on the code,
and it seems like these functions from the header file (of the reader):

vtkGetStringMacro(FileName);
vtkSetStringMacro(FileName);

they are never getting called.

Thanks,

Kevin

here are my xml too... it looks right, but maybe I am missing something.

On Sun, May 3, 2015 at 7:04 AM, Utkarsh Ayachit <utkarsh.ayachit at kitware.com
> wrote:

> You can also use the Information panel to see what arrays are being
> read in and what their ranges are.
>
> On Sat, May 2, 2015 at 7:06 PM, Dean, Kevin
> <kevin.dean at decisionsciencescorp.com> wrote:
> > looked at the spreadsheet view in the GUI, and it looks like none of the
> > Point Data is actually being copied...
> >
> > On Sat, May 2, 2015 at 3:44 PM, Dean, Kevin
> > <kevin.dean at decisionsciencescorp.com> wrote:
> >>
> >> What's up Utkarsh?
> >>
> >> So I was able to write that plugin and convert my image to the
> >> vtkImageData. However, I am having trouble visualizing the image.
> However,
> >> when I write out the output from my reader, the image gets written
> >> correctly... Here are some pictures to show the differences. (All the
> >> information for the images is exactly the same) Do you have an idea of
> how I
> >> can try to fix it? Thanks.
> >>
> >> Kevin E. Dean
> >
> >
> >
> > This email and its contents are confidential. If you are not the intended
> > recipient, please do not disclose or use the information within this
> email
> > or its attachments. If you have received this email in error, please
> report
> > the error to the sender by return email and delete this communication
> from
> > your records.
>

-- 
This email and its contents are confidential. If you are not the intended 
recipient, please do not disclose or use the information within this email 
or its attachments. If you have received this email in error, please report 
the error to the sender by return email and delete this communication from 
your records.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150504/765b59ea/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkPVPROTOImageReader.xml
Type: text/xml
Size: 1207 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150504/765b59ea/attachment.xml>


More information about the ParaView mailing list