def quad_topomesh(quads, positions, faces_as_cells=False, **kwargs):
quads = np.array(quads)
positions = array_dict(positions)
edges = array_unique(np.sort(np.concatenate(quads[:,quad_edge_list],axis=0)))
quad_edges = np.sort(np.concatenate(quads[:,quad_edge_list]))
start_time = time()
print "--> Generating quad topomesh"
quad_edge_matching = vq(quad_edges,edges)[0]
quad_topomesh = PropertyTopomesh(3)
for c in np.unique(quads):
quad_topomesh.add_wisp(0,c)
for e in edges:
eid = quad_topomesh.add_wisp(1)
for pid in e:
quad_topomesh.link(1,eid,pid)
for q in quads:
fid = quad_topomesh.add_wisp(2)
for eid in quad_edge_matching[4*fid:4*fid+4]:
quad_topomesh.link(2,fid,eid)
if not faces_as_cells:
quad_topomesh.add_wisp(3,0)
for fid in quad_topomesh.wisps(2):
quad_topomesh.link(3,0,fid)
else:
for fid in quad_topomesh.wisps(2):
quad_topomesh.add_wisp(3,fid)
quad_topomesh.link(3,fid,fid)
quad_topomesh.update_wisp_property('barycenter',0,positions.values(np.unique(quads)),keys=np.unique(quads))
end_time = time()
print "<-- Generating quad topomesh [",end_time-start_time,"s]"
return quad_topomesh
property_topomesh_creation.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录