[Paraview] Fwd: Image Doesn't load correctly
Dean, Kevin
kevin.dean at decisionsciencescorp.com
Tue May 5 12:09:13 EDT 2015
---------- Forwarded message ----------
From: Dean, Kevin <kevin.dean at decisionsciencescorp.com>
Date: Mon, May 4, 2015 at 5:10 PM
Subject: Re: [Paraview] Image Doesn't load correctly
To: Burlen Loring <burlen.loring at gmail.com>
awesome, thanks, that did it.
One more question. Is there a way to debug the FileName aspect of the
reader. I can't figure out how it's supposed to get set. The only way I can
get the image to show is by hard
coding it within the RequestData() function.
Thanks Again
Kevin E. Dean
On Mon, May 4, 2015 at 11:33 AM, Burlen Loring <burlen.loring at gmail.com>
wrote:
> Hi Kevin.
>
> Your RequestInformation looks a little bare. Unless things have changed
> recently, you might need to set WHOLE_EXTENT, ORIGIN, SPACING,
> CAN_PRODUCE_SUB_EXTENT keys there. and if you support parallel IO honor the
> requested extent in RequestData.
>
> Burlen
>
>
> On 05/04/2015 09:52 AM, Dean, Kevin wrote:
>
> 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.
>
> _______________________________________________
> 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
>
>
>
--
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/20150505/8c20dc1a/attachment.html>
More information about the ParaView
mailing list