()
| 12 | |
| 13 | |
| 14 | def main(): |
| 15 | kwargs = dict(num_groups=2, group_size=1000, dist=100.0, seed=1) |
| 16 | # generate 2 random normally distributed clusters of points, 200 X 2 numpy array. |
| 17 | points = generate_test_points(**kwargs) |
| 18 | lmax = get_estimated_lmax(**kwargs) |
| 19 | polylidar_kwargs = dict(alpha=0.0, lmax=lmax, min_triangles=5) |
| 20 | |
| 21 | # Convert points to matrix format (no copy) and make Polylidar3D Object |
| 22 | points_mat = MatrixDouble(points, copy=False) |
| 23 | polylidar = Polylidar3D(**polylidar_kwargs) |
| 24 | |
| 25 | # Extract the mesh, planes, polygons, and time |
| 26 | t1 = time.perf_counter() |
| 27 | mesh, planes, polygons = polylidar.extract_planes_and_polygons(points_mat) |
| 28 | t2 = time.perf_counter() |
| 29 | |
| 30 | print("Took {:.2f} milliseconds".format((t2 - t1) * 1000)) |
| 31 | |
| 32 | # Convert to numpy format, no copy with np.asarray() |
| 33 | triangles = np.asarray(mesh.triangles) |
| 34 | |
| 35 | fig, ax = plt.subplots(figsize=(10, 10), nrows=1, ncols=1) |
| 36 | # plot points |
| 37 | ax.scatter(points[:, 0], points[:, 1], c='k') |
| 38 | # plot all triangles |
| 39 | # plt.triplot(points[:,0], points[:,1], triangles) # better alternative |
| 40 | plot_triangles(get_triangles_from_list(triangles, points), ax) |
| 41 | # plot seperated planar triangular segments |
| 42 | triangle_meshes = get_colored_planar_segments(planes, triangles, points) |
| 43 | plot_triangle_meshes(triangle_meshes, ax) |
| 44 | # plot polygons |
| 45 | plot_polygons(polygons, points, ax) |
| 46 | plt.axis('equal') |
| 47 | plt.show() |
| 48 | |
| 49 | |
| 50 | if __name__ == "__main__": |
no test coverage detected