1

我有一个我运行的自动剪辑脚本,作为它的一部分,我想拥有并选择将配色方案重新缩放为范围内的可见数据 - 布尔值。

clipDisplay.SetScalarBarVisibility(renderView1, True)Paraview 用户指南(第 10.1.2 章)中找到了此命令,并将其放置在剪辑的 paraview 跟踪脚本中的颜色转移函数的末尾。

运行脚本不会给出任何错误,但与在 GUI 中完成的相同操作相比,它不会重新调整配色方案。

我想普遍使用代码,所以手动选择具有数字定义的范围内的数据是不可能的......

编辑

使用跟踪你会得到:

# trace generated using paraview version 5.7.0
#
# To ensure correct image size when batch processing, please search 
# for and uncomment the line `# renderView*.ViewSize = [*,*]`

#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

# get color transfer function/color map for 'p'
pLUT = GetColorTransferFunction('p')
pLUT.AutomaticRescaleRangeMode = "Grow and update on 'Apply'"
pLUT.InterpretValuesAsCategories = 0
pLUT.AnnotationsInitialized = 0
pLUT.ShowCategoricalColorsinDataRangeOnly = 0
pLUT.RescaleOnVisibilityChange = 0
pLUT.EnableOpacityMapping = 0
pLUT.RGBPoints = [-714.7062377929688, 0.231373, 0.298039, 0.752941, -259.51192474365234, 0.865003, 0.865003, 0.865003, 195.68238830566406, 0.705882, 0.0156863, 0.14902]
pLUT.UseLogScale = 0
pLUT.ColorSpace = 'Diverging'
pLUT.UseBelowRangeColor = 0
pLUT.BelowRangeColor = [0.0, 0.0, 0.0]
pLUT.UseAboveRangeColor = 0
pLUT.AboveRangeColor = [0.5, 0.5, 0.5]
pLUT.NanColor = [1.0, 1.0, 0.0]
pLUT.NanOpacity = 1.0
pLUT.Discretize = 1
pLUT.NumberOfTableValues = 256
pLUT.ScalarRangeInitialized = 1.0
pLUT.HSVWrap = 0
pLUT.VectorComponent = 0
pLUT.VectorMode = 'Magnitude'
pLUT.AllowDuplicateScalars = 1
pLUT.Annotations = []
pLUT.ActiveAnnotatedValues = []
pLUT.IndexedColors = []
pLUT.IndexedOpacities = []

# Rescale transfer function
pLUT.RescaleTransferFunction(-413.7960510253906, 192.35369873046875)

# get opacity transfer function/opacity map for 'p'
pPWF = GetOpacityTransferFunction('p')
pPWF.Points = [-714.7062377929688, 0.0, 0.5, 0.0, 195.68238830566406, 1.0, 0.5, 0.0]
pPWF.AllowDuplicateScalars = 1
pPWF.UseLogScale = 0
pPWF.ScalarRangeInitialized = 1

# Rescale transfer function
pPWF.RescaleTransferFunction(-413.7960510253906, 192.35369873046875)

请问有什么想法吗?干杯

4

1 回答 1

3

clip1Display.RescaleTransferFunctionToDataRange(False, True)是你想要的线。有关信息,在查找接口操作的 Python 版本时,您可以使用Trace( Tools/Start Trace)。它记录界面中的每个操作,当您停止 ( Tools/Stop Trace) 时,它会打印这些操作的 python 版本。

编辑

您无法轻松地在 python 中重新缩放到可见范围。

一种解决方法是提取可见数据以获取可见范围,最后将其应用于原始数据传输函数。这个宏可以解决问题


from paraview.simple import *
v=GetActiveView()
source=GetActiveSource()
SelectSurfacePoints(Rectangle=[0, 0, v.ViewSize[0], v.ViewSize[1]])# Or SelectPointsThrough 
extractSelection1=ExtractSelection()
# s=Show()
arrayInfo = e.PointData['X'] # replace 'X' by the array you want
r=arrayInfo.GetRange(0)
Delete(extractSelection1)
del extractSelection1
SetActiveSource(source)
ClearSelection()

pLUT = GetColorTransferFunction('X')
pLUT.RescaleTransferFunction(r[0], r[1])


于 2020-07-22T07:24:52.197 回答