CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[General] Paraview pipeline when writing plugins

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 18, 2013, 05:01
Default Paraview pipeline when writing plugins
  #1
New Member
 
Join Date: Jun 2013
Posts: 2
Rep Power: 0
Tasche is on a distinguished road
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:
Code:
//first filter
vtkFirst::vtkFirst() {
    this->SetNumberOfInputPorts(0);
    this->SetNumberOfOutputPorts(1);
}

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()));
    int dim[3] = {10,20,30}
    output->Initialize();
    output->SetDimensions(dim);
    int ext[6]; output->GetExtent(ext);
    cout << "Extent: " << ext[0] << ... <<ext[5] << endl;
}
//output: 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)
{
    // get the input and output objects from info
    vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
    vtkDataObject* inputDataObject = inInfo->Get(vtkDataObject::DATA_OBJECT());
    in_grid = vtkUniformGrid::SafeDownCast(inputDataObject);
    int ext[6]; output->GetExtent(ext);
    cout << "Extent: " << ext[0] << ... << ext[5] << endl;
}
//output 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
Tasche is offline   Reply With Quote

Old   June 19, 2013, 04:37
Default
  #2
New Member
 
Join Date: Jun 2013
Posts: 2
Rep Power: 0
Tasche is on a distinguished road
Ah sorry for the premature post, i found the problem!
In RequestDataObject(...) add the line:

Code:
...
    if (!output ) {
        output = vtkUniformGrid::New();
        outInfo->Set( vtkDataObject::DATA_OBJECT(), output );
        this->GetOutputPortInformation(i)->Set(vtkDataObject::DATA_EXTENT_TYPE(), output->GetExtentType() );
        outputVector->SetInformationObject(i, outInfo);      //this line is probably not needed, cant test atm..
        this->GetExecutive()->SetOutputData(i, output);      //this works for me
    }
...

From the paraview mailing list, i also got the tip to implement RequestInformation(...) method to set these things, but for testing, a newbie (like me) prefers minimal code
Can be marked as solved i guess.

EDIT: this didnt solve anything at all, i was just testing wrong. The problem still stands as is, any help is appreciated...

Last edited by Tasche; June 19, 2013 at 07:51. Reason: Wrong info
Tasche is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[mesh manipulation] How to write cellSet for different regions in constant/polyMesh/sets Struggle_Achieve OpenFOAM Meshing & Mesh Conversion 3 June 17, 2019 09:29
.cfg not actually writing paraview vtk (or general outputs) Jasfss SU2 5 August 22, 2016 12:33
[OpenFOAM.org] Trouble Installing Paraview Plugins m_ridzon OpenFOAM Installation 13 July 20, 2016 08:42
[General] Paraview Binary and OSPray plugin Prapanchnair ParaView 0 May 27, 2016 06:26
[OpenFOAM] Distributed ParaView and PV3FoamReader micalil ParaView 4 July 1, 2010 05:09


All times are GMT -4. The time now is 17:16.