[vtkusers] vtkPolyDataReader Error

David E DeMarle dave.demarle at kitware.com
Sat Mar 28 14:04:05 EDT 2009


Use vtkXMLPolyDataReader to read .vtp files.

vtkPolyDataReader reads legacy .vtk files..

David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109



On Sat, Mar 28, 2009 at 1:49 PM, 周敏明 <zmmbreeze0825 at gmail.com> wrote:
> Hi,
>
> I met a problem about the class named "vtkPolyDataReader". I want to read a
> vtp file and render it. So I write some code.
>
>     vtkPolyDataReader *vpdr = vtkPolyDataReader::New();
>     vpdr->SetFileName("C:/VTK 5.2/bin/Examples/All/Infovis/Cxx/cube.vtp");
>     vpdr->Update();
>     vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
>     mapper->SetInput(vpdr->GetOutput());
>     vtkRenderer* ren = vtkRenderer::New();
>     vtkRenderWindow* renwin = vtkRenderWindow::New();
>     renwin->AddRenderer (ren);
>     vtkActor* actor = vtkActor::New();
>     actor->SetMapper (mapper);
>     ren->AddActor (actor);
>     renwin->Render();
>
> But I met a error:vtkPolyDataReader (003BBD28): Unrecognized file type: <?
> xml version=" 1.0"?> for file: C:/VTK
> 5.2/bin/Examples/All/Infovis/Cxx/cube.vtp
> The vtp file is:
>
> <? xml version=" 1.0"?>
> <VTKFile type=" PPolyData" version=" 0.1" byte_ order=" LittleEndian">
> <PPolyData GhostLevel=" 0">
> <PPointData Scalars=" my_ scalars">
> <PDataArray type=" Float32" Name=" my_ scalars"/>
> </ PPointData>
> <PCellData Scalars=" cell_ scalars" Normals=" cell_ normals">
> <PDataArray type=" Int32" Name=" cell_ scalars"/>
> <PDataArray type=" Float32" Name=" cell_ normals" NumberOfComponents=" 3"/>
> </ PCellData>
> <PPoints>
> <PDataArray type=" Float32" NumberOfComponents=" 3"/>
> </ PPoints>
> <Piece Source=" polyEx0. vtp"/>
> </ PPolyData> </ VTKFile>
> <? xml version=" 1.0"?>
> <VTKFile type=" PolyData" version=" 0. 1" byte_ order=" LittleEndian">
> <PolyData>
> <Piece NumberOfPoints=" 8" NumberOfVerts=" 0" NumberOfLines=" 0"
> NumberOfStrips=" 0" NumberOfPolys=" 6">
> <Points>
> <DataArray type=" Float32" NumberOfComponents=" 3" format=" ascii">
> 0 0 0 10 0 1 1 0 0 1 0 00 1 1 0 1 1 1 10 1 1
> </ DataArray>
> </ Points>
> <PointData Scalars=" my_ scalars">
> <DataArray type=" Float32" Name=" my_ scalars" format=" ascii">
> 0 1 2 34 5 6 7
> </ DataArray>
> </ PointData>
> <CellData Scalars=" cell_ scalars" Normals=" cell_ normals">
> <DataArray type=" Int32" Name=" cell_ scalars" format=" ascii">
> 0 1 2 34 5
> </ DataArray>
> <DataArray type=" Float32" Name=" cell_ normals"
> NumberOfComponents=" 3" format=" ascii">
> 0 0 -1 00 1 0 -1 0 0 1 0-1 0 0 1 0 0
> </ DataArray>
> </ CellData>
> <Polys>
> <DataArray type=" Int32" Name=" connectivity" format=" ascii">
> 0 1 2 34 5 6 7 0 1 5 4 23 7 6 0 4 7 3 12 6 5
> </ DataArray>
> <DataArray type=" Int32" Name=" offsets" format=" ascii">
> 4 8 12 16 20 24
> </ DataArray>
> </ Polys>
> </ Piece>
> </ PolyData>
> </ VTKFile>
>
> Anyone can solve this problem.Your assistance will be highly appreciated.
> Sorry for my bad English.
>
>
>
>
> _______________________________________________
> 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