import open3d as o3d
import numpy as np

# PLYファイルのパスを指定
ply_file_path = "20250223_room.ply"

# PLYファイルを読み込む
point_cloud = o3d.io.read_point_cloud(ply_file_path)

#範囲を指定してトリミング
min_bound = np.array([-10, -10, -10])  # 最小座標 (X_min, Y_min, Z_min)
max_bound = np.array([10, 10, 10])     # 最大座標 (X_max, Y_max, Z_max)

# 指定範囲内の点のみ抽出
cropped_pc = point_cloud.crop(o3d.geometry.AxisAlignedBoundingBox(min_bound, max_bound))

# 可視化
o3d.visualization.draw_geometries([cropped_pc],
                                  window_name="PLY Viewer",
                                  width=800,
                                  height=600,
                                  left=50,
                                  top=50,
                                  point_show_normal=False)
