你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 04:56:51 +08:00
Updated with ruff formatter
这个提交包含在:
@@ -21,12 +21,20 @@ def convert_file(input_file_path, discretization, pad=1, parallel=False):
|
||||
return convert_files([input_file_path], discretization, pad=pad, parallel=parallel)
|
||||
|
||||
|
||||
def convert_files(input_file_paths, discretization, colors=[(0, 0, 0)], pad=1, parallel=False):
|
||||
def convert_files(
|
||||
input_file_paths, discretization, colors=[(0, 0, 0)], pad=1, parallel=False
|
||||
):
|
||||
meshes = []
|
||||
|
||||
for input_file_path in input_file_paths:
|
||||
mesh_obj = mesh.Mesh.from_file(input_file_path)
|
||||
org_mesh = np.hstack((mesh_obj.v0[:, np.newaxis], mesh_obj.v1[:, np.newaxis], mesh_obj.v2[:, np.newaxis]))
|
||||
org_mesh = np.hstack(
|
||||
(
|
||||
mesh_obj.v0[:, np.newaxis],
|
||||
mesh_obj.v1[:, np.newaxis],
|
||||
mesh_obj.v2[:, np.newaxis],
|
||||
)
|
||||
)
|
||||
meshes.append(org_mesh)
|
||||
vol, scale, shift = convert_meshes(meshes, discretization, parallel)
|
||||
vol = np.transpose(vol)
|
||||
|
@@ -6,7 +6,9 @@ def lines_to_voxels(line_list, pixels):
|
||||
x = 0
|
||||
for event_x, status, line_ind in generate_line_events(line_list):
|
||||
while event_x - x >= 0:
|
||||
lines = reduce(lambda acc, cur: acc + [line_list[cur]], current_line_indices, [])
|
||||
lines = reduce(
|
||||
lambda acc, cur: acc + [line_list[cur]], current_line_indices, []
|
||||
)
|
||||
paint_y_axis(lines, pixels, x)
|
||||
x += 1
|
||||
|
||||
|
@@ -19,7 +19,12 @@ def mesh_to_plane(mesh, bounding_box, parallel):
|
||||
|
||||
current_mesh_indices = set()
|
||||
z = 0
|
||||
with tqdm(total=bounding_box[2], desc="Processing Layers", ncols=get_terminal_width() - 1, file=sys.stdout) as pbar:
|
||||
with tqdm(
|
||||
total=bounding_box[2],
|
||||
desc="Processing Layers",
|
||||
ncols=get_terminal_width() - 1,
|
||||
file=sys.stdout,
|
||||
) as pbar:
|
||||
for event_z, status, tri_ind in generate_tri_events(mesh):
|
||||
while event_z - z >= 0:
|
||||
mesh_subset = [mesh[ind] for ind in current_mesh_indices]
|
||||
|
@@ -17,9 +17,15 @@ if __name__ == "__main__":
|
||||
usage="cd gprMax; python -m toolboxes.STLtoVoxel.stltovoxel stlfilename -matindex -dxdydz",
|
||||
)
|
||||
parser.add_argument(
|
||||
"stlfiles", help="can be the filename of a single STL file, or the path to folder containing multiple STL files"
|
||||
"stlfiles",
|
||||
help="can be the filename of a single STL file, or the path to folder containing multiple STL files",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-dxdydz",
|
||||
type=float,
|
||||
required=True,
|
||||
help="discretisation to use in voxelisation process",
|
||||
)
|
||||
parser.add_argument("-dxdydz", type=float, required=True, help="discretisation to use in voxelisation process")
|
||||
args = parser.parse_args()
|
||||
|
||||
if os.path.isdir(args.stlfiles):
|
||||
@@ -38,7 +44,9 @@ if __name__ == "__main__":
|
||||
newline = "\n\t"
|
||||
logger.info(f"\nConverting STL file(s): {newline.join(files)}")
|
||||
model_array = convert_files(files, dxdydz)
|
||||
logger.info(f"Number of voxels: {model_array.shape[0]} x {model_array.shape[1]} x {model_array.shape[2]}")
|
||||
logger.info(
|
||||
f"Number of voxels: {model_array.shape[0]} x {model_array.shape[1]} x {model_array.shape[2]}"
|
||||
)
|
||||
logger.info(f"Spatial discretisation: {dxdydz[0]} x {dxdydz[1]} x {dxdydz[2]}m")
|
||||
|
||||
# Write HDF5 file for gprMax using voxels
|
||||
|
在新工单中引用
屏蔽一个用户