[vtk-developers] vtkAssignAttributes doesn't pass NumComponents?
Julien Finet
julien.finet at kitware.com
Thu Aug 25 01:03:19 EDT 2011
Hi all,
I'm trying to process a tensors vtkImageData by a filter that only accept
scalars.
However, I think that vtkAssignAttribute doesn't pass the number of
components in the output information.
Indeed, looking at vtkAssignAttribute::RequestInformation(), I don't see how
it could pass the "number of components". Maybe it's done later in
RequestData, but wouldn't it be too late when vtkAssignAttribute output is
connected as an input of another filter?
Here is my pipeline:
// Create Data:
VTK_CREATE(vtkImageData,image);
image->SetDimensions(2,1,1);
VTK_CREATE(vtkFloatArray, tensors);
tensors->SetName("tensors");
tensors->SetNumberOfComponents(9);
// 2 tuples, identity matrices
tensors->InsertNextTuple9(1.,0.,0.,0.,1.,0.,0.,0.,1.);
tensors->InsertNextTuple9(1.,0.,0.,0.,1.,0.,0.,0.,1.);
image->GetPointData()->SetTensors(tensors);
// Move tensors into scalars
VTK_CREATE(vtkAssignAttribute, assign);
assign->Assign(vtkDataSetAttributes::TENSORS,
vtkDataSetAttributes::SCALARS, vtkAssignAttribute::POINT_DATA);
assign->SetInput(image);
// Cast scalars
VTK_CREATE(vtkImageCast, cast); // here I use cast but it could be any
other image filter that just process scalars
cast->SetOutputScalarTypeToDouble();
cast->SetInput(imageOut);
cast->Update();
Unfortunately, the output of the cast filter is not a scalar image with 9
components but only 1.
vtkImageData* imageOut = vtkImageData::SafeDownCast(assign->GetOutput());
vtkImageData* imageCasted = vtkImageData::SafeDownCast(cast->GetOutput());
if (imageCasted->GetPointData()->GetNumberOfComponents() != 9)
{
cerr << "Input: \n";
image->GetPointData()->Print(cerr);
cerr << "Intermediate: \n";
imageOut->GetPointData()->Print(cerr);
cerr << "Casted: \n";
imageCasted->GetPointData()->Print(cerr);
}
produces the output:
Input:
vtkPointData (0398BBF8)
Debug: Off
Modified Time: 29
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 1
Array 0 name = tensors
Number Of Components: 9
Number Of Tuples: 2
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars: (none)
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors:
Debug: Off
Modified Time: 26
Reference Count: 3
Registered Events: (none)
Name: tensors
Data type: float
Size: 27
MaxId: 17
NumberOfComponents: 9
Information: 00000000
Name: tensors
Number Of Components: 9
Number Of Tuples: 2
Size: 27
MaxId: 17
LookupTable: (none)
Array: 0398C450
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Intermediate:
vtkPointData (0398F5B0)
Debug: Off
Modified Time: 338
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 1
Array 0 name = tensors
Number Of Components: 9
Number Of Tuples: 2
Copy Tuple Flags: ( 1 1 1 1 1 0 1 1 )
Interpolate Flags: ( 1 1 1 1 1 0 0 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars:
Debug: Off
Modified Time: 26
Reference Count: 3
Registered Events: (none)
Name: tensors
Data type: float
Size: 27
MaxId: 17
NumberOfComponents: 9
Information: 00000000
Name: tensors
Number Of Components: 9
Number Of Tuples: 2
Size: 27
MaxId: 17
LookupTable: (none)
Array: 0398C450
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors:
Debug: Off
Modified Time: 26
Reference Count: 3
Registered Events: (none)
Name: tensors
Data type: float
Size: 27
MaxId: 17
NumberOfComponents: 9
Information: 00000000
Name: tensors
Number Of Components: 9
Number Of Tuples: 2
Size: 27
MaxId: 17
LookupTable: (none)
Array: 0398C450
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
Casted:
vtkPointData (037C2A30)
Debug: Off
Modified Time: 394
Reference Count: 1
Registered Events: (none)
Number Of Arrays: 1
Array 0 name = tensors
Number Of Components: 1
Number Of Tuples: 2
Copy Tuple Flags: ( 1 1 1 1 1 1 1 1 )
Interpolate Flags: ( 1 1 1 1 1 1 1 1 )
Pass Through Flags: ( 1 1 1 1 1 1 1 1 )
Scalars:
Debug: Off
Modified Time: 391
Reference Count: 1
Registered Events: (none)
Name: tensors
Data type: double
Size: 2
MaxId: 1
NumberOfComponents: 1
Information: 00000000
Name: tensors
Number Of Components: 1
Number Of Tuples: 2
Size: 2
MaxId: 1
LookupTable: (none)
Array: 037C6DC8
Vectors: (none)
Normals: (none)
TCoords: (none)
Tensors: (none)
GlobalIds: (none)
PedigreeIds: (none)
EdgeFlag: (none)
So is it a bug or a misuse? Any idea ?
Thanks,
Julien.
p.s. doing the following doesn't help neither.
assign->Assign("tensors", vtkDataSetAttributes::SCALARS,
vtkAssignAttribute::POINT_DATA);
instead of
assign->Assign(vtkDataSetAttributes::TENSORS,
vtkDataSetAttributes::SCALARS, vtkAssignAttribute::POINT_DATA);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20110825/bff1f309/attachment.html>
More information about the vtk-developers
mailing list