[vtkusers] SelectColorArray
Corinne Tith
cocoricore at gmail.com
Mon May 18 12:26:27 EDT 2009
Hi all,
I would like to color an isosurface with scalar field. When I associate my
scalars to my data set before filtering, I have no problem. To reduce time
processing, I want to associate my scalars after filtering operation, but I
only get grey 3D object on screen.
//before filtering
int nbPoints =
(int)m_ImageData->GetPointData()->GetArray(0)->GetNumberOfTuples();
vtkIntArray *colorArray = vtkIntArray::New();
colorArray->SetName("colorArray");
//m_ProcessedImageData->SetScalarTypeToShort();
colorArray->SetNumberOfValues(nbPoints);
int *ptrColorArray = colorArray->GetPointer(0);
for( int i = 0; i < nbPoints i++){
ptrColorArray[i] = 1; // just to test
}
m_ImageData->GetPointData()->AddArray(colorArray);
[filtering]
m_Reverser->Update();
int nbPoints =
(int)m_ReverseSenceFilter->GetOutput()->GetPointData()->GetArray(0)->GetNumberOfTuples();
vtkIntArray *colorArray2 = vtkIntArray::New();
colorArray2->SetName("colorArray2");
//m_ReverseSenceFilter->GetOutput()->SetScalarTypeToShort();
colorArray2->SetNumberOfValues(nbPoints);
int *ptrColorArray2 = colorArray2->GetPointer(0);
for(i = 0; i < 100; i++)
ptrColorArray2[i] = 2;
for(i = 100; i < nbPoints; i++)
ptrColorArray2[i] = 4;
m_ReverseSenceFilter->GetOutput()->GetPointData()->AddArray(colorArray2);
m_ReverseSenceFilter->GetOutput()->GetPointData()->SetActiveScalars("colorArray2");
// render
m_PolyDataMapper->ScalarVisibilityOn();
m_PolyDataMapper->SetScalarRange(0,11);
m_PolyDataMapper->SetScalarModeToUseCellFieldData();
m_PolyDataMapper->SelectColorArray("colorArray2"); // my object is just
grey
//m_PolyDataMapper->SelectColorArray("colorArray"); // no problem if I
uncomment this line
My colorArray2 scalars are well add to my ReverseSenseFilter.
Where is my mistake and any idea about how to overcome it?
Thanks,
Corinne
<corinne.tith at eisti.fr>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090518/2479146c/attachment.htm>
More information about the vtkusers
mailing list