2

这看起来很简单,但我很难在不同颜色的平面上表示不同的标量值。我有一个包含季节数据“dados_solo.vtk”的文件,并且具有与土壤温度“soilTemp”相对应的标量值,我必须用不同颜色表示每个季节的土壤温度数据飞机。我用 vtkStructuredGridGeometryFilter 表示它们没有问题,但现在我必须用平面表示,而不是点。

图像

这是我到目前为止的代码:

    package require vtk
    package require vtkinteraction

vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

# Definir o estilo de interacção 
vtkInteractorStyleTrackballCamera style
    iren SetInteractorStyle style

    iren AddObserver UserEvent {wm deiconify .vtkInteract}

vtkDataSetReader reader
    reader SetFileName "dados_solo.vtk"
    reader SetScalarsName soilTemp
    reader Update

vtkDataSetReader readertemp
    readertemp SetFileName "dados_solo.vtk"
    readertemp SetScalarsName soilTemp
    readertemp Update

# Contours of the grid-----------------------------------------------------
vtkStructuredGridOutlineFilter outline
    outline SetInput [reader GetStructuredGridOutput]
vtkPolyDataMapper mapOutline
    mapOutline SetInput [outline GetOutput]
vtkActor outlineActor
    outlineActor SetMapper mapOutline
    [outlineActor GetProperty] SetColor 1 0 0


# Points of Grid-----------------------------------------------------
vtkStructuredGridGeometryFilter compPlane
    compPlane SetInput [reader GetStructuredGridOutput]

vtkPolyDataMapper planeMapper
    planeMapper SetInput [compPlane GetOutput]
    eval planeMapper SetScalarRange \
      [[[[reader GetOutput] GetPointData] GetScalars] GetRange]
    planeMapper ScalarVisibilityOn

vtkActor planeActor
    planeActor SetMapper planeMapper
    [planeActor GetProperty] SetColor 0 1 0

# -------------------------------------------------------------------
vtkPlane plane
    eval plane SetOrigin [[reader GetOutput] GetCenter]

vtkCutter planeCut
    planeCut SetInput [reader GetOutput]
    planeCut SetCutFunction plane

vtkPolyDataMapper cutMapper
    cutMapper SetInput [planeCut GetOutput]
    eval cutMapper SetScalarRange \
      [[[[reader GetOutput] GetPointData] GetScalars] GetRange]

vtkActor cutActor
    cutActor SetMapper cutMapper
# -------------------------------------------------------------------

ren1 AddActor cutActor 
ren1 AddActor outlineActor
ren1 AddActor planeActor
renWin SetSize 500 500
ren1 SetBackground 0.1 0.1 0.1
renWin Render
4

0 回答 0