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

Nenad Vujicic nenadus at gmail.com
Wed May 4 08:31:51 EDT 2011


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.


More information about the ParaView mailing list