Hello,
im new to Paraview, and im trying to write a plugin for the application.
I already managed to get going a bit by using on site examples, however i have severe difficulty understanding how to pass data between filters.
 
I have written a source plugin which generates some data, and a marching cubes filter to do some analyzing.
However, the data written to the source plugins' output data object never seems to arrive at the m.c. filters input.
The code below was more or less copy pasted and reworked from a couple of examples i could actually get to work,
and which had some sparse explanation to them.
 
Heres the code i think is relevant:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
//first filter
vtkFirst::vtkFirst() {
    this->SetNumberOfInputPorts(0);
    this->SetNumberOfOutputPorts(1);
}
 
vtkFirst::~vtkFirst(){
}
 
int vtkFirst::FillOutputPortInformation(int port, vtkInformation* info) {
    if (port == 0)
    info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkUniformGrid");
    return 1;
}
 
int vtkFirst::RequestDataObject(vtkInformation *vtkNotUsed(request),
                              vtkInformationVector **vtkNotUsed(input),
                              vtkInformationVector *outputVector)
{
    for ( int i = 0; i < this->GetNumberOfOutputPorts(); ++i ){
        vtkInformation* outInfo = outputVector->GetInformationObject( i );
        vtkSmartPointer<vtkUniformGrid> output = vtkUniformGrid::SafeDownCast(outInfo->Get( vtkDataObject::DATA_OBJECT() ) );
        if (!output ) {
            output = vtkUniformGrid::New();
            outInfo->Set( vtkDataObject::DATA_OBJECT(), output );
            this->GetOutputPortInformation(i)->Set(vtkDataObject::DATA_EXTENT_TYPE(), output->GetExtentType() );
        }
    }
    return 1;
}
int vtkFirst::RequestData(vtkInformation *vtkNotUsed(request),
                              vtkInformationVector **vtkNotUsed(input),
                              vtkInformationVector *outputVector)
{
    vtkInformation* outInfo = outputVector->GetInformationObject(0);
    vtkUniformGrid* output = vtkUniformGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
    //fill output with some data, for testing i set the dims
    int dim[3] = {10,20,30};
    output->SetDimensions(dim);
 
    int ext[6];
    in_grid->GetExtents(ext);
    cout << ext[0] << ... << ext[6] << endl;
}
//output is 0 9 0 19 0 29
------------------------------------------------------------------------------------------------------------------------------------------------------------------
//second filter
 
void vtkSecond::AddSourceConnection(vtkAlgorithmOutput* input){
    this->AddInputConnection(1, input);
}
void vtkSecond::RemoveAllSources(){
    this->SetInputConnection(1, 0);
}
 
int vtkSecond::FillInputPortInformation( int port, vtkInformation* info ){
    if (!this->Superclass::FillInputPortInformation(port, info)) {
    return 0;
    }
    if ( port == 0 ) {
    info->Set( vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkUniformGrid" );
    return 1;
    }
    return 0;
}
 
int vtkSecond::RequestData(vtkInformation *vtkNotUsed(request),
              vtkInformationVector **inputVector,
              vtkInformationVector *outputVector)
{
    vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
    vtkDataObject* inputDataObject = inInfo->Get(vtkDataObject::DATA_OBJECT());
    vtkSmartPointer<vtkUniformGrid> in_grid = vtkUniformGrid::SafeDownCast(inputDataObject);
    int ext[6];
    in_grid->GetExtents(ext);
    cout << ext[0] << ... << ext[6] << endl;
}
//output is 0 -1 0 -1 0 -1
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Its not only the data thats getting lost, if i directly compare memory adresses of the DATA_OBJECTs, they are different.
I didnt post the .xml files since i assumed they would throw an error if something is wrong.
In short, the .xml file sets no pins for the first filter, and a single input pin for the second.
I also would appreciate an example which is as simple as possible explaning step by step how to talk to the pipeline.
It seems rather hard to find anything useful on the web (because its probably pretty trivial),or at least something that is so
minimal that it will work out of the box, and you can learn from it by expanding a working code, not reducing a
broken one to get it to work. Then again maybe it really is that complicated, then i'll just write my own vis package :)
 
Thanks alot,
    Tasche
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to