def bunny(event=None): pcd_file = open(os.path.join('..', 'assets', 'models', 'bunny.pcd'), 'r').readlines()[10:] # create the point_cloud pc = Graphic3d_ArrayOfPoints(len(pcd_file)) for line in pcd_file: x, y, z = map(float, line.split()) pc.AddVertex(x, y, z) point_cloud = AIS_PointCloud() point_cloud.SetPoints(pc) ais_context = display.GetContext() ais_context.Display(point_cloud) display.View_Iso() display.FitAll()
def random_points(event=None): n_points = 500000 # first, create a set of 1000 points points_3d = Graphic3d_ArrayOfPoints(n_points) for idx in range(n_points): x = random.uniform(-50, 50) y = random.uniform(-50, 50) z = random.uniform(-50, 50) points_3d.AddVertex(x, y, z) # then build the point cloud point_cloud = AIS_PointCloud() point_cloud.SetPoints(points_3d) # display ais_context = display.GetContext() ais_context.Display(point_cloud, True) display.View_Iso() display.FitAll()
def tabletop(event=None): pcd_file = open(os.path.join('..', 'assets', 'models', 'tabletop.pcd'), 'r').readlines()[11:] # create the point_cloud pc = Graphic3d_ArrayOfPoints(len(pcd_file), True) for line in pcd_file: x, y, z, rgb = map(float, line.split()) r, g, b = unpackRGB(rgb) color = Quantity_Color(r/float(255), g/float(255), b/float(255), Quantity_TOC_RGB) pc.AddVertex(gp_Pnt(x, y, z), color) # then build the point cloud point_cloud = AIS_PointCloud() point_cloud.SetPoints(pc) # display ais_context = display.GetContext() ais_context.Display(point_cloud) display.DisableAntiAliasing() display.View_Iso() display.FitAll()
def bunny(event=None): pcd_file_name = os.path.join('..', 'assets', 'models', 'bunny.pcd') # compute number of lines nbr_of_vertices = pcd_get_number_of_vertices(pcd_file_name) print("Number of vertices :", nbr_of_vertices) # create the point_cloud pc = Graphic3d_ArrayOfPoints(nbr_of_vertices) # fedd it with vertices fp = open(pcd_file_name, 'r') # read 11 lines to skip header for i in range(10): fp.readline() for i in range(nbr_of_vertices): line = fp.readline() x, y, z = map(float, line.split()) pc.AddVertex(x, y, z) point_cloud = AIS_PointCloud() point_cloud.SetPoints(pc) ais_context = display.GetContext() ais_context.Display(point_cloud, True) display.View_Iso() display.FitAll()
from OCC.Core.Graphic3d import Graphic3d_ArrayOfPoints from OCC.Core.AIS import AIS_PointCloud from OCC.Core.Bnd import Bnd_Box, Bnd_Array1OfSphere if __name__ == "__main__": argvs = sys.argv parser = argparse.ArgumentParser() opt = parser.parse_args() print(opt, argvs) obj = dispocc() obj.display.DisplayShape(gp_Pnt()) num = 100000 pnt_3d = Graphic3d_ArrayOfPoints(num) for idx in range(num): x = random.uniform(-0.5, 0.5) y = random.uniform(-0.5, 0.5) z = random.uniform(-0.5, 0.5) r = np.sqrt(x**2 + y**2 + z**2) ratio = random.uniform(0, 100) pnt_3d.AddVertex(x / r * ratio, y / r * ratio, z / r * ratio) point_cloud = AIS_PointCloud() point_cloud.SetPoints(pnt_3d) box = point_cloud.GetBoundingBox() print(box) ais_context = obj.display.GetContext() ais_context.Display(point_cloud, True)
from OCC.Core.BRepAlgoAPI import BRepAlgoAPI_Algo from OCC.Core.Graphic3d import Graphic3d_ArrayOfPoints from OCC.Core.AIS import AIS_PointCloud from OCC.Core.Bnd import Bnd_Box, Bnd_Array1OfSphere if __name__ == "__main__": argvs = sys.argv parser = OptionParser() opt, argc = parser.parse_args(argvs) print(argc, opt) display, start_display, add_menu, add_function_to_menu = init_display() display.DisplayShape(gp_Pnt()) pnt_3d = Graphic3d_ArrayOfPoints(100) for idx in range(100): x = random.uniform(-0.5, 0.5) y = random.uniform(-0.5, 0.5) z = random.uniform(-0.5, 0.5) r = np.sqrt(x**2 + y**2 + z**2) ratio = random.uniform(0, 100) pnt_3d.AddVertex(x / r * ratio, y / r * ratio, z / r * ratio) point_cloud = AIS_PointCloud() point_cloud.SetPoints(pnt_3d) #display.DisplayShape(point_cloud.GetBoundingBox()) display.FitAll() start_display()