[vtkusers] Color by vector
Steven Kenny
S.D.Kenny at lboro.ac.uk
Fri Feb 22 03:24:17 EST 2008
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
More information about the vtkusers
mailing list