File size: 1,121 Bytes
e73a251
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Large-scale / out-of-core reconstruction example.

When your point cloud has millions of points (e.g. a full building or
outdoor LiDAR scan), NKSR supports chunking: the scene is split into
overlapping blocks, each reconstructed independently, and then fused
into a single implicit field.
"""

from pathlib import Path
from nksr_wrapper import NKSRMeshReconstructor, load_point_cloud, save_mesh

ply_path = Path("assets/large_scene.ply")
points, normals = load_point_cloud(ply_path)

recon = NKSRMeshReconstructor(
    device="cuda:0",
    config="ks",
    chunk_tmp_device="cpu",   # offload finished chunks to CPU RAM
)

mesh = recon.reconstruct(
    points=points,
    normals=normals,
    chunk_size=50.0,          # each chunk is a 50-unit cube
    overlap_ratio=0.05,       # 5 % overlap for smooth transitions
    approx_kernel_grad=True,  # faster gradient approximation
    solver_tol=1e-4,          # slightly looser tolerance — huge scenes
    mise_iter=1,
)

save_mesh("large_scene_mesh.ply", mesh.vertices, mesh.faces)
print(f"Reconstructed {len(mesh.vertices):,} vertices, {len(mesh.faces):,} faces")