Exemplo n.º 1
0
def UpdateColorMap (colorMap, colorArrayName):
  if type(colorArrayName) is unicode:
    colorArrayName = colorArrayName.encode('ascii', 'ignore')
  
  lookupTable = pwsimple.GetLookupTableForArray(colorArrayName, 1)
  lookupTable.RGBPoints = colorMap
  
  dataRep = pwsimple.Show()
  dataRep.LookupTable = lookupTable
Exemplo n.º 2
0
def ChangeWindow(rgbPoints, colorArrayName):
    if type(colorArrayName) is unicode:
        colorArrayName = colorArrayName.encode('ascii', 'ignore')

    lookupTable = pwsimple.GetLookupTableForArray(colorArrayName, 1)
    lookupTable.RGBPoints = rgbPoints

    retVal = {}
    retVal['lookupTable'] = lookupTable
    return retVal
Exemplo n.º 3
0
def InitViewState(cameraFocalPoint, cameraPosition, colorArrayName, colorMap,
                  sliceVal, sliceMode, parallelScale, cameraUp):
    if type(colorArrayName) is unicode:
        colorArrayName = colorArrayName.encode('ascii', 'ignore')

    if type(sliceMode) is unicode:
        sliceMode = sliceMode.encode('ascii', 'ignore')

    activeView = pwsimple.CreateIfNeededRenderView()

    activeView.CameraFocalPoint = cameraFocalPoint
    activeView.CameraPosition = cameraPosition
    activeView.CameraViewUp = cameraUp
    activeView.CameraParallelProjection = True
    activeView.CameraParallelScale = parallelScale
    activeView.CenterOfRotation = activeView.CameraFocalPoint
    activeView.CenterAxesVisibility = False
    activeView.OrientationAxesVisibility = False
    activeView.Background = [0.0, 0.0, 0.0]
    activeView.Background2 = [0.0, 0.0, 0.0]

    lookupTable = pwsimple.GetLookupTableForArray(colorArrayName, 1)
    lookupTable.RGBPoints = colorMap
    lookupTable.ScalarRangeInitialized = 1.0
    lookupTable.ColorSpace = 0  # 0 corresponds to RGB

    dataRep = pwsimple.GetDisplayProperties()
    dataRep.Representation = 'Slice'
    dataRep.SliceMode = sliceMode
    dataRep.Slice = sliceVal
    dataRep.LookupTable = lookupTable
    dataRep.ColorArrayName = colorArrayName

    retVal = {}
    retVal['lookupTable'] = lookupTable
    retVal['activeView'] = activeView
    return retVal
Exemplo n.º 4
0
def InitViewState(cameraFocalPoint, cameraPosition, colorArrayName, colorMap,
                  sofPoints, viewSize):
    if type(colorArrayName) is unicode:
        colorArrayName = colorArrayName.encode('ascii', 'ignore')

    activeView = pwsimple.CreateIfNeededRenderView()

    activeView.CameraFocalPoint = cameraFocalPoint
    activeView.CameraPosition = cameraPosition
    activeView.CameraViewUp = [0.0, 0.0, 1.0]
    activeView.CameraParallelProjection = False
    activeView.CenterOfRotation = activeView.CameraFocalPoint
    activeView.Background = [0.0, 0.0, 0.0]
    activeView.Background2 = [0.0, 0.0, 0.0]
    activeView.ViewSize = viewSize

    lookupTable = pwsimple.GetLookupTableForArray(colorArrayName, 1)
    lookupTable.RGBPoints = colorMap
    lookupTable.ScalarRangeInitialized = 1.0
    lookupTable.ColorSpace = 0  # 0 corresponds to RGB

    # Initial scalar opacity function
    sof = pwsimple.CreatePiecewiseFunction()
    sof.Points = sofPoints

    dataRep = pwsimple.Show()
    dataRep.ScalarOpacityFunction = sof
    dataRep.Representation = 'Volume'
    dataRep.ColorArrayName = colorArrayName
    dataRep.LookupTable = lookupTable

    retVal = {}
    retVal['sof'] = sof
    retVal['lookupTable'] = lookupTable
    retVal['activeView'] = activeView
    return retVal
Exemplo n.º 5
0
def InitViewState(cameraFocalPoint, cameraPosition, colorArrayName, colorMap,
                  sliceVal, sliceMode, parallelScale, cameraUp, meshes,
                  lineWidth, viewSize):
    if type(colorArrayName) is unicode:
        colorArrayName = colorArrayName.encode('ascii', 'ignore')

    if type(sliceMode) is unicode:
        sliceMode = sliceMode.encode('ascii', 'ignore')

    activeView = pwsimple.CreateIfNeededRenderView()

    activeView.CameraFocalPoint = cameraFocalPoint
    activeView.CameraPosition = cameraPosition
    activeView.CameraViewUp = cameraUp
    activeView.CameraParallelProjection = True
    activeView.CameraParallelScale = parallelScale
    activeView.CenterOfRotation = activeView.CameraFocalPoint
    activeView.CenterAxesVisibility = False
    activeView.OrientationAxesVisibility = False
    activeView.Background = [0.0, 0.0, 0.0]
    activeView.Background2 = [0.0, 0.0, 0.0]
    activeView.ViewSize = viewSize

    lookupTable = pwsimple.GetLookupTableForArray(colorArrayName, 1)
    lookupTable.RGBPoints = colorMap
    lookupTable.ScalarRangeInitialized = 1.0
    lookupTable.ColorSpace = 0  # 0 corresponds to RGB

    dataRep = pwsimple.GetDisplayProperties()
    dataRep.Representation = 'Slice'
    dataRep.SliceMode = sliceMode
    dataRep.Slice = sliceVal
    dataRep.LookupTable = lookupTable
    dataRep.ColorArrayName = colorArrayName

    volume = pwsimple.GetActiveSource()
    meshSlices = []
    for mesh in meshes:
        pwsimple.SetActiveSource(mesh['source'])
        pwsimple.Hide()
        meshSlice = pwsimple.Slice(SliceType='Plane')

        meshSlice.SliceOffsetValues = [0.0]
        meshSlice.SliceType = 'Plane'
        meshSlice.SliceType.Origin = [
            0.0, 0.0,
            math.cos(math.radians(mesh['orientation'][2])) * sliceVal
        ]
        meshSlice.SliceType.Normal = [0.0, 0.0, 1.0]
        meshDataRep = pwsimple.Show(meshSlice)
        meshDataRep.Representation = 'Points'
        meshDataRep.LineWidth = lineWidth
        meshDataRep.PointSize = lineWidth
        meshDataRep.AmbientColor = mesh['diffuseColor']
        meshDataRep.Orientation = mesh['orientation']
        meshSlices.append(meshSlice)

    pwsimple.SetActiveSource(volume)

    retVal = {}
    retVal['lookupTable'] = lookupTable
    retVal['activeView'] = activeView
    retVal['meshSlices'] = meshSlices
    return retVal