|
|
|
|
@ -92,7 +92,7 @@ def compute_bbox_all(dict_mesh_obj,is_downsample):
@@ -92,7 +92,7 @@ def compute_bbox_all(dict_mesh_obj,is_downsample):
|
|
|
|
|
dict_total_matrix[obj_name] = total_matrix |
|
|
|
|
dict_pcd_fix[ply_name] = pcd_fix |
|
|
|
|
|
|
|
|
|
print(f"compute_bbox obj_name={obj_name} ply_name={ply_name} time={time.time()-start_time}") |
|
|
|
|
# print(f"compute_bbox obj_name={obj_name} ply_name={ply_name} time={time.time()-start_time}") |
|
|
|
|
|
|
|
|
|
# dict_mesh_obj.clear() |
|
|
|
|
# del dict_mesh_obj |
|
|
|
|
@ -115,13 +115,15 @@ def compute_bbox(mesh_obj, obj_name, is_downsample=True):
@@ -115,13 +115,15 @@ def compute_bbox(mesh_obj, obj_name, is_downsample=True):
|
|
|
|
|
succ, total_matrix, z_max, min_bound, max_bound, ply_name = compute_bbox_net(printId) |
|
|
|
|
if not succ : |
|
|
|
|
total_matrix, z_max, min_bound, max_bound, ply_name = compute_bbox_ext(mesh_obj, obj_name, is_downsample) |
|
|
|
|
print(f"compute_bbox_net fail {printId}") |
|
|
|
|
else: |
|
|
|
|
ply_name = f"{os.path.splitext(obj_name)[0]}={ply_name.split('=')[1]}" |
|
|
|
|
print(f"compute_bbox_net succ {printId}") |
|
|
|
|
|
|
|
|
|
# print(f"compute_bbox_net printId = {printId}, total_matrix = {total_matrix}, ply_name = {ply_name}") |
|
|
|
|
else : |
|
|
|
|
total_matrix, z_max, min_bound, max_bound, ply_name = compute_bbox_ext(mesh_obj, obj_name, is_downsample) |
|
|
|
|
# print(f"compute_bbox_ext total_matrix = {total_matrix}, ply_name = {ply_name}") |
|
|
|
|
print(f"compute_bbox_ext ply_name = {ply_name}") |
|
|
|
|
|
|
|
|
|
transformed_vertices = mesh_transform_by_matrix(np.asarray(mesh_obj_origin.vertices), total_matrix) |
|
|
|
|
|
|
|
|
|
@ -154,7 +156,7 @@ def compute_bbox_net(printId):
@@ -154,7 +156,7 @@ def compute_bbox_net(printId):
|
|
|
|
|
try: |
|
|
|
|
matrix_list = ast.literal_eval(homo_matrix_str) # 直接转换为二维列表 |
|
|
|
|
reconstructed_matrix = np.array(matrix_list, dtype=float) |
|
|
|
|
print("矩阵形状:", reconstructed_matrix.shape) # 应该是 (4, 4) |
|
|
|
|
# print("矩阵形状:", reconstructed_matrix.shape) # 应该是 (4, 4) |
|
|
|
|
except (ValueError, SyntaxError) as e: |
|
|
|
|
print(f"解析错误: {e}") |
|
|
|
|
|
|
|
|
|
@ -215,7 +217,7 @@ class Platform:
@@ -215,7 +217,7 @@ class Platform:
|
|
|
|
|
|
|
|
|
|
if self.is_cross_border(x, y, z, model): |
|
|
|
|
|
|
|
|
|
print(f"can_place False 1 cross_border {x}, {y}, {z}, {model}, {self.width}, {self.depth}, {self.height}") |
|
|
|
|
# print(f"can_place False 1 cross_border {x}, {y}, {z}, {model}, {self.width}, {self.depth}, {self.height}") |
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
# 碰撞检测(正确逻辑与间距处理) |
|
|
|
|
@ -230,7 +232,7 @@ class Platform:
@@ -230,7 +232,7 @@ class Platform:
|
|
|
|
|
y - my - extend_dist_model_y < py and |
|
|
|
|
z < pz + pdz and |
|
|
|
|
z + mz > pz): |
|
|
|
|
print("can_place False 2",False,model,x,y,z,px,pdx,extend_dist_model_x,py,pdy,extend_dist_model_y,my,pz,pdz,pz) |
|
|
|
|
# print("can_place False 2",False,model,x,y,z,px,pdx,extend_dist_model_x,py,pdy,extend_dist_model_y,my,pz,pdz,pz) |
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
return True |
|
|
|
|
@ -256,7 +258,7 @@ class Platform:
@@ -256,7 +258,7 @@ class Platform:
|
|
|
|
|
model['position'] = (self.width - extend_dist_border_x_max, self.depth - extend_dist_border_y_max, 0) |
|
|
|
|
model['first_line'] = False |
|
|
|
|
|
|
|
|
|
print("model position1", model['name'], model['position']) |
|
|
|
|
# print("model position1", model['name'], model['position']) |
|
|
|
|
self.placed_models.append(model) |
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
@ -268,7 +270,7 @@ class Platform:
@@ -268,7 +270,7 @@ class Platform:
|
|
|
|
|
else: |
|
|
|
|
px = pre_px - pre_mx - extend_dist_model_x |
|
|
|
|
model['first_line'] = False |
|
|
|
|
print(model['name'], "px", px, pre_px, pre_mx) |
|
|
|
|
# print(model['name'], "px", px, pre_px, pre_mx) |
|
|
|
|
|
|
|
|
|
reach_limit_x = False |
|
|
|
|
if self.first_line: |
|
|
|
|
@ -296,7 +298,7 @@ class Platform:
@@ -296,7 +298,7 @@ class Platform:
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
model['position'] = (px, y, z) |
|
|
|
|
print("model position2", model['name'], model['position']) |
|
|
|
|
# print("model position2", model['name'], model['position']) |
|
|
|
|
self.placed_models.append(model) |
|
|
|
|
return True |
|
|
|
|
else: |
|
|
|
|
@ -314,7 +316,7 @@ class Platform:
@@ -314,7 +316,7 @@ class Platform:
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
model['position'] = (px, y, z) |
|
|
|
|
print("model position2", model['name'], model['position']) |
|
|
|
|
# print("model position2", model['name'], model['position']) |
|
|
|
|
self.placed_models.append(model) |
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|