[Paraview] TexturePainter missing Scalar Data
Christian Werner
christian.werner at rwth-aachen.de
Thu Feb 11 15:06:32 EST 2010
Hello!
I use the vtkSimpleImageToImageFilter to make a nifty little
segmentation plugin. Below is how I overwrote the SimpleExecute
function. It looks good and actually does the job, at least in a
VTK-only (Reader>MyFilter>Writer) setup. It loads in Paraview, but if
executed I get the following warning and bad/no (visual) results:
Warning: In /opt/ParaView3/Servers/Filters/vtkTexturePainter.cxx, line 173
vtkTexturePainter (0x1a34fd0): Failed to locate selected scalars. Will
use image scalars by default.
I traced this down to the function:
int vtkTexturePainter::SetupScalars(vtkImageData* input)
which does a
vtkDataArray* scalars = vtkAbstractMapper::GetScalars(input,
this->ScalarMode, this->ScalarArrayName? VTK_GET_ARRAY_BY_NAME :
VTK_GET_ARRAY_BY_ID,
this->ScalarArrayIndex,
this->ScalarArrayName,
cellFlag);
which becomes NULL. This leads to the above warning. I spent the last
hours following the information flow in the VTK pipeline and as far as
my humble understanding goes, all should be fine, because the
vtkSimpleImageToImageFilter derives from vtkImageAlgorithm which takes
care that all the OutputPortInformation and all the Requests, etc. are
setup correctly.
Despite that, Paraview does not seem to have information about the data
array, at least its not listed where as there IS information on the
original image: Name:PNGImage DataType: unsigned char, Data Ranges[0,255]...
Here is my SimpleExecution Function:
void vtkDislev::SimpleExecute(vtkImageData* input, vtkImageData*
output)
{
if (input==NULL) {
vtkErrorMacro(<<"Bad Input to vtkDislev");
return;
}
int dim[3];
input->GetDimensions(dim);
int numvox = dim[0]*dim[1]*dim[2];
int numcomp = input->GetNumberOfScalarComponents();
vtkDataArray* inarray = input->GetPointData()->GetScalars();
vtkDataArray* outarray = output->GetPointData()->GetScalars();
unsigned char in=255;
unsigned char out=0;
for (int component=0; component < numcomp; component++) {
for (int i=0; i < numvox; i++) {
unsigned char v=inarray->GetComponent(i,component);
if (v >= this->LowerThreshold && v<=this->UpperThreshold) {
outarray->SetComponent(i,component,in);
} else {
outarray->SetComponent(i,component,out);
}
}
}
}
I would be glad if someone had any idea. Maybe I DO have to rewrite
these FillOutputInformationVector(...) ?
Best regards,
Christian
More information about the ParaView
mailing list