[vtkusers] Fwd: Paraview Error while reading .vts file

Siming Bayer siming.bayer at gmail.com
Wed Sep 27 09:47:11 EDT 2017


---------- Forwarded message ----------
From: Siming Bayer <siming.bayer at gmail.com>
Date: 2017-09-27 15:42 GMT+02:00
Subject: Re: [vtkusers] Paraview Error while reading .vts file
To: Cory Quammen <cory.quammen at kitware.com>


I used the vtkProbeFilter to interpolate the value on the edges of a
volumetric mesh onto a image volume with dimension of 256x256x256. And save
the output of vtkProbeFilter to a .vts file use the following code:

vtkSmartPointer<vtkImageData> volume = vtkSmartPointer<vtkImageData>::New();

volume->DeepCopy(reader->GetOutput());

//find the cell centers, store as polydata

vtkSmartPointer<vtkPoints> probePoints = vtkSmartPointer<vtkPoints>::New();

double center[3] = { 0,0,0 };

for (vtkIdType cellId = 0; cellId < volume->GetNumberOfCells(); ++cellId)

{

double pcoords[3] = { 0,0,0 };

double *weights = new double[volume->GetMaxCellSize()];

vtkCell* cell = volume->GetCell(cellId);

int subId = cell->GetParametricCenter(pcoords);

cell->EvaluateLocation(subId, pcoords, center, weights);

probePoints->InsertNextPoint(center[0], center[1], center[2]);

}

vtkSmartPointer<vtkPolyData> probePolyData = vtkSmartPointer<vtkPolyData>::
New();

probePolyData->SetPoints(probePoints);

//read the .vtu mesh file as untructured grid

vtkSmartPointer<vtkXMLUnstructuredGridReader> meshReader = vtkSmartPointer<
vtkXMLUnstructuredGridReader>::New();

meshReader->SetFileName(argv[2]);

meshReader->Update();

vtkUnstructuredGrid* ugrid = meshReader->GetOutput();

std::cout << "Interpolating...." << std::endl;

//Probe filter

vtkSmartPointer<vtkProbeFilter> probe = vtkSmartPointer<vtkProbeFilter
>::New();

probe->SetValidPointMaskArrayName("mesh");

probe->SetSourceData(ugrid);

probe->SetInputData(probePolyData);

probe->Update();
//save the output of probefileter as .vtu file

vtkSmartPointer<vtkStructuredGrid> sgrid = vtkSmartPointer<vtkStructuredGrid
>::New();

sgrid->SetDimensions(256, 256, 256);

sgrid->SetPoints(probePoints);

unsigned int numberOfArrays = probe->GetOutput()->GetPointData()->
GetNumberOfArrays();

std::cout << "Copying arrays:" << std::endl;

for (unsigned int i = 0; i < numberOfArrays; i++)

{

std::cout << "\t" << probe->GetOutput()->GetPointData()->GetArray(i)->GetName()
<< std::endl;

sgrid->GetCellData()->AddArray(probe->GetOutput()->
GetPointData()->GetArray(i));

}

std::cout << "Writing .vts output" << std::endl;

vtkSmartPointer<vtkXMLStructuredGridWriter> sWriter = vtkSmartPointer<
vtkXMLStructuredGridWriter>::New();

sWriter->SetFileName("test.vts");

sWriter->SetInputData(sgrid);

sWriter->Write();

}


Maybe something wrong here?


best,

Siming

2017-09-27 15:29 GMT+02:00 Cory Quammen <cory.quammen at kitware.com>:

> [Moving this discussion over to the ParaView list serve as it has to
> do with ParaView.]
>
> Unfortunately, there's not enough information in the header file. What
> wrote this .vts file?
>
> Thanks,
> Cory
>
> On Wed, Sep 27, 2017 at 9:25 AM, Siming Bayer <siming.bayer at gmail.com>
> wrote:
> > Yes,
> >
> > the whole file is quite large. The header part is the following:
> >
> > <?xml version="1.0"?>
> > <VTKFile type="StructuredGrid" version="0.1" byte_order="LittleEndian"
> > header_type="UInt32" compressor="vtkZLibDataCompressor">
> >   <StructuredGrid WholeExtent="0 255 0 255 0 255">
> >     <Piece Extent="0 255 0 255 0 255"
> >>
> >       <PointData>
> >       </PointData>
> >       <CellData>
> >         <DataArray type="Float64" Name="velocity" NumberOfComponents="3"
> > format="appended" RangeMin="0"                    RangeMax="0"
> > offset="0"                   />
> >         <DataArray type="Float64" Name="position" NumberOfComponents="3"
> > format="appended" RangeMin="0"                    RangeMax="0"
> > offset="906832"              />
> >         <DataArray type="Float64" Name="rest_position"
> > NumberOfComponents="3" format="appended" RangeMin="0"
> > RangeMax="0"                    offset="1813664"             />
> >         <DataArray type="Int8" Name="mesh" format="appended" RangeMin="0"
> > RangeMax="0"                    offset="2720496"             />
> >       </CellData>
> >       <Points>
> >         <DataArray type="Float32" Name="Points" NumberOfComponents="3"
> > format="appended" RangeMin="0.86602540378"        RangeMax="440.80693053"
> > offset="2758320"             />
> >       </Points>
> >     </Piece>
> >   </StructuredGrid>
> >   <AppendedData encoding="base64">
> >
> > _...........................................................
> ............(here
> > is the data)
> >   </AppendedData>
> > </VTKFile>
> >
> > Thank you!
> >
> > best,
> > Siming
> >
> > 2017-09-27 15:21 GMT+02:00 Cory Quammen <cory.quammen at kitware.com>:
> >>
> >> On Wed, Sep 27, 2017 at 8:50 AM, Siming Bayer <siming.bayer at gmail.com>
> >> wrote:
> >> > Dear all,
> >> >
> >> > I got the following error while reading a .vts file with ParaView:
> >> >
> >> >
> >> >
> >> > ERROR: In
> >> >
> >> > C:\bbd\7cc78367\build\superbuild\paraview\src\VTK\IO\XML\vtk
> XMLStructuredDataReader.cxx,
> >> > line 360
> >> >
> >> > vtkXMLStructuredGridReader (000000000B791F40): Error reading extent 0
> >> > 255 0
> >> > 255 0 255 from piece 0
> >> >
> >> >
> >> > What does it mean? What could be the reason?
> >> >
> >>
> >> Perhaps there is something wrong with the file. Can you share it, or
> >> ideally a smaller data set that exhibits the same problem?
> >>
> >> Thanks,
> >> Cory
> >>
> >> >
> >> >
> >> >
> >> > _______________________________________________
> >> > 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
> >> >
> >>
> >>
> >>
> >> --
> >> Cory Quammen
> >> Staff R&D Engineer
> >> Kitware, Inc.
> >
> >
>
>
>
> --
> Cory Quammen
> Staff R&D Engineer
> Kitware, Inc.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170927/bda42b1c/attachment.html>


More information about the vtkusers mailing list