コード例 #1
0
ファイル: midascommon.py プロジェクト: tasahi/Midas
def OpenData (filename, otherMeshes):
  if type(filename) is unicode:
    filename = filename.encode('ascii', 'ignore')
  
  srcObj = pwsimple.OpenDataFile(filename)
  pwsimple.Show()
  imageData = pwsimple.GetDataInformation()
  
  # Load other meshes into scene
  meshes = []
  for mesh in otherMeshes:
    diffuseColor = [float(mesh['diffuseColor'][0]), float(mesh['diffuseColor'][1]), float(mesh['diffuseColor'][2])]
    orientation = [float(mesh['orientation'][0]), float(mesh['orientation'][1]), float(mesh['orientation'][2])]
    source = pwsimple.OpenDataFile(mesh['path'])
    pwsimple.SetActiveSource(source)
    properties = pwsimple.Show()
    properties.Representation = 'Surface'
    properties.DiffuseColor = diffuseColor
    properties.Orientation = orientation
    meshes.append({'source': source, 'item': mesh['item'], 'visible': True, 'diffuseColor': diffuseColor, 'orientation': orientation})
  
  pwsimple.SetActiveSource(srcObj)
  
  retVal = {}
  retVal['input'] = srcObj
  retVal['imageData'] = imageData
  retVal['meshes'] = meshes
  return retVal
コード例 #2
0
ファイル: midascommon.py プロジェクト: tasahi/Midas
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
コード例 #3
0
def ChangeSlice(volume, slice, sliceMode, meshes, lineWidth):
    if type(sliceMode) is unicode:
        sliceMode = sliceMode.encode('ascii', 'ignore')

    dataRep = pwsimple.GetDisplayProperties(volume)
    dataRep.Slice = slice

    # Delete any previous slice objects in the scene
    sources = pwsimple.GetSources()
    for key, srcId in sources:
        if key[:5] == 'Slice':
            pwsimple.Delete(sources[(key, srcId)])

    meshSlices = []
    for mesh in meshes:
        if sliceMode == 'XY Plane':
            origin = [
                0.0, 0.0,
                math.cos(math.radians(mesh['orientation'][2])) * slice
            ]
            normal = [0.0, 0.0, 1.0]
        elif sliceMode == 'XZ Plane':
            origin = [
                0.0,
                math.cos(math.radians(mesh['orientation'][1])) * slice, 0.0
            ]
            normal = [0.0, 1.0, 0.0]
        else:
            origin = [
                math.cos(math.radians(mesh['orientation'][0])) * slice, 0.0,
                0.0
            ]
            normal = [1.0, 0.0, 0.0]

        pwsimple.Hide(mesh['source'])
        meshSlice = pwsimple.Slice(Input=mesh['source'], SliceType='Plane')
        pwsimple.SetActiveSource(volume)

        meshSlice.SliceOffsetValues = [0.0]
        meshSlice.SliceType = 'Plane'
        meshSlice.SliceType.Origin = origin
        meshSlice.SliceType.Normal = normal
        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['meshSlices'] = meshSlices
    retVal['sliceMode'] = sliceMode
    return retVal
コード例 #4
0
ファイル: midasdual.py プロジェクト: tasahi/Midas
def ShowSphere(point, color, radius, input):
    glyph = pwsimple.Sphere()
    glyph.Radius = radius
    glyph.Center = point
    dataRep = pwsimple.Show()
    dataRep.Representation = 'Surface'
    dataRep.DiffuseColor = color

    pwsimple.SetActiveSource(input)

    retVal = {}
    retVal['glyph'] = glyph
    retVal['surfaceColor'] = color
    retVal['radius'] = radius
    return retVal
コード例 #5
0
def ShowSphere(point, color, radius, objectToDelete, input):
    if objectToDelete is not False:
        pwsimple.SetActiveSource(objectToDelete)
        pwsimple.Delete()

    glyph = pwsimple.Sphere()
    glyph.Radius = radius
    glyph.Center = point
    dataRep = pwsimple.Show()
    dataRep.Representation = 'Surface'
    dataRep.DiffuseColor = color

    pwsimple.SetActiveSource(input)

    retVal = {}
    retVal['glyph'] = glyph
    return retVal
コード例 #6
0
ファイル: midasvr.py プロジェクト: tasahi/Midas
def ExtractSubgrid(source, bounds, lookupTable, sof, colorArrayName, toHide):
    pwsimple.SetActiveSource(source)
    subgrid = pwsimple.ExtractSubset()
    subgrid.VOI = bounds
    pwsimple.SetActiveSource(subgrid)

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

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

    pwsimple.SetActiveSource(source)
    pwsimple.Hide(source)
    if toHide:
        pwsimple.Hide(toHide)

    pwsimple.SetActiveSource(subgrid)
    return subgrid
コード例 #7
0
ファイル: midasvr.py プロジェクト: tasahi/Midas
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
コード例 #8
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