feat: update algorithm integrations and point cloud overlays

This commit is contained in:
2026-06-30 16:46:36 +08:00
parent ddca7e5436
commit 7e2e56a50d
64 changed files with 4356 additions and 2781 deletions

View File

@@ -39,8 +39,8 @@ registration:
random_seed:
evaluation:
chunk_size: 2048
triangle_chunk_size: 4096
chunk_size: 8192
triangle_chunk_size: 512
cad_mesh_deflection: 0.1
curvature:

View File

@@ -74,15 +74,23 @@ class Evaluator:
) -> tuple[np.ndarray, DistanceStats]:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
dtype = torch.float64
# vertices/triangles 上 GPU(mesh 通常几百MB,可以接受)
vertices_t = torch.as_tensor(np.asarray(vertices, dtype=np.float64), dtype=dtype, device=device)
faces_t = torch.as_tensor(np.asarray(faces, dtype=np.int64), dtype=torch.long, device=device)
triangles = vertices_t[faces_t]
points_t = torch.as_tensor(points, dtype=dtype, device=device)
del vertices_t, faces_t # 释放原始 vertices/faces,只保留 triangles
# points 保留在 CPU,按 point_chunk 逐批传上 GPU,避免 10 亿点全量上 GPU OOM
points_np = np.asarray(points, dtype=np.float64)
n_points = points_np.shape[0]
distances = []
with torch.no_grad():
for start in range(0, points_t.shape[0], point_chunk_size):
chunk = points_t[start:start + point_chunk_size]
for start in range(0, n_points, point_chunk_size):
chunk = torch.as_tensor(
points_np[start:start + point_chunk_size], dtype=dtype, device=device
)
if triangle_chunk_size is None or triangle_chunk_size <= 0:
dist2 = self._point_to_triangle_distance_squared(chunk, triangles)
min_dist2 = dist2.min(dim=1).values
@@ -90,7 +98,7 @@ class Evaluator:
min_dist2 = torch.full(
(chunk.shape[0],),
torch.inf,
dtype=points_t.dtype,
dtype=dtype,
device=device,
)
for triangle_start in range(0, triangles.shape[0], triangle_chunk_size):