()
| 25 | |
| 26 | |
| 27 | def main(): |
| 28 | np.random.seed(1) |
| 29 | # generate random plane with hole |
| 30 | plane = generate_3d_plane(bounds_x=[0, 10, 0.5], bounds_y=[0, 10, 0.5], holes=[ |
| 31 | [[3, 6], [3, 6]]], height_noise=0.04, planar_noise=0.04) |
| 32 | |
| 33 | large_wall = generate_3d_plane(bounds_x=[0.5, 4, 1.0], bounds_y=[0, 9.5, 0.5], holes=[], height_noise=0.04, planar_noise=0.1) |
| 34 | # Generate top of box (causing the hole that we see) |
| 35 | box_top = generate_3d_plane(bounds_x=[3, 6, 0.5], bounds_y=[3, 6, 0.5], holes=[ |
| 36 | ], height_noise=0.02, height=2, planar_noise=0.03) |
| 37 | # Generate side of box (causing the hole that we see) |
| 38 | box_side = generate_3d_plane(bounds_x=[.25, 2, 0.5], bounds_y=[ |
| 39 | 0, 3, 0.5], holes=[], height_noise=0.02, planar_noise=0.02) |
| 40 | rm = rotation_matrix([0,1,0], -math.pi/2.0) |
| 41 | box_side = apply_rotation(rm, box_side) + [6, 3, 0] |
| 42 | |
| 43 | large_wall = apply_rotation(rm , large_wall) + [10, 0, -3.5] |
| 44 | # box_side = r.apply(box_side) + [5, 3, 0] |
| 45 | # All points joined together |
| 46 | points = np.concatenate((plane, box_side, box_top, large_wall)) |
| 47 | |
| 48 | points_mat = MatrixDouble(points) |
| 49 | polylidar_kwargs = dict(alpha=0.0, lmax=1.0, min_triangles=10, z_thresh=0.15, norm_thresh_min=0.95) |
| 50 | polylidar = Polylidar3D(**polylidar_kwargs) |
| 51 | |
| 52 | elev = 15.0 |
| 53 | azim = -35 |
| 54 | |
| 55 | # Show Point Cloud |
| 56 | print("Should see point raw point cloud") |
| 57 | fig, ax = plt.subplots(figsize=(10, 10), nrows=1, ncols=1, |
| 58 | subplot_kw=dict(projection='3d')) |
| 59 | # plot points |
| 60 | ax.scatter(*scale_points(points), s=20.0, c=points[:, 2], cmap=plt.cm.plasma) |
| 61 | set_axes_equal(ax, ignore_z=True) |
| 62 | ax.set_zlim3d([-4, 6]) |
| 63 | ax.view_init(elev=elev, azim=azim) |
| 64 | set_labels(ax) |
| 65 | fig.savefig("assets/scratch/Basic25DAlgorithm_pointcloud.pdf", bbox_inches='tight') |
| 66 | fig.savefig("assets/scratch/Basic25DAlgorithm_pointcloud.png", bbox_inches='tight', pad_inches=-0.8) |
| 67 | plt.show() |
| 68 | |
| 69 | |
| 70 | # Extracts planes and polygons, time |
| 71 | t1 = time.time() |
| 72 | mesh, planes, polygons = polylidar.extract_planes_and_polygons(points_mat) |
| 73 | t2 = time.time() |
| 74 | print("Polylidar Took {:.2f} milliseconds".format((t2 - t1) * 1000)) |
| 75 | |
| 76 | triangles = np.asarray(mesh.triangles) |
| 77 | all_planes = [np.arange(triangles.shape[0])] |
| 78 | |
| 79 | # Show Triangulation |
| 80 | fig, ax = plt.subplots(figsize=(10, 10), nrows=1, ncols=1, |
| 81 | subplot_kw=dict(projection='3d')) |
| 82 | |
| 83 | plot_planes_3d(points, triangles, all_planes, ax, alpha=0.0, z_value=-4.0) |
| 84 | plot_planes_3d(points, triangles, all_planes, ax, alpha=0.5) |
no test coverage detected