CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > ParaView

Paraview pipeline when writing plugins

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools 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

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Mix AIR and WATER Elvis1991 FLUENT 10 March 28, 2012 12:40
Newbie: Install ParaView 3.81 on OF-1.6-ext/OpenSuse 11.2? lentschi OpenFOAM Installation 1 March 9, 2011 03:32
Distributed ParaView and PV3FoamReader micalil OpenFOAM Paraview & paraFoam 4 July 1, 2010 05:09
Writing data to a File using paraview mecbe2002 OpenFOAM 0 March 20, 2010 09:18
paraFoam reader for OpenFOAM 1.6 smart OpenFOAM Installation 13 November 16, 2009 22:41


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