[vtkusers] Reading an XDMF file using the vtkXdmf3Reader class fails even though the function CanReadFile() returns true.

David E DeMarle dave.demarle at kitware.com
Mon Jul 25 12:32:40 EDT 2016


On Fri, Jul 22, 2016 at 12:11 PM, Magnus Elden <magnus_elden at hotmail.com>
wrote:

> I am trying to modify the SmartVolumeMapper example to read an .xdmf file,
> but I get an error when calling the Update() function.
>
>
>
> 1 1'Value' not in itemProperties in XdmfTime::populateItem
>
>
>
> The error above is all I have been able to get out of the function. What
> am I doing wrong? The .xdmf, .h5 and .hdf5 are all in the same folder and
> the “1 1” output before the error shows that it can be read. I am using
> VisualStudio 2015 and no other libraries than VTK. I am building everything
> as x64 Release. The error occurs between ‘1’ and ‘2’. (Please refer to the
> printf() calls below.)
>
>
Looks like a syntax error in the xdmf file. See the section about time in
http://xdmf.org/index.php/XDMF_Model_and_Format and if still stuck, post a
snippet to the xdmf mailing list.


>
> This is a minimal program that causes the error:
>
> #include <vtkVersion.h>
>
> #include <vtkSmartPointer.h>
>
> #include <vtkSphere.h>
>
> #include <vtkSampleFunction.h>
>
> #include <vtkSmartVolumeMapper.h>
>
> #include <vtkColorTransferFunction.h>
>
> #include <vtkPiecewiseFunction.h>
>
> #include <vtkRenderer.h>
>
> #include <vtkRenderWindow.h>
>
> #include <vtkRenderWindowInteractor.h>
>
> #include <vtkVolumeProperty.h>
>
> #include <vtkCamera.h>
>
> #include <vtkImageShiftScale.h>
>
> #include <vtkImageData.h>
>
> #include <vtkPointData.h>
>
> #include <vtkDataArray.h>
>
> #include <vtkXMLImageDataReader.h>
>
> #include <vtkXdmf3Reader.h>
>
>
>
> static void CreateImageData(vtkImageData* im);
>
>
>
> int main(int argc, char *argv[])
>
> {
>
>        vtkSmartPointer<vtkXdmf3Reader> reader =
>
>               vtkSmartPointer<vtkXdmf3Reader>::New();
>
>
>
>        reader->SetFileName(
> "C:/Users/NoobsDeSroobs/Downloads/testVolume.xdmf");
>
>        printf("1 %d" , reader->CanReadFile(
> "C:/Users/NoobsDeSroobs/Downloads/testVolume.xdmf"));
>
>        reader->Update();
>
>        printf("2");
>
>        int numArrays = reader->GetNumberOfPointArrays();
>
>        printf("3");
>
>        for (int i = 0; i < numArrays; i++) {
>
>               printf("Name of index %d is: %s", i, reader->
> GetPointArrayName(i));
>
>               printf("2");
>
>        }
>
>
>
>        return 0;
>
> }
>
>
>
>
>
> Finally, I noticed that the standard way of copying the read data to the
> vtkImageData is by doing a shallow copy of the output of the reader, but imageData->ShallowCopy(reader->GetOutput())
> does not compile as GetOutput() does not exist.
>

Use GetOutputData() this was an API change in VTK version 6.0. GetOutput()
split into GetOutputPort() /* for connecting filters */ and GetOutputData()
/* for getting the data object */

See  http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Replacement_of_SetInput



> I have a feeling this might have something to do with the fact that this
> is a 4D file and not a standard 3D file.
>
>
>
> If possible a working example would be great to have.
>
>
>
> Finally, some functions like Update() and Read() are not listed in the
> documentation: http://www.vtk.org/doc/nightly/html/
> <http://www.vtk.org/doc/nightly/html/classvtkXdmf3Reader.html>
>

Navigate the inheritance hierarchy graph, or more easily click the "List of
all members" link on the top right of the vtk doxygen page to see the
methods of the ancestor classes as well as those implemented in the child
class.


classvtkXdmf3Reader.html
> <http://www.vtk.org/doc/nightly/html/classvtkXdmf3Reader.html> Just a
> heads up.
>
>
>
> Thank you so much for your help.
>
>
>
> Yours,
>
> Magnus Elden
>
>
>
>
>
>
>
> _______________________________________________
> 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 VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160725/07433c48/attachment.html>


More information about the vtkusers mailing list