Ejemplo n.º 1
0
def add_net_work(nodes,
                 edges,
                 name="my_net_work",
                 color=(0.89, 0.69, 0.1),
                 radius=0.00200):
    edges = edges - np.ones(edges.shape)  #obj文件坐标索引从1开始,polyscope要求从0开始
    my_net_work = ps.register_curve_network(name, nodes, edges)
    my_net_work.set_color(color)
    my_net_work.set_radius(radius)
    return my_net_work
Ejemplo n.º 2
0
def show_skeleton_in_obj_file(obj_file):
    ps.init()
    vertex_pos = []
    line_indices = []
    with open(obj_file) as f_in:
        for line in f_in:
            temp = line.split(' ')
            if temp[0] == 'v':
                vertex_pos.append(np.array([float(temp[1]), float(temp[2]), float(temp[3])]))
            if temp[0] == 'l':
                line_indices.append(np.array([int(temp[1]) - 1, int(temp[2]) - 1]))
    points = np.array(vertex_pos)
    edges = np.array(line_indices)
    skeleton = ps.register_curve_network("skeleton curve", points, edges)
    point_cloud = ps.register_point_cloud("point cloud", points)
    skeleton.set_radius(0.001)
    point_cloud.set_radius(0.005)
    point_cloud.set_color((1,0,0))
    ps.set_autoscale_structures(True)
    ps.show()