你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Changed name of file writing method. Added method for writing gprMax XML materials to file.
这个提交包含在:
@@ -52,7 +52,7 @@ class GeometryView:
|
|||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.type = type
|
self.type = type
|
||||||
|
|
||||||
def write_file(self, modelrun, numbermodelruns, G):
|
def write_vtk(self, modelrun, numbermodelruns, G):
|
||||||
"""Writes the geometry information to a VTK file. Either ImageData (.vti) for a per cell geometry view, or PolygonalData (.vtp) for a per cell edge geometry view.
|
"""Writes the geometry information to a VTK file. Either ImageData (.vti) for a per cell geometry view, or PolygonalData (.vtp) for a per cell edge geometry view.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -101,11 +101,7 @@ class GeometryView:
|
|||||||
f.write(pack('I', G.solid[i, j, k]))
|
f.write(pack('I', G.solid[i, j, k]))
|
||||||
f.write('\n</AppendedData>\n</VTKFile>'.encode('utf-8'))
|
f.write('\n</AppendedData>\n</VTKFile>'.encode('utf-8'))
|
||||||
|
|
||||||
# Write gprMax specific information which relates material name to material numeric identifier
|
self.write_materials(f, G.materials)
|
||||||
f.write('\n\n<gprMax>\n'.encode('utf-8'))
|
|
||||||
for material in G.materials:
|
|
||||||
f.write('<Material name="{}">{}</Material>\n'.format(material.ID, material.numID).encode('utf-8'))
|
|
||||||
f.write('</gprMax>\n'.encode('utf-8'))
|
|
||||||
|
|
||||||
elif self.type == 'f':
|
elif self.type == 'f':
|
||||||
self.filename += '.vtp'
|
self.filename += '.vtp'
|
||||||
@@ -197,9 +193,18 @@ class GeometryView:
|
|||||||
|
|
||||||
f.write('\n</AppendedData>\n</VTKFile>'.encode('utf-8'))
|
f.write('\n</AppendedData>\n</VTKFile>'.encode('utf-8'))
|
||||||
|
|
||||||
# Write gprMax specific information which relates material name to material numeric identifier
|
self.write_materials(f, G.materials)
|
||||||
|
|
||||||
|
def write_materials(self, f, materials):
|
||||||
|
"""Writes gprMax specific information which relates material name to material numeric identifier.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
f (filehandle): VTK file.
|
||||||
|
materials (list): Materials in the model.
|
||||||
|
"""
|
||||||
|
|
||||||
f.write('\n\n<gprMax>\n'.encode('utf-8'))
|
f.write('\n\n<gprMax>\n'.encode('utf-8'))
|
||||||
for material in G.materials:
|
for material in materials:
|
||||||
f.write('<Material name="{}">{}</Material>\n'.format(material.ID, material.numID).encode('utf-8'))
|
f.write('<Material name="{}">{}</Material>\n'.format(material.ID, material.numID).encode('utf-8'))
|
||||||
f.write('</gprMax>\n'.encode('utf-8'))
|
f.write('</gprMax>\n'.encode('utf-8'))
|
||||||
|
|
||||||
|
在新工单中引用
屏蔽一个用户