你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 23:14:03 +08:00
Updated to try and threshold only materials present in geometry file (and not all materials in model). Corrected the problem of not initially rendering things.
这个提交包含在:
@@ -36,18 +36,18 @@ renderview.ResetCamera()
|
|||||||
|
|
||||||
# List to hold material identifiers written in VTK file in tags <gprMax3D> <Material>
|
# List to hold material identifiers written in VTK file in tags <gprMax3D> <Material>
|
||||||
materials = []
|
materials = []
|
||||||
with open(model.FileName[0], 'rb') as f:
|
with open(model.FileName[0], 'r') as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith('<Material'):
|
if line.startswith('<Material'):
|
||||||
line.rstrip('\n')
|
line.rstrip('\n')
|
||||||
tmp = (float(ET.fromstring(line).text), ET.fromstring(line).attrib.get('name'))
|
tmp = (int(ET.fromstring(line).text), ET.fromstring(line).attrib.get('name'))
|
||||||
materials.append(tmp)
|
materials.append(tmp)
|
||||||
|
|
||||||
|
# Get range of data
|
||||||
|
datarange = model.CellData.GetArray(0).GetRange()
|
||||||
|
|
||||||
# If the geometry file does not contain any information on materials names
|
# If the geometry file does not contain any information on materials names
|
||||||
if not materials:
|
if not materials:
|
||||||
# Get range of data and set upper bound
|
|
||||||
datarange = model.CellData.GetArray(0).GetRange()
|
|
||||||
|
|
||||||
for x in range(0, int(datarange[1]) + 1):
|
for x in range(0, int(datarange[1]) + 1):
|
||||||
threshold = Threshold(Input=model)
|
threshold = Threshold(Input=model)
|
||||||
threshold.ThresholdRange = [x, x]
|
threshold.ThresholdRange = [x, x]
|
||||||
@@ -66,15 +66,18 @@ if not materials:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
# Create threshold for materials (name and numeric value)
|
# Create threshold for materials (name and numeric value)
|
||||||
for material in range(len(materials)):
|
for x in range(0, int(datarange[1]) + 1):
|
||||||
|
for y in range(len(materials)):
|
||||||
|
if materials[y][0] == x:
|
||||||
threshold = Threshold(Input=model)
|
threshold = Threshold(Input=model)
|
||||||
threshold.ThresholdRange = [materials[material][0], materials[material][0]]
|
threshold.ThresholdRange = [materials[y][0], materials[y][0]]
|
||||||
|
|
||||||
RenameSource(materials[material][1], threshold)
|
RenameSource(materials[y][1], threshold)
|
||||||
|
|
||||||
if materials[material][0] != 1:
|
if materials[y][0] != 1:
|
||||||
# Show data in view
|
# Show data in view
|
||||||
thresholdDisplay = Show(threshold, renderview)
|
Show(threshold, renderview)
|
||||||
|
|
||||||
|
Render()
|
||||||
# Show color bar/color legend
|
# Show color bar/color legend
|
||||||
#thresholdDisplay.SetScalarBarVisibility(renderview, False)
|
#thresholdDisplay.SetScalarBarVisibility(renderview, False)
|
在新工单中引用
屏蔽一个用户