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.ayac...@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.d...@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.d...@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.
<ServerManagerConfiguration>
  <ProxyGroup name="sources">
    
    <!-- ================================================================================================================ -->
    <SourceProxy name ="vtkPVPROTOImageReader" class="vtkPVPROTOImageReader" label="vtkPVPROTOImageReader">
      <Documentation
        long_help="Read a DSC Reconstruction Data protobuf file."
        short_help="Read a DSC Reconstruction Data protobuf file.">
      </Documentation>
      <StringVectorProperty name="FileName"  animateable="0" command="SetFileName" number_of_elements="1">
        <FileListDoman name="files"/>
        <Documentation>
          This property specifies the file name for the protobuf reader
        </Documentation>
      </StringVectorProperty>
      
      <Hints>
        <ReaderFactory extensions="pbuf"
                       file_description="DSC Protobuf Files" />
        <Property name="FileName" show="1"/>
      </Hints>
    </SourceProxy>
    <!-- End Reader -->
    <!-- ================================================================================================================ -->
    
  </ProxyGroup>
  <!-- End Filters Group -->
</ServerManagerConfiguration>
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to