本文整理匯總了Python中pymesh.save_mesh方法的典型用法代碼示例。如果您正苦於以下問題:Python pymesh.save_mesh方法的具體用法?Python pymesh.save_mesh怎麽用?Python pymesh.save_mesh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pymesh
的用法示例。
在下文中一共展示了pymesh.save_mesh方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: isolate_files
# 需要導入模塊: import pymesh [as 別名]
# 或者: from pymesh import save_mesh [as 別名]
def isolate_files():
"""
Utility fonction to generate the metro_file archive. Useless to all users but the author.
"""
with open('./dataset/data/metro_files/files-metro.txt', 'r') as file:
files = file.read().split('\n')
for file in files:
if file[-3:] == "ply":
cat = file.split('/')[0]
name = file.split('/')[1][:-4]
path_points = '/'.join(['.', 'dataset', 'data', 'ShapeNetV1PointCloud', cat, name + '.points.ply.npy'])
path_png = '/'.join(['.', 'dataset', 'data', 'ShapeNetV1Renderings', cat, name, "rendering", '00.png'])
path_obj = '/'.join(['', 'home', 'thibault', 'hdd', 'data', 'ShapeNetCore.v1', cat, name, 'model.obj'])
mesh = pymesh.load_mesh(path_obj)
points = np.load((path_points))
if not exists('/'.join(['.', 'dataset', 'data', 'metro_files', cat])):
os.mkdir('/'.join(['.', 'dataset', 'data', 'metro_files', cat]))
pymesh.save_mesh('/'.join(['.', 'dataset', 'data', 'metro_files', cat, name + '.ply']), mesh, ascii=True)
np.save('/'.join(['.', 'dataset', 'data', 'metro_files', cat, name + '.npy']), points)
copy(path_png, '/'.join(['.', 'dataset', 'data', 'metro_files', cat, name + '.png']))
示例2: shuffle_pc
# 需要導入模塊: import pymesh [as 別名]
# 或者: from pymesh import save_mesh [as 別名]
def shuffle_pc(file, output_path):
"""
Function to shuffle a point cloud produced by virtual scanner.
"""
mesh = pymesh.load_mesh(file)
vertices = copy.deepcopy(mesh.vertices)
permutation = np.random.permutation(len(vertices))
vertices = vertices[permutation]
new_mesh = pymesh.meshio.form_mesh(vertices, mesh.faces)
new_mesh.add_attribute("vertex_nx")
new_mesh.set_attribute("vertex_nx", mesh.get_vertex_attribute("vertex_nx")[permutation])
new_mesh.add_attribute("vertex_ny")
new_mesh.set_attribute("vertex_ny", mesh.get_vertex_attribute("vertex_ny")[permutation])
new_mesh.add_attribute("vertex_nz")
new_mesh.set_attribute("vertex_nz", mesh.get_vertex_attribute("vertex_nz")[permutation])
pymesh.save_mesh(output_path, new_mesh, ascii=True, anonymous=True, use_float=True, *new_mesh.get_attribute_names())
示例3: downsample_pointcloud
# 需要導入模塊: import pymesh [as 別名]
# 或者: from pymesh import save_mesh [as 別名]
def downsample_pointcloud(pc_path, point_num):
mesh_raw = pymesh.load_mesh(pc_path)
points_raw = mesh_raw.vertices
if points_raw.shape[0] > point_num:
point_subset = np.random.choice(points_raw.shape[0], point_num, replace=False)
points = points_raw[point_subset]
else:
points = points_raw
mesh = pymesh.form_mesh(points, np.ones((0, 3)))
pymesh.save_mesh(join(dirname(pc_path), 'compressed.ply'), mesh)
示例4: output_patch_coords
# 需要導入模塊: import pymesh [as 別名]
# 或者: from pymesh import save_mesh [as 別名]
def output_patch_coords(subv, subf, subn, i, neigh_i, theta, rho):
"""
For debugging purposes, save a patch to visualize it.
"""
mesh = pymesh.form_mesh(subv, subf)
n1 = subn[:,0]
n2 = subn[:,1]
n3 = subn[:,2]
mesh.add_attribute('vertex_nx')
mesh.set_attribute('vertex_nx', n1)
mesh.add_attribute('vertex_ny')
mesh.set_attribute('vertex_ny', n2)
mesh.add_attribute('vertex_nz')
mesh.set_attribute('vertex_nz', n3)
rho = np.array([rho[0,ix] for ix in range(rho.shape[1]) if ix in neigh_i])
mesh.add_attribute('rho')
mesh.set_attribute('rho', rho)
theta= np.array([theta[ix] for ix in range((theta.shape[0])) if ix in neigh_i])
mesh.add_attribute('theta')
mesh.set_attribute('theta', theta)
charge = np.zeros(len(neigh_i))
mesh.add_attribute('charge')
mesh.set_attribute('charge', charge)
pymesh.save_mesh('v{}.ply'.format(i), mesh, *mesh.get_attribute_names(), use_float=True, ascii=True)
#@jit
示例5: save
# 需要導入模塊: import pymesh [as 別名]
# 或者: from pymesh import save_mesh [as 別名]
def save(mesh, path, colormap):
try:
vertex_sources = mesh.get_attribute("vertex_sources") # batch, nb_prim, num_point, 3
if vertex_sources.max() > 0:
vertex_sources = (255 * (vertex_sources / vertex_sources.max())).astype('int')
mesh.add_attribute("vertex_red")
mesh.add_attribute("vertex_green")
mesh.add_attribute("vertex_blue")
mesh.set_attribute("vertex_red", colormap.colormap[vertex_sources][:, 0])
mesh.set_attribute("vertex_green", colormap.colormap[vertex_sources][:, 1])
mesh.set_attribute("vertex_blue", colormap.colormap[vertex_sources][:, 2])
except:
pass
pymesh.save_mesh(path[:-3] + "ply", mesh, *mesh.get_attribute_names(), ascii=True)
示例6: shuffle_pc
# 需要導入模塊: import pymesh [as 別名]
# 或者: from pymesh import save_mesh [as 別名]
def shuffle_pc(file, output_path):
mesh = pymesh.load_mesh(file)
vertices = copy.deepcopy(mesh.vertices)
permutation = np.random.permutation(len(vertices))
vertices = vertices[permutation]
new_mesh = pymesh.meshio.form_mesh(vertices, mesh.faces)
new_mesh.add_attribute("vertex_nx")
new_mesh.set_attribute("vertex_nx", mesh.get_vertex_attribute("vertex_nx")[permutation])
new_mesh.add_attribute("vertex_ny")
new_mesh.set_attribute("vertex_ny", mesh.get_vertex_attribute("vertex_ny")[permutation])
new_mesh.add_attribute("vertex_nz")
new_mesh.set_attribute("vertex_nz", mesh.get_vertex_attribute("vertex_nz")[permutation])
pymesh.save_mesh(output_path, new_mesh, ascii=True, anonymous=True, use_float=True, *new_mesh.get_attribute_names())
示例7: remesh_and_save
# 需要導入模塊: import pymesh [as 別名]
# 或者: from pymesh import save_mesh [as 別名]
def remesh_and_save(input_path, output_path):
try:
obj = remesh(input_path)
pymesh.save_mesh(output_path, obj, )
except Exception as e:
return ("", str(e))
else:
return ("","")
示例8: save_ply
# 需要導入模塊: import pymesh [as 別名]
# 或者: from pymesh import save_mesh [as 別名]
def save_ply(
filename,
vertices,
faces=[],
normals=None,
charges=None,
vertex_cb=None,
hbond=None,
hphob=None,
iface=None,
normalize_charges=False,
):
""" Save vertices, mesh in ply format.
vertices: coordinates of vertices
faces: mesh
"""
mesh = pymesh.form_mesh(vertices, faces)
if normals is not None:
n1 = normals[:, 0]
n2 = normals[:, 1]
n3 = normals[:, 2]
mesh.add_attribute("vertex_nx")
mesh.set_attribute("vertex_nx", n1)
mesh.add_attribute("vertex_ny")
mesh.set_attribute("vertex_ny", n2)
mesh.add_attribute("vertex_nz")
mesh.set_attribute("vertex_nz", n3)
if charges is not None:
mesh.add_attribute("charge")
if normalize_charges:
charges = charges / 10
mesh.set_attribute("charge", charges)
if hbond is not None:
mesh.add_attribute("hbond")
mesh.set_attribute("hbond", hbond)
if vertex_cb is not None:
mesh.add_attribute("vertex_cb")
mesh.set_attribute("vertex_cb", vertex_cb)
if hphob is not None:
mesh.add_attribute("vertex_hphob")
mesh.set_attribute("vertex_hphob", hphob)
if iface is not None:
mesh.add_attribute("vertex_iface")
mesh.set_attribute("vertex_iface", iface)
pymesh.save_mesh(
filename, mesh, *mesh.get_attribute_names(), use_float=True, ascii=True
)