Upload examples/chunked_reconstruction.py
Browse files123456789101112131415161718192021222324252627282930313233"""Large-scale / out-of-core reconstruction example.
When your point cloud has millions of points (e.g. a full building oroutdoor LiDAR scan), NKSR supports chunking: the scene is split intooverlapping blocks, each reconstructed independently, and then fusedinto a single implicit field."""
from pathlib import Pathfrom 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")examples/chunked_reconstruction.pyAdded+33