[Paraview] python changes 4.0/4.1 to 4.3?

Dan Lipsa dan.lipsa at kitware.com
Mon Aug 31 14:23:56 EDT 2015


Anton,
I think the relevant change in ParaView 4.3 is that it now colors data
resulted from a threshold operation using the default color map. This makes
sense as you may see data with different values within a given threshold.
(this is not the case in your particular case).

This is why your DiffuseColor settings have no effect.
If you want to color you threshold data with a plain color as you have done
in the past you have to add

ColorBy(DataRepresentationX, None) after you set
DataRepresentationx.DifuseColor = ...

Where X is 2, 3 and 4.

Dan





On Tue, Jun 9, 2015 at 2:40 PM, Anton Shterenlikht <mexas at bris.ac.uk> wrote:

> There is no error, just instead of the requested colours:
>
> DataRepresentation2.DiffuseColor = [ 1, 0, 1 ]        <- purple
> DataRepresentation3.DiffuseColor = [1.0, 1.0, 0.0] <- yellow
> DataRepresentation4.DiffuseColor = [0.0, 1.0, 0.5] <- greenish
>
> I get red and blue.
>
> The colours I had with pv 4.0/4.1 can be seen here:
>  http://eis.bris.ac.uk/~mexas/cgpack/201502res/cr.png
>  http://eis.bris.ac.uk/~mexas/cgpack/201503res/gb.png
>
> The colours I'm getting now with 4.3 (with the same script)
> can be seen here:
>  http://eis.bris.ac.uk/~mexas/cgpack/201506res/cr.png
>  http://eis.bris.ac.uk/~mexas/cgpack/201506res/gb.png
>
> The 2 data files I used are:
>  http://eis.bris.ac.uk/~mexas/zg0.raw
>  http://eis.bris.ac.uk/~mexas/zf5.raw
>
> The files are raw binary, 40MB each.
>
> I might have done something really stupid,
> in which case I apologise for wasting your time.
>
> Thanks for your help
>
> Anton
>
>
> On 09/06/2015, Utkarsh Ayachit <utkarsh.ayachit at kitware.com> wrote:
> > Anton,
> >
> > DiffuseColor still exists. Can you post the full error message that
> you're
> > getting? If you can share the dataset you're using to test this script,
> > that'll be even better!
> >
> > Utkarsh
> >
> >
> > On Mon, Jun 8, 2015 at 7:39 PM Anton Shterenlikht <mexas at bris.ac.uk>
> wrote:
> >
> >> I've a script that used to work ok on 4.0 and 4.1,
> >> but now something is wrong with the colours.
> >> Has anything changed between 4.0/4.1 to 4.3 to make
> >>
> >> DataRepresentation3.DiffuseColor = [1.0, 1.0, 0.0]
> >>
> >> not understood?
> >>
> >>
> >> The full script:
> >>
> >> ######################################################################72
> >> # Adjust these parameters
> >> ext1    = 220         # data extent along 1
> >> ext2    = 220         # data extent along 2
> >> ext3    = 220        # data extent along 3
> >> ffile   = "zf5.raw" # fracture file
> >> gfile   = "zg0.raw"   # grain file
> >> imsize1 = 1000        # size, in pixels, of the resulting image along 1
> >> imsize2 = 1000        # size, in pixels, of the resulting image along 2
> >>
> >> # End of adjustable parameters
> >> ######################################################################72
> >>
> >> # define the centre of rotation (cor)
> >> cor1 = 0.5 * ext1
> >> cor2 = 0.5 * ext2
> >> cor3 = 0.5 * ext3
> >>
> >> from paraview.simple import *
> >>
> >> # the extents start from zero, so need to lower
> >> # the upper extents by 1
> >> cracks = ImageReader( FilePrefix= ffile )
> >> cracks.DataExtent=[ 0, ext1-1, 0, ext2-1, 0, ext3-1 ]
> >> cracks.DataByteOrder = 'LittleEndian'
> >> cracks.DataScalarType = 'int'
> >>
> >> RenderView1 = GetRenderView()
> >> DataRepresentation1 = Show()
> >>
> >> DataRepresentation1.Representation = 'Outline'
> >> DataRepresentation1.EdgeColor = [0.0, 0.0, 0.5]
> >>
> >> # grain boundaries, cell state 2
> >>
> >> Threshold1 = Threshold()
> >> Threshold1.Scalars = ['POINTS', 'ImageFile']
> >> Threshold1.ThresholdRange = [ 2, 2 ]
> >> Threshold1.AllScalars = 0
> >>
> >> DataRepresentation2 = Show()
> >> DataRepresentation2.ScalarOpacityUnitDistance = 1.0
> >> DataRepresentation2.SelectionPointFieldDataArrayName = 'ImageFile'
> >> DataRepresentation2.DiffuseColor = [ 1, 0, 1 ]
> >>
> >> camera = GetActiveCamera()
> >> camera.SetViewUp(-1,0,0)
> >> camera.Azimuth(30)
> >> camera.Elevation(30)
> >>
> >> RenderView1.ResetCamera()
> >>
> >> # gradient background colour
> >> RenderView1.UseGradientBackground = 1
> >> RenderView1.Background2 = [0.0, 0.0, 0.16470588235294117]
> >> RenderView1.Background = [0.3215686274509804, 0.3411764705882353,
> >> 0.43137254901960786]
> >>
> >> RenderView1.CenterAxesVisibility = 0
> >> RenderView1.OrientationAxesVisibility = 1
> >> RenderView1.CenterOfRotation = [ cor1, cor2, cor3 ]
> >> RenderView1.CameraFocalPoint = [ cor1, cor2, cor3 ]
> >> RenderView1.ViewSize = [ imsize1, imsize2 ]
> >> RenderView1.CameraViewAngle = 30
> >>
> >> # do all crack states from the main dataset
> >> SetActiveSource( cracks )
> >>
> >> # (100) cracks
> >> cracks100 = Threshold()
> >> cracks100.Scalars = ['POINTS', 'ImageFile']
> >> cracks100.ThresholdRange = [ 0, 0 ]
> >> cracks100.AllScalars = 0
> >>
> >> DataRepresentation3 = Show()
> >> DataRepresentation3.ScalarOpacityUnitDistance = 1.0
> >> DataRepresentation3.SelectionPointFieldDataArrayName = 'ImageFile'
> >> DataRepresentation3.DiffuseColor = [1.0, 1.0, 0.0]
> >>
> >> # (110) cracks
> >> SetActiveSource( cracks )
> >> cracks110 = Threshold()
> >> cracks110.Scalars = ['POINTS', 'ImageFile']
> >> cracks110.ThresholdRange = [ -1, -1 ]
> >> cracks110.AllScalars = 0
> >>
> >> DataRepresentation4 = Show()
> >> DataRepresentation4.ScalarOpacityUnitDistance = 1.0
> >> DataRepresentation4.SelectionPointFieldDataArrayName = 'ImageFile'
> >> DataRepresentation4.DiffuseColor = [0.0, 1.0, 0.5]
> >>
> >> # 1 is to show, 0 not to show
> >> # data2 is GB
> >> # data3 is cracks
> >> # data4 is grains microstructure
> >>
> >> DataRepresentation2.Opacity = 0.1
> >> WriteImage( "crgb.png" )
> >>
> >> DataRepresentation2.Opacity = 1
> >> DataRepresentation3.Visibility = 0
> >> WriteImage( "gb.png" )
> >>
> >> DataRepresentation2.Visibility = 0
> >> DataRepresentation3.Visibility = 1
> >> WriteImage( "cr.png" )
> >>
> >> RenderView1.ResetCamera()
> >>
> >> Render()
> >>
> >>
> >> ****
> >>
> >> Is there anything wrong in this script for 4.3?
> >>
> >> Many thanks
> >>
> >> Anton
> >>
> >> _______________________________________________
> >> 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
> >>
> >> Search the list archives at: http://markmail.org/search/?q=ParaView
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://public.kitware.com/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
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150831/431b30c5/attachment.html>


More information about the ParaView mailing list