[vtkusers] help needed setting up the colormap/lookuptable/mapper in C++

Eduardo K. Saldanha eks05 at inf.ufpr.br
Mon Aug 13 13:57:37 EDT 2007


put the header
#include "vtkPointData.h"

2007/8/13, David, John <john.david at uconn.edu>:
>
>
>
>
> > > > You could use vtkDoubleArray or vtkFloatArray to set up the scalars:
> > > >
> > > > vtkDoubleArray *scalars = vtkDoubleArray::New();
> > > > for (i=0; !in.eof() && in.good(); i++)
> > > > {
> > > >     in >>  v;
> > > >     scalars.InsertNextValue(v);
> > > > }
> > > > polyData->SetScalars(scalars);
> > >
> > >
> > > Hmmm...  That gives me a compile error:
>  > >
> > >  'class vtkPolyData' has no member named 'SetScalars'
> > >
> >
> > sorry,
> > polyData->GetPointData()->SetScalars(scalars);
>
> No problem.  This gives me the following compiler error:
>
> lidar_hack1.cpp: In function 'int main(int, char**)':
> lidar_hack1.cpp:139: error: invalid use of undefined type 'struct vtkPointData'
> /usr/include/vtk-5.0/vtkCell.h:48: error: forward declaration of 'struct vtkPointData'
>
> I thought that polyData->SetPoints(points) defined polyData's point data.
>
> Here is the salient code:
>
>     vtkPoints *points = vtkPoints::New();
>     vtkCellArray *polys = vtkCellArray::New();
>     vtkDoubleArray *scalars = vtkDoubleArray::New();
>
> ...
>       // set the points with
>       points->InsertPoint(i, x, y, z);
>       scalars->InsertNextValue(z);
> ...
>
>
>     vtkPolyData *polyData = vtkPolyData::New();
>     polyData->SetPoints(points);
>     polyData->SetPolys(polys);
>     polyData->GetPointData()->SetScalars(scalars);
>     polyData->Update();
>
>
>
>
> Also if it helps, some system info:
>
>   OS:   Gentoo Linux-2.6.21-r4
>   CXX:  g++ (GCC) 4.1.2
>   VTK:  5.0.3
>
>
>   Thanks,
>
>   EBo --
>



More information about the vtkusers mailing list