[vtkusers] How to transfer data through vtkInformation
Mathieu Westphal
mathieu.westphal at gmail.com
Wed Jul 4 11:20:58 EDT 2012
Hello
I have implemented my own data reader, which inherit vtkPolyDataAlgotihm.
This reader need parameter to read data
The vtkPolyDataMapper, connected to the reader output port, know which
mode he have to use, so i would like to create/modify a vtkInformation
in the vtkPolyDataMapper with a key named "myKeys" of length 3.
And then in the reader, read this key and make the appropriate read.
But anyway i tried, i've never found my keys in the information i get in
the reader.
in Reader :
int vtkHDF5Reader::RequestData(vtkInformation* info2,
vtkInformationVector**,
vtkInformationVector* outputVector)
{
vtkInformation* info = outputVector->GetInformationObject(0);
info->PrintKeys(std::cout,vtkIndent(0));
return 1;
}
in main :
// Create a point cloud
vtkSmartPointer<Reader> pointSource =
vtkSmartPointer<Reader>::New();
vtkSmartPointer<vtkPolyDataMapper> pointsMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
pointsMapper->SetInputConnection(pointSource->GetOutputPort());
// access the info (presently none stored)
vtkInformation* info = pointsMapper->GetInputPortInformation(0);
// add one attribute, a double vector
const char *name = "myKey";
const char *location = "MyClass"; //
const int length = 3;
vtkInformationDoubleVectorKey *key = new
vtkInformationDoubleVectorKey(name,
location,
length);
double values[] = {0.1, 0.2, 0.3};
info->Set(key, values[0], values[1],values[2]);
info->PrintKeys(std::cout,vtkIndent(0));
pointSource->Update();
And the output i get :
PORT_REQUIREMENTS_FILLED: 1
INPUT_REQUIRED_DATA_TYPE: vtkPolyData
myKey: 0.1 0.2 0.3
PRODUCER: vtkStreamingDemandDrivenPipeline(0x9092e0) port 0
UPDATE_NUMBER_OF_PIECES: 1
MAXIMUM_NUMBER_OF_PIECES: 1
DATA_OBJECT: vtkPolyData(0x90e1e0)
CONSUMERS: vtkStreamingDemandDrivenPipeline(0x90c790) port 0
UPDATE_NUMBER_OF_GHOST_LEVELS: 0
UPDATE_PIECE_NUMBER: 0
UPDATE_EXTENT_INITIALIZED: 0
So the keys have nothin in common, i guess i dont modify or read the
right information.
Could someone help me?
Mathieu
More information about the vtkusers
mailing list