예제 #1
0
def save_load_ply_file(path,points, in_side_px,load_ply = False):
    
    TEST_DIR = path.joinpath('test')
    grid = str(TEST_DIR.joinpath('grid.ply'))
    ply_file = open(grid,'w')
    ply_file.write("ply\n")
    ply_file.write("format ascii 1.0\n")
    ply_file.write("element vertex %d\n"%(points.shape[0]))
    ply_file.write("property float x\n")
    ply_file.write("property float y\n")
    ply_file.write("property float z\n")
    ply_file.write("property float nx\n")
    ply_file.write("property float ny\n")
    ply_file.write("property float nz\n")
    ply_file.write("property uchar red\n")
    ply_file.write("property uchar green\n")
    ply_file.write("property uchar blue\n")
    ply_file.write("end_header\n")

    for i in range(points.shape[0]):
        if in_side_px[i] == True:
            ply_file.write("%f %f %f %f %f %f %d %d %d\n"%(points[i,0],points[i,1],points[i,2],0,0,0,0,0,0))
        else:
            ply_file.write("%f %f %f %f %f %f %d %d %d\n"%(points[i,0],points[i,1],points[i,2],0,0,0,255,0,0))

    ply_file.close()
    if load_ply:
        import_ply.load_ply(grid)
예제 #2
0
 def execute(self, context):
     import_ply.load_ply(
         self.filepath)  # we could use load poly mesh instead
     ob = context.scene.objects.active  # active object
     # cleanups
     bpy.ops.object.editmode_toggle()
     bpy.ops.mesh.remove_doubles()
     bpy.ops.mesh.normals_make_consistent()
     bpy.ops.object.editmode_toggle()
     # assign a material
     mat = ob.active_material = bpy.data.materials.new("UAVs_hull")
     mat.alpha = 0.1
     mat.game_settings.alpha_blend = "ALPHA"
     ob.show_transparent = True
     return {'FINISHED'}
예제 #3
0
def load_cropped():
    filepath = bpy.data.filepath
    blend_directory = filepath[0: filepath.rfind('\\')]
    upper_jaw_file = os.path.join(blend_directory, "upper_cropped.ply")
    import_ply.load_ply(upper_jaw_file)
예제 #4
0
def load_jaw_from_ply(filename):
    filepath = bpy.data.filepath
    root_dir = filepath[0: filepath.find('visualization') - 1]
    filepath = os.path.join(root_dir, 'data', filename)
    import_ply.load_ply(filepath)