[vtkusers] Why I can't create a global vtkPolyData instance?

David Doria daviddoria at gmail.com
Tue May 1 08:43:45 EDT 2012


> Here is a short demo code. It is built in an empty console application in
> Windows 7 with Visual Studio 2008(C++)
>
> //----------------------------------------------------
> #include <vtkPolyData.h>
> #include <vtkPoints.h>
> #include <vtkCellArray.h>
> #include <vtkGenericDataObjectReader.h>
>
> vtkPolyData* polydata = vtkPolyData::New();                // error pops
> vtkPoints* points = vtkPoints::New();                           // no error
> vtkCellArray* polygon = vtkCellArray::New();                // no error
> vtkGenericDataObjectReader* reader = vtkGenericDataObjectReader::New();
>
> void main()
> {
>     reader->SetFileName("C:\\Users\\Wenlong\\Desktop\\surface.vtk");
>     reader->OpenVTKFile();
>     reader->Update();
>
>     polydata = reader->GetPolyDataOutput();
>     points = polydata->GetPoints();
>     polygon = polydata->GetPolys();
> }

You're still doing the same thing we just discussed was illegal:

#include <vtkGenericDataObjectReader.h>

vtkPolyData* polydata = vtkPolyData::New();                // error
pops (of course, this is still not in a scope (main) ).

David



More information about the vtkusers mailing list