[Paraview] Problems with 'interpolate scalars before mapping' in v3.10

Nenad Vujicic nenadus at gmail.com
Tue May 10 06:13:33 EDT 2011


Dear Utkarsh,

Thank You very much, but unfortunately, adding manually copying of
parameters didn't solve all problems. I updated test plug-in with
manually copying, converting scalars to texture, applying texture to
actor and showing resulting actor in vtkRenderWindow. You can find
updated sources at
http://alas.matf.bg.ac.rs/~mr00053/projects/PVTest.zip.

If You load again disk_out_ref.ex2, select H2 and try to export to
.my, You'll see in separate vtkRenderWindow same object with applied
generated
texture which looks very bad. Again, it works fine in v3.8.1. I
believe I'm not initializing new actors properly? Do You have some
idea how to fix it?

Thanks,
Nenad.


On Mon, May 9, 2011 at 10:02 PM, Utkarsh Ayachit
<utkarsh.ayachit at kitware.com> wrote:
> The problem is pretty straight forward. Looks like
> vtkMapper::ShallowCopy(..) does not copy the state of
> InterpolateScalarsBeforeMapping. I will commit a fix for that for next
> release. Until then, you'll have to manually copy ivars that you care
> about.
>
> Utkarsh
>
> On Sun, May 8, 2011 at 10:25 AM, Nenad Vujicic <nenadus at gmail.com> wrote:
>> Dear Utkarsh,
>>
>> I uploaded test plugin that shows my problem at
>> http://alas.matf.bg.ac.rs/~mr00053/projects/PVTest.zip.
>>
>> After I build and load the plugin from Qt client, I load
>> disk_out_ref.ex2, select "H2" for mapping scalars, check Interpolate
>> Scalars on Display tab in Object inspector and go on File->Export
>> (select .my file). I get 6 message boxes which report 0, 0, 0, 0, 0, 1
>> (instead of 0, 0, 0, 0, 1, 1) as values for
>> vtkMapper::InterpolateScalarsBeforeMapping. So, here is first
>> question: "How to create multiple vtkActor objects from
>> vtkCompositePolyDataMapper2's input"? I thought that vtkMyExporter.cpp
>> Ln 138-162 should be fine, but uploaded sources shows different.
>>
>> Thanks,
>> Nenad.
>>
>> On Fri, May 6, 2011 at 2:29 PM, Utkarsh Ayachit
>> <utkarsh.ayachit at kitware.com> wrote:
>>> Nenad,
>>>
>>> There;s nothing much different about the vtkCompositePolyDataMapper or
>>> vtkPolyDataMapper as far as the state of the
>>> InterpolateScalarsBeforeMapping flag goes. I cannot see how that
>>> variable can return false if it is indeed set to true as you are
>>> saying. Can you share the plugin?
>>>
>>> Utkarsh
>>>
>>> On Thu, May 5, 2011 at 6:03 PM, Nenad Vujicic <nenadus at gmail.com> wrote:
>>>> Hello everyone,
>>>>
>>>> Perhaps I was a bit unclear in my previous messages. Here are more
>>>> details about the problem and test case.
>>>>
>>>> I use ParaView v3.10.1 release sources, Visual Studio 2008 SP1, Python
>>>> 2.7, OpenMPI 1.4.3 on Vista SP2. I compiled sources with standard
>>>> options (just turned on BUILD_SHARED_LIBS, MPI and Python). I derived
>>>> new class from vtkExporter, vtkMyExporter, and in
>>>> vtkMyExporter::WriteData() I call code specified down. The problem is
>>>> in QMessage line, which reports always 0, even when this flag is
>>>> turned on. Same is happening with most of other parameters.
>>>>
>>>> I believe that learning how to decompose composite ptrActor into
>>>> several actors with vtkPolyDataMapper mapper and vtkPolyData data will
>>>> solve all other problems (which occur when generating texture from
>>>> scalars). At the moment, I'm interested only in actors which use
>>>> vtkCompositePolyDataMapper2 mappers. As input I use disk_out_ref.ex2
>>>> with selected H2 (or any other channel) for mapping colors. Does
>>>> anyone have any idea how this can be done? Btw, this worked perfectly
>>>> under ParaView v.3.8.1 and with RenderWindow created using VTK 5.4.2
>>>> (where I create vtkCompositePolyDataMapper2 and populate it manually).
>>>>
>>>> Thank You very much for Your help!
>>>>
>>>> Best regards,
>>>> Nenad.
>>>>
>>>> --------------------
>>>>
>>>> 1) Get interactive renderer 'InteractiveRenderer' from
>>>> vtkMyExporter::RenderWindow
>>>> 2) For every actor 'ptrActor' (3D actors only) in InteractiveRenderer do:
>>>>
>>>>    vtkCompositeDataIterator* actor_iterator;
>>>>    vtkCompositePolyDataMapper2* composite_mapper = NULL;
>>>>
>>>>    // get actor's mapper
>>>>    vtkMapper* mapper = ptrActor->GetMapper();
>>>>    if(mapper == NULL)
>>>>        return true; // discard
>>>>
>>>>    // get mapper's input
>>>>    vtkCompositeDataSet* composite_input_data =
>>>> dynamic_cast<vtkCompositeDataSet*>(mapper->GetInputDataObject(0, 0));
>>>>    if(composite_input_data != NULL)
>>>>    {
>>>>        // get actor's composite mapper
>>>>        composite_mapper = dynamic_cast<vtkCompositePolyDataMapper2*>(mapper);
>>>>        if(composite_mapper == NULL)
>>>>            return false;
>>>>
>>>>        // in case input data is composite object, get iterator for traversing
>>>>        actor_iterator = composite_input_data->NewIterator();
>>>>
>>>>        // initialize iterator for traversing
>>>>        actor_iterator->InitTraversal();
>>>>        actor_iterator->GoToFirstItem();
>>>>    }
>>>>    else
>>>>        actor_iterator = NULL;
>>>>
>>>>    // export all components of input actor
>>>>    for(;;)
>>>>    {
>>>>        vtkSmartPointer<vtkActor> actor;
>>>>
>>>>        // if input data is composite object, create actor with
>>>> current component as data, otherwise use entire actor (I do this
>>>> because I need actor with vtkPolyDataMapper and vtkPolyData data for
>>>> vtkScalarsToColorsPainter)
>>>>        if(actor_iterator != NULL)
>>>>        {
>>>>            // check if there are no more components
>>>>            if(actor_iterator->IsDoneWithTraversal())
>>>>                break;
>>>>
>>>>            // get next component
>>>>            vtkDataObject* data_object = actor_iterator->GetCurrentDataObject();
>>>>            if(dynamic_cast<vtkPolyData*>(data_object) != NULL)
>>>>            {
>>>>                // get poly data
>>>>                vtkPolyData* poly_data =
>>>> dynamic_cast<vtkPolyData*>(data_object);
>>>>
>>>>                // create new temporary poly data mapper
>>>>                vtkSmartPointer<vtkPolyDataMapper> poly_data_mapper =
>>>> vtkSmartPointer<vtkPolyDataMapper>::New();
>>>>
>>>>                // copy mapper's parameters
>>>>                poly_data_mapper->ShallowCopy(composite_mapper);
>>>>
>>>>                // set mapper's input
>>>>                poly_data_mapper->SetInput(poly_data);
>>>>
>>>>                // create new actor
>>>>                actor = vtkSmartPointer<vtkActor>::New();
>>>>
>>>>                // copy actor parameters
>>>>                actor->ShallowCopy(ptrActor);
>>>>
>>>>                // set actor's mapper
>>>>                actor->SetMapper(poly_data_mapper);
>>>>            }
>>>>            else
>>>>            {
>>>>                return false;
>>>>            }
>>>>        }
>>>>        else
>>>>            actor = ptrActor;
>>>>
>>>>        // report some actor's property
>>>>        QMessageBox::about(NULL, "",
>>>> QString::number(ptrActor->GetMapper()->GetInterpolateScalarsBeforeMapping()));
>>>>
>>>>        // perform transformation from scalars to texture using
>>>>        vtkScalarsToColorsPainter class
>>>>
>>>>        // extract data from ptrActor (I use previously generated
>>>> texture instead of colors / scalars)
>>>>
>>>>        // write to my custom format
>>>>
>>>>        // if input is not composite, break the loop
>>>>        if(composite_input_data == NULL)
>>>>            break;
>>>>
>>>>        // set iterator on next item
>>>>        if(actor_iterator != NULL)
>>>>            actor_iterator->GoToNextItem();
>>>>    }
>>>>
>>>>
>>>> ----------------------------------------------------------------------------------------------------
>>>>
>>>> On Wed, May 4, 2011 at 3:04 PM, Utkarsh Ayachit
>>>> <utkarsh.ayachit at kitware.com> wrote:
>>>>> Nenad,
>>>>>
>>>>> I am not sure I understand where this code is being put. You say it's
>>>>> an exporter? Meaning it exports to something like a vrml/x3d file? But
>>>>> that doesn't seem right since you say you are using the
>>>>> PolyDataMapper.
>>>>>
>>>>> What is this plugin trying to achieve?
>>>>>
>>>>> Utkarsh
>>>>>
>>>>> On Wed, May 4, 2011 at 8:31 AM, Nenad Vujicic <nenadus at gmail.com> wrote:
>>>>>> Hello everyone,
>>>>>>
>>>>>> I'm having some problems with porting my ParaView exporter plug-in to
>>>>>> v3.10, because ParaView started using vtkCompositeDataSet internally
>>>>>> instead of keeping components merged. The problem is in performing
>>>>>> transformation of scalars to texture using vtkScalarsToColorsPainter
>>>>>> class. Here is approximately my code (questions come after
>>>>>> pseudo-code):
>>>>>>
>>>>>> for every actor in currently active renderer:
>>>>>>  for every component of composite data object (I retrieve
>>>>>> vtkDataObject* with vtkCompositeDataIterator::GetCurrentDataObject()
>>>>>> call)
>>>>>>
>>>>>>    // prepare new actor which defines component
>>>>>>    dynamic cast vtkDataObject* data_object to vtkPolyData* poly_data;
>>>>>>    create new vtkPolyDataMapper* pdm;
>>>>>>    pdm->ShallowCopy(composite_mapper);
>>>>>>    pdm->SetInput(poly_data);
>>>>>>    allocate new actor and do actor->ShallowCopy(ptrActor) //
>>>>>> ptrActor) is selected actor from currently active renderer - line 1
>>>>>>    actor->SetMapper(pdm);
>>>>>>
>>>>>>    // perform converting from scalars to texture
>>>>>>    ConvertScalarsToColors(actor);
>>>>>>
>>>>>> Routine ConvertScalarsToColors(vtkActor*) is defined in following way:
>>>>>>
>>>>>> L1 get actor's poly_data and mapper references,
>>>>>> L2 create s2c - instance of MyVtkScalarsToColorsPainter (derived from
>>>>>> vtkScalarsToColorsPainter for allowing setting its protected
>>>>>> attributes),
>>>>>> L3 initialize s2c parameters from mapper and poly_data
>>>>>> L4 if s2c->CanUseTextureMapForColoring(poly_data) returns true,
>>>>>> s2c->PrepareForRendering(), get texture and texture coordinates and
>>>>>> sets them to passed actor
>>>>>>
>>>>>> Q1: First problem is in L3 when setting s2c parameters. Original
>>>>>> mapper has turned on InterpolateScalarsBeforeMapping flag, but new one
>>>>>> doesn't have it. How to safely copy properties of
>>>>>> vtkCompositePolyDataMapper2 to vtkPolyDataMapper or I shouldn't do it?
>>>>>>
>>>>>> Q2: Even if I override above problem by turning on manually
>>>>>> InterpolateScalarsBeforeMapping, I get very bad texture on output. It
>>>>>> looks like scalars were not interpolated before mapping, sometimes
>>>>>> even more distorted..
>>>>>>
>>>>>> The same code works with v3.8 perfectly. I also tried to apply
>>>>>> vtkCompositeDataGeometryFilter to composite data object and to apply
>>>>>> ConvertScalarsToColors() to result (even without creating new actor),
>>>>>> but without success. Strange thing is that when I try this with
>>>>>> manually created VTK scene (out of ParaView) it works perfectly and
>>>>>> texture looks great!
>>>>>>
>>>>>> I would appreciate any help!
>>>>>>
>>>>>> Best regards,
>>>>>> Nenad.
>>>>>> _______________________________________________
>>>>>> 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
>>>>>>
>>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>
>> _______________________________________________
>> 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
>>
>


More information about the ParaView mailing list