Axel We were just discussing this few days ago. Do you have to use paraview gui? Or paraview python will work? There might be a way in pv python route.
Thanks Sent from my iPhone > On Dec 16, 2015, at 5:01 AM, Axel Kittenberger <[email protected]> wrote: > > Hello, > > the Python VTK script below gives results, like a expect. Now I'm trying to > reproduce it in Paraview and I fail. > > I get rather confused as soon I give it a source with more than one scalar > component. > Paraview creates one color map; I would expect 3 color maps, 1 for every > component. > What ever I do effective opacity is always 1. That is I see a black cube with > it's surface the images > of the data on its surface (so far correct), however no effective volume > rendering -- I selected Volume, "Ray Cast Only" > which should be vtkFixedPointVolumeRayCastMapper as far I understood. > > I tried creating 3 readers with the different scalar components extracted > first, but doesn't give > correct rendering -- neither in VTK nor in paraview, since multiple renderer > seem to compete which gets to > draw a pixel instead of composing them together > like a red transparent + a green transparent should give a yellow transparent > impression. > > How can I achieve the same result with Paraview? > > Kind regards, Axel > > -------------------------- > #!/usr/bin/env python > > import vtk > > # Create the standard renderer, render window and interactor > ren = vtk.vtkRenderer( ) > renWin = vtk.vtkRenderWindow( ) > renWin.AddRenderer( ren ) > iren = vtk.vtkRenderWindowInteractor( ) > iren.SetRenderWindow( renWin ) > > reader = vtk.vtkImageReader2( ) > reader.SetFileName( "./data.raw" ); > reader.SetDataScalarTypeToUnsignedChar( ); > reader.SetNumberOfScalarComponents( 3 ); > reader.SetFileDimensionality( 3 ); > reader.SetDataExtent( 0, 261, 0, 511, 0, 21 ); > reader.SetDataSpacing( 1, 1, 3.5 ); > > # Create transfer mapping scalar value to opacity > opacityTransferFunction = vtk.vtkPiecewiseFunction( ) > opacityTransferFunction.AddPoint( 0, 0.0 ) > opacityTransferFunction.AddPoint( 20, 0.0 ) > opacityTransferFunction.AddPoint( 40, 0.1 ) > opacityTransferFunction.AddPoint( 255, 0.1 ) > > # Create transfer mapping scalar value to color > > colorRedTransferFunction = vtk.vtkColorTransferFunction( ) > colorRedTransferFunction.AddRGBPoint( 0.0, 0.2, 0.0, 0.0 ) > colorRedTransferFunction.AddRGBPoint( 255.0, 1.0, 0.0, 0.0 ) > > colorGreenTransferFunction = vtk.vtkColorTransferFunction( ) > colorGreenTransferFunction.AddRGBPoint( 0.0, 0.0, 0.2, 0.0 ) > colorGreenTransferFunction.AddRGBPoint( 255.0, 0.0, 1.0, 0.0 ) > > colorBlueTransferFunction = vtk.vtkColorTransferFunction( ) > colorBlueTransferFunction.AddRGBPoint( 0.0, 0.0, 0.0, 0.0 ) > colorBlueTransferFunction.AddRGBPoint( 255.0, 0.0, 0.0, 1.0 ) > > volumeProperty = vtk.vtkVolumeProperty( ) > volumeProperty.SetColor( 0, colorRedTransferFunction ) > volumeProperty.SetColor( 1, colorGreenTransferFunction ) > volumeProperty.SetColor( 2, colorBlueTransferFunction ) > > volumeProperty.SetScalarOpacity( 0, opacityTransferFunction ) > volumeProperty.SetScalarOpacity( 1, opacityTransferFunction ) > volumeProperty.SetScalarOpacity( 2, opacityTransferFunction ) > volumeProperty.SetInterpolationTypeToLinear( ) > > volumeMapper = vtk.vtkFixedPointVolumeRayCastMapper( ) > volumeMapper.SetInputConnection( reader.GetOutputPort( ) ) > volumeMapper.SetNumberOfThreads( 1 ) > > volume = vtk.vtkVolume( ) > volume.SetMapper( volumeMapper ) > volume.SetProperty( volumeProperty ) > > ren.AddVolume( volume ) > ren.SetBackground( 1, 1, 1 ) > renWin.SetSize( 600, 600 ) > > def CheckAbort( obj, event ): > if obj.GetEventPending( ) != 0: > obj.SetAbortRender( 1 ) > > renWin.AddObserver( "AbortCheckEvent", CheckAbort ) > > iren.Initialize( ) > renWin.Render( ) > iren.Start( ) > -------------------------- > _______________________________________________ > 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
