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

Eduardo K. Saldanha eks05 at inf.ufpr.br
Sun Aug 12 14:19:54 EDT 2007


sorry, I forgot to sent to the list

---------- Forwarded message ----------
From: Eduardo K. Saldanha <eks05 at inf.ufpr.br>
Date: 12/08/2007 15:01
Subject: Re: [vtkusers] help needed setting up the colormap/lookup
table/mapper in C++
To: "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);

And if you want to set up the vectors too:

vtkDoubleArray *vectors = vtkDoubleArray::New();
vectors->SetNumberOfComponents(3);
for (i=0; !in.eof() && in.good(); i++)
{
    in >>  x  >>  y  >>  z;
    scalars.InsertNextTuple3(x, y, z);
}
polyData->SetVectors(vectors);



2007/8/12, David, John <john.david at uconn.edu>:
>
> Sometime back I wrote a simple point cloud to VTK converter which had the following output structure:
>
>   # vtk DataFile Version 2.0
>   loop
>   ASCII
>   DATASET UNSTRUCTURED_GRID
>   POINTS 1150 float
>       758301.12       555277.12            6.70
>       758301.50       555183.19            3.50
>   ...
>
>   CELLS 1150 2300
>   1 0
>   1 1
>   ...
>
>   CELL_TYPES 1150
>   1
>   1
>   ...
>
>   POINT_DATA 1150
>   SCALARS Z_Value float 1 LOOKUP_TABLE default
>   6.700000
>   3.500000
>   ...
>
> I have been unable to figure out how to fully implement the equivalent on the fly in C++.  The following is some test code which appears to get the point data set up correctly, but I cannot figure out how to set up the colormap/lookup table/mapper:
>
>     vtkPoints *points = vtkPoints::New();
>     vtkCellArray *polys = vtkCellArray::New();
>
>     for (i=0; !in.eof() && in.good(); i++)
>     {
>       in >> x >> y >> z;
>       points->InsertPoint(i, x, y, z);
>     }
>
>     polys->InsertNextCell(points->GetNumberOfPoints());
>     for (i=0; i<points->GetNumberOfPoints(); i++)
>     {
>         polys->InsertCellPoint(i);
>     }
>
>         vtkPolyData *polyData = vtkPolyData::New();
>         polyData->SetPoints(points);
>         polyData->SetPolys(polys);
>
>     polyData->Update();
>
>         vtkPolyDataWriter* writer1 = vtkPolyDataWriter::New();
>
>         writer1->SetInput(polyData);
>         writer1->SetFileName( "test_points.vtk" );
>         writer1->Update();
>
>         writer1->Delete();
>
>
> I have not found any solutions on line, and my book order has not arrived yet (originally ordered through Amazon, and placed on back oder for 6+ months).  Any pointers will be appreciated.
>
> Thanks and best regards,
>
>   EBo --
> _______________________________________________
> 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
>



More information about the vtkusers mailing list