[vtkusers] Stupid Mistake? Color a pointcloud...
David Doria
daviddoria at gmail.com
Thu Sep 22 08:01:41 EDT 2011
> I tried to work with some examples:
> 1) the colored point example "enlarges" my points (sets vertices?!) so they
> all are tiny squares. Thus I cannot use the visualization because it is
> getting blurred. (Example:
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/ColoredPoints)
Vertices are necessary. VTK has a concept of geometry (points) vs
topology. You cannot ever see geometry, you have to add some topology
to it. Vertices are 0D topology (the little squares you see).
> 2) I found quite the same problem discussed here some time ago. There is
> given this example:
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/VTKConcepts/Scalars
> But when I try to use this method, my compiler (visual studio 2010) say
> "pointer to incomplete class is not allowed!" when I try to set a
> vtkDoubleArray as scalar values.
> Looks like this:
>
> vtkSmartPointer<vtkDoubleArray> PointCloudColors =
> vtkSmartPointer<vtkDoubleArray>::New();
You cannot color a data set by double values without a lookup table.
You must use a vtkUnsignedCharArray.
> [Set all the points in polydata, set all the colors (it is in the same loop
> so I am pretty sure, that the numbers of values are equal)]
>
> PointCloudPolyData ->SetPoints(PointCloudPoints);
> PointCloudPolyData ->SetVerts(PointCloudCellArray);
> PointCloudPolyData ->GetPointData()->SetScalars(Colors); //here comes
> "pointer to incomplete" error
The "incomplete class" is fixed by including the class:
#include <vtkPointData.h>
GetPointData() returns a vtkPointData pointer, but your program
doesn't know what it is.
David
More information about the vtkusers
mailing list