[vtkusers] Color by vector

Amy Squillacote ahs at cfdrc.com
Fri Feb 22 09:19:09 EST 2008


Hi Steven,

It looks like you have point data, not cell data, so 
SetScalarModeToUseCellData won't work. In your mapper, use the 
SelectColorArray method, specifying the name of your dataVectors as the 
input parameter. Then in your lookup table (mapper->GetLookupTable()), 
you can specify whether to map a single component of your vectors to 
color (SetVectorModeToComponent()) or use the magnitude to derive color 
(SetVectorModeToMagnitude()). You can select which vector component to 
use with the SetVectorComponent() method of the lookup table.

- Amy

Steven Kenny wrote:
> I am try to display some data so that the color that gets associated 
> with a point is done so on the basis of a vector. It seems that I 
> should be able to do this using the properties that vtkPolyDataMapper 
> inherits from vtkMapper, but I don't seem to be able to get this to 
> work. The code that I have reads like (lots of code has been cutout so 
> as to give a gist of what is being done):
>
>   dataSet = vtkStructuredGrid::New();
>   static_cast<vtkStructuredGrid*>(dataSet)->SetDimensions(dataDims);
>   dataSet->SetPoints(dataPoints);
>   dataSet->GetPointData()->SetScalars(dataValues);
>   dataSet->GetPointData()->SetVectors(dataVectors);
>
>   orthoPlane = vtkPlane::New();
>   orthoSlice = vtkCutter::New();
>   orthoMapper = vtkPolyDataMapper::New();
>   orthoActor = vtkActor::New();
>
>   orthoPlane->SetOrigin(orthoPlaneCentre);
>   orthoPlane->SetNormal(orthoPlaneNormals);
>
>   orthoSlice->SetInput(data->getData());
>   orthoSlice->SetCutFunction(orthoPlane);
>
>   orthoMapper->SetInput(orthoSlice->GetOutput());
>   orthoMapper->SetScalarRange(dataRange);
>   orthoMapper->SetLookupTable(colourTable);
>
>   orthoActor->SetMapper(orthoMapper);
>
> where dataPoints contains a set of xyz points on a regular mesh, 
> dataValues a set of scalars and dataVectors a 3 component tuple for 
> each point. What I would like to do is color on the basis of the 
> dataVector tuple, it seems that I should be able to do this using 
> SetScalarModeToUseCellData but I can't get that to work. Does anyone 
> have any hints o how to do this or any example code at all?
>
> Thanks,
>
> Steven
> _______________________________________________
> 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
>
>

-- 
Amy Squillacote                    Phone: (256) 726-4839
Computer Scientist                 Fax: (256) 726-4806
CDF Research Corporation           Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL  35805





More information about the vtkusers mailing list