[vtkusers] GetNumberOfPoints() returns 0

Tim Hutton tim.hutton at gmail.com
Mon May 15 06:16:31 EDT 2006


Xiaobin,

The call to Write is equivalent to an Update - it tells the whole
pipeline to update, including the vtkSphereSource. I suggest you read
the VTK books to get a handle on this, it is central to how VTK works.

The advantage of it working this way is when you only want *part* of a
dataset as output. If you are processing a large image, but only save
the lower half, the pipeline will only process the part of the image
that you need, not the whole thing.

Tim

On 5/15/06, Xiaobin Wang <xiaobin2006 at gmail.com> wrote:
> Hi Tim ,
> thank you for answering.
>
> when I did not Update the SphereSource, the file writing  worked .
> vtkPolyDataWriter *wrt = vtkPolyDataWriter::New();
>     wrt->SetInput(Sphere->GetOutput());
>     wrt->SetFileName(" sphere.vtk");
>     wrt->Write();
> -----------------
> so  i am confused when Update() should be called .
> can you explain me ?
> thank you
>
>
> On 5/15/06, Tim Hutton <tim.hutton at gmail.com> wrote:
> > Hi Xiaobin,
> >
> > VTK uses a pipeline architecture, so filters and sources do not get
> > executed until they are needed. see:
> >
> >
> http://www.vtk.org/Wiki/VTK_FAQ#Why_does_this_filter_not_produce_any_output.3F_eg._GetPoints.28.29.3D.3D0
> >
> > The quick answer is to call Sphere->Update.
> >
> > Tim
> >
> > On 5/15/06, Xiaobin Wang < xiaobin2006 at gmail.com> wrote:
> > > Hi users,
> > >
> > > I have got a very wierd problem .
> > > the code segment ---------------
> > >    vtkSphereSource *Sphere= vtkSphereSource::New();
> > >    Sphere->SetRadius(10);
> > >    Sphere->SetCenter(0,0,0);
> > >     vtkDoubleArray  *pDouble = vtkDoubleArray::New();
> > >     N=Sphere->GetOutput()->GetNumberOfPoints();
> > >     printf("%d,\n",N);
> > >
> > > I expect N is a finite number of points of the polygonal data
> representing
> > > the sphere.
> > > But  i got N =0!
> > > I really confused .can somebody help?
> > > thanks for your time ...
> > >
> > >
> > > _______________________________________________
> > > This is the private VTK discussion list.
> > > Please keep messages on-topic. Check the FAQ at:
> > > http://www.vtk.org/Wiki/VTK_FAQ
> > > Follow this link to subscribe/unsubscribe:
> > > http://www.vtk.org/mailman/listinfo/vtkusers
> > >
> > >
> > >
> >
> >
> > --
> > Tim Hutton - http://www.sq3.org.uk
> >
> > Take the Organic Builder challenge -
> > http://www.sq3.org.uk/Evolution/Squirm3/OrganicBuilder/
> >
>
>


-- 
Tim Hutton - http://www.sq3.org.uk

Take the Organic Builder challenge -
http://www.sq3.org.uk/Evolution/Squirm3/OrganicBuilder/



More information about the vtkusers mailing list