[vtkusers] General file reader

Gerrick Bivins Gerrick.Bivins at halliburton.com
Mon Feb 11 08:50:08 EST 2013


I've use code like this (java) to read "general vtk" files (NOTE: this attempts to always return multiblock output):

     vtkXMLFileReadTester vtkXMLFormatFileChecker = new vtkXMLFileReadTester();

        vtkXMLFormatFileChecker.SetFileName(fileName);

        if (vtkXMLFormatFileChecker.TestReadFile() > 0) {
            Logger.getLogger(getClass().getName()).log(Level.INFO, "[{0}] is of type [{1}]",
                    new Object[] { fileName, vtkXMLFormatFileChecker.GetFileDataType() });

            vtkXMLGenericDataObjectReader vtkXMLFileReader = new vtkXMLGenericDataObjectReader();

            vtkXMLFileReader.SetFileName(fileName);
            vtkXMLFileReader.Update();

            if (vtkXMLFileReader.GetOutput() instanceof vtkMultiBlockDataSet) {
                return vtkXMLFileReader;
            } else {
                vtkMultiBlockDataGroupFilter makeMultiblock = new vtkMultiBlockDataGroupFilter();

                makeMultiblock.SetInputConnection(vtkXMLFileReader.GetOutputPort());

                return makeMultiblock;
            }
        } else // legacy format
        {
            vtkGenericDataObjectReader legacyVTKFileReader = new vtkGenericDataObjectReader();

            legacyVTKFileReader.SetFileName(fileName);
            legacyVTKFileReader.Update();

            vtkMultiBlockDataGroupFilter makeMultiblock = new vtkMultiBlockDataGroupFilter();

            makeMultiblock.SetInput(legacyVTKFileReader.GetOutput());

            return makeMultiblock;
        }

Gerrick
-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of Bill Lorensen
Sent: Saturday, February 09, 2013 9:56 AM
To: Sunrise
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] General file reader

There is not for non-image data. I had started on a general polydata reader about 6 months ago, but put it on the back burner.

On Sat, Feb 9, 2013 at 12:08 AM, Sunrise <helios.corona at gmail.com> wrote:
> I would like to read different file formats as input to my class.
> Previously, I wrote a custom reader that used different readers inside 
> it, based on parsing user input and extracting the file extension, 
> then switching to appropriate reader. For example 
> vtkUnstructuredgridReader for *.vtk input and vtkXMLUnstructuredGridReader for *.vtu input.
>
> I would like to ask, is there any method that I can leverage reading 
> almost all supported formats (specifically for unstructured grid data, 
> such as vtk, vtu, ex2, ...) without parsing user input?
>
> Thanks
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers



--
Unpaid intern in BillsBasement at noware dot com _______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list