def process(self): if not any(output.is_linked for output in self.outputs): return InVert, InEdge, InEdSel = self.inputs OutVert, OutEdg, OutFace, ONVert, ONEdg, ONFace, OOVert, OOEdg, OOFace = self.outputs vertices_s = InVert.sv_get() topo = InEdge.sv_get() if len(topo[0][0]) == 2: bmlist= [bmesh_from_pydata(v, e, [], normal_update=True) for v,e in zip(vertices_s,topo)] else: bmlist= [bmesh_from_pydata(v, [], e, normal_update=True) for v,e in zip(vertices_s,topo)] rev, ree, ref, riv, rie, rif, rsv, rse, rsf = [],[],[],[],[],[],[],[],[] if InEdSel.is_linked: if self.sel_mode == "index": useedges = [np.array(bm.edges[:])[idxs] for bm, idxs in zip(bmlist, InEdSel.sv_get())] elif self.sel_mode == "mask": useedges = [np.extract(mask, bm.edges[:]) for bm, mask in zip(bmlist, InEdSel.sv_get())] else: useedges = [bm.edges for bm in bmlist] for bm,ind in zip(bmlist,useedges): geom = subdivide_edges(bm, edges=ind, smooth=self.smooth, smooth_falloff=int(self.falloff_type), fractal=self.fractal, along_normal=self.along_normal, cuts=self.cuts, seed=self.seed, quad_corner_type=int(self.corner_type), use_grid_fill=self.grid_fill, use_single_edge=self.single_edge, use_only_quads=self.only_quads, use_smooth_even=self.smooth_even) new_verts, new_edges, new_faces = pydata_from_bmesh(bm) rev.append(new_verts) ree.append(new_edges) ref.append(new_faces) if self.show_new: geo1 = geom['geom_inner'] riv.append([tuple(v.co) for v in geo1 if isinstance(v, bmesh.types.BMVert)]) rie.append([[v.index for v in e.verts] for e in geo1 if isinstance(e, bmesh.types.BMEdge)]) rif.append([[v.index for v in f.verts] for f in geo1 if isinstance(f, bmesh.types.BMFace)]) if self.show_old: geo2 = geom['geom_split'] rsv.append([tuple(v.co) for v in geo2 if isinstance(v, bmesh.types.BMVert)]) rse.append([[v.index for v in e.verts] for e in geo2 if isinstance(e, bmesh.types.BMEdge)]) rsf.append([[v.index for v in f.verts] for f in geo2 if isinstance(f, bmesh.types.BMFace)]) bm.free() OutVert.sv_set(rev) OutEdg.sv_set(ree) OutFace.sv_set(ref) ONVert.sv_set(riv) ONEdg.sv_set(rie) ONFace.sv_set(rif) OOVert.sv_set(rsv) OOEdg.sv_set(rse) OOFace.sv_set(rsf)
def process(self): inputs, outputs = self.inputs, self.outputs if self.dont_process(): return result_vertices, result_edges, result_faces, result_face_data = [], [], [], [] r_inner_vertices, r_inner_edges, r_inner_faces = [], [], [] r_split_vertices, r_split_edges, r_split_faces = [], [], [] use_mask = inputs['EdgeMask'].is_linked show_new = self.show_new and any(s.is_linked for s in outputs[4:7]) show_old = self.show_old and any(s.is_linked for s in outputs[7:]) use_face_data = inputs['FaceData'].is_linked and outputs['FaceData'].is_linked output_numpy = any(self.out_np) meshes = self.get_data() for vertices, edges, faces, face_data, masks, cuts, smooth, fractal, along_normal, seed in zip(*meshes): if cuts < 1: result_vertices.append(vertices) result_edges.append(edges) result_faces.append(faces) result_face_data.append(face_data) r_inner_vertices.append(vertices) r_inner_edges.append(edges) r_inner_faces.append(faces) r_split_vertices.append(vertices) r_split_edges.append(edges) r_split_faces.append(faces) continue if use_face_data and len(face_data) > 0: if isinstance(face_data, ndarray): face_data_matched = numpy_full_list(face_data, len(faces)).tolist() else: face_data_matched = repeat_last_for_length(face_data, len(faces)) else: face_data_matched =[] bm = bmesh_from_pydata( vertices, edges, faces, markup_face_data=use_face_data, markup_edge_data=use_mask, normal_update=True) selected_edges = get_selected_edges(use_mask, masks, bm.edges) geom = subdivide_edges( bm, edges=selected_edges, smooth=smooth, smooth_falloff=self.falloff_type, fractal=fractal, along_normal=along_normal, cuts=cuts, seed=seed, quad_corner_type=self.corner_type, use_grid_fill=self.grid_fill, use_single_edge=self.single_edge, use_only_quads=self.only_quads, use_smooth_even=self.smooth_even) if output_numpy: new_verts, new_edges, new_faces, new_face_data = numpy_data_from_bmesh(bm, self.out_np, face_data_matched) else: if use_face_data and len(face_data) > 0: new_verts, new_edges, new_faces, new_face_data = pydata_from_bmesh(bm, face_data_matched) else: new_verts, new_edges, new_faces = pydata_from_bmesh(bm) new_face_data = [] result_vertices.append(new_verts) result_edges.append(new_edges) result_faces.append(new_faces) result_face_data.append(new_face_data) if show_new: inner_verts, inner_edges, inner_faces = get_partial_result_pydata(geom['geom_inner']) r_inner_vertices.append(inner_verts) r_inner_edges.append(inner_edges) r_inner_faces.append(inner_faces) if show_old: split_verts, split_edges, split_faces = get_partial_result_pydata(geom['geom_split']) r_split_vertices.append(split_verts) r_split_edges.append(split_edges) r_split_faces.append(split_faces) bm.free() outputs['Vertices'].sv_set(result_vertices) outputs['Edges'].sv_set(result_edges) outputs['Faces'].sv_set(result_faces) outputs['FaceData'].sv_set(result_face_data) outputs['NewVertices'].sv_set(r_inner_vertices) outputs['NewEdges'].sv_set(r_inner_edges) outputs['NewFaces'].sv_set(r_inner_faces) outputs['OldVertices'].sv_set(r_split_vertices) outputs['OldEdges'].sv_set(r_split_edges) outputs['OldFaces'].sv_set(r_split_faces)