当前位置: 首页>>代码示例>>Python>>正文


Python sv_bmesh_utils.bmesh_from_pydata函数代码示例

本文整理汇总了Python中sverchok.utils.sv_bmesh_utils.bmesh_from_pydata函数的典型用法代码示例。如果您正苦于以下问题:Python bmesh_from_pydata函数的具体用法?Python bmesh_from_pydata怎么用?Python bmesh_from_pydata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bmesh_from_pydata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

 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)
开发者ID:nortikin,项目名称:sverchok,代码行数:54,代码来源:subdivide_lite.py

示例2: storage_set_data

    def storage_set_data(self, storage):
        geom = storage['geom']
        name = storage['params']["obj_name"]
        geom_dict = json.loads(geom)

        if not geom_dict:
            print(self.name, 'contains no flatten geom')
            return

        unrolled_geom = unflatten(geom_dict)
        verts = unrolled_geom['Vertices']
        edges = unrolled_geom['Edges']
        polygons = unrolled_geom['Polygons']
        matrix = unrolled_geom['Matrix']

        bm = bmesh_from_pydata(verts, edges, polygons)
        obj = generate_object(name, bm)
        obj.matrix_world = matrix

        # rename if obj existed
        if not obj.name == name:
            storage['params']["obj_name"] = obj.name
            self.id_data.freeze(hard=True)
            self.obj_name = obj.name
            self.id_data.unfreeze(hard=True)
开发者ID:elfnor,项目名称:sverchok,代码行数:25,代码来源:objects_in_lite.py

示例3: make_bmesh_geometry

def make_bmesh_geometry(node, context, geometry, idx, layers):
    scene = context.scene
    meshes = bpy.data.meshes
    objects = bpy.data.objects
    verts, edges, matrix, _, _ = geometry
    name = node.basemesh_name + '.' + str("%04d" % idx)

    # remove object
    if name in objects:
        obj = objects[name]
        # assign the object an empty mesh, this allows the current mesh
        # to be uncoupled and removed from bpy.data.meshes
        obj.data = assign_empty_mesh(idx)

        # remove uncoupled mesh, and add it straight back.
        if name in meshes:
            meshes.remove(meshes[name])
        mesh = meshes.new(name)
        obj.data = mesh
    else:
        # this is only executed once, upon the first run.
        mesh = meshes.new(name)
        obj = objects.new(name, mesh)
        scene.objects.link(obj)

    # at this point the mesh is always fresh and empty
    obj['idx'] = idx
    obj['basename'] = node.basemesh_name

    data_layers = None
    if node.distance_doubles > 0.0:
        bm = bmesh_from_pydata(verts, edges, [])
        verts, edges, faces, d1, d2 = shrink_geometry(bm, node.distance_doubles, layers)
        data_layers = d1, d2

    force_pydata(obj.data, verts, edges)
    obj.update_tag(refresh={'OBJECT', 'DATA'})

    if node.live_updates:

        if 'sv_skin' in obj.modifiers:
            sk = obj.modifiers['sv_skin']
            obj.modifiers.remove(sk)

        if 'sv_subsurf' in obj.modifiers:
            sd = obj.modifiers['sv_subsurf']
            obj.modifiers.remove(sd)

        _ = obj.modifiers.new(type='SKIN', name='sv_skin')
        b = obj.modifiers.new(type='SUBSURF', name='sv_subsurf')
        b.levels = node.levels
        b.render_levels = node.render_levels

    if matrix:
        matrix = matrix_sanitizer(matrix)
        obj.matrix_local = matrix
    else:
        obj.matrix_local = Matrix.Identity(4)

    return obj, data_layers
开发者ID:elfnor,项目名称:sverchok,代码行数:60,代码来源:viewer_skin_mk1.py

示例4: remove_doubles_from_edgenet

def remove_doubles_from_edgenet(verts_in, edges_in, distance):
    bm = bmesh_from_pydata(verts_in, edges_in, [])
    bmesh.ops.remove_doubles(bm, verts=bm.verts[:], dist=distance)
    verts_out = [v.co.to_tuple() for v in bm.verts]
    edges_out = [[j.index for j in i.verts] for i in bm.edges]

    return verts_out, edges_out
开发者ID:nortikin,项目名称:sverchok,代码行数:7,代码来源:edges_intersect_mk2.py

示例5: intersect_edges_3d

def intersect_edges_3d(verts_in, edges_in, s_epsilon):

    bm = bmesh_from_pydata(verts_in, edges_in, [])

    edge_indices = [e.index for e in bm.edges]
    trim_indices = len(edge_indices)
    for edge in bm.edges:
        edge.select = True

    cm = CAD_ops(epsilon=s_epsilon)

    d = get_intersection_dictionary(cm, bm, edge_indices)
    unselect_nonintersecting(bm, d.keys(), edge_indices)

    # store non_intersecting edge sequencer
    add_back = [[i.index for i in edge.verts] for edge in bm.edges if not edge.select]

    update_mesh(bm, d)
    verts_out = [v.co.to_tuple() for v in bm.verts]
    edges_out = [[j.index for j in i.verts] for i in bm.edges]

    # optional correction, remove originals, add back those that are not intersecting.
    edges_out = edges_out[trim_indices:]
    edges_out.extend(add_back)
    bm.free()

    return verts_out, edges_out
开发者ID:nortikin,项目名称:sverchok,代码行数:27,代码来源:edges_intersect_mk2.py

示例6: fillet

def fillet(verts, edges, adj, num_seg):
    bm = bmesh_from_pydata(verts[0], edges[0], [])
    this_fillet = fillet_op0(bm, adj, num_seg)

    verts_out = [v.co[:] for v in bm.verts]
    edges_out = [[i.index for i in p.verts] for p in bm.edges[:]]
    return verts_out, edges_out
开发者ID:BitByte01,项目名称:myblendercontrib,代码行数:7,代码来源:tone_fillet.py

示例7: process

 def process(self):
     BML, Verts, Edges, Polys, vermask, edgmask, angllim = self.inputs
     o1,o2,o3,o4,o5 = self.outputs
     angle = angllim.sv_get()[0]
     ret = []
     bmlist = BML.sv_get([])
     if Verts.is_linked:
         bmlist.extend([bmesh_from_pydata(verts, edges, faces, normal_update=True) for verts, edges, faces in zip(*mlr([Verts.sv_get(), Edges.sv_get([[]]), Polys.sv_get([[]])]))])
     if vermask.is_linked:
         verm = [np.array(bm.verts[:])[ma] for bm,ma in zip(bmlist,vermask.sv_get())]
     else:
         verm = [bm.verts for bm in bmlist]
     if edgmask.is_linked:
         edgm = [np.array(bm.edges[:])[ma] for bm,ma in zip(bmlist,edgmask.sv_get())]
     else:
         edgm = [bm.edges for bm in bmlist]
     udb, dlm = self.use_dissolve_boundaries, self.delimit
     for bm, ang, vm, em in zip(bmlist, safc(bmlist, angle), verm, edgm):
         # it's a little undocumented..
         ret.append(dissolve_limit(bm, angle_limit=ang, use_dissolve_boundaries=udb, verts=vm, edges=em, delimit=dlm)['region'])
     if o1.is_linked:
         o1.sv_set([[v.co[:] for v in bm.verts]for bm in bmlist])
     if o2.is_linked:
         o2.sv_set([[[i.index for i in e.verts] for e in bm.edges]for bm in bmlist])
     if o3.is_linked:
         o3.sv_set([[[i.index for i in p.verts] for p in bm.faces]for bm in bmlist])
     if o4.is_linked:
         o4.sv_set(ret)
     if o5.is_linked:
         o5.sv_set(bmlist)
开发者ID:nortikin,项目名称:sverchok,代码行数:30,代码来源:limited_dissolve_mk2.py

示例8: process

    def process(self):

        if not (self.outputs['Vers'].is_linked and self.inputs['Vers'].is_linked):
            return

        vertices = Vector_generate(self.inputs['Vers'].sv_get())
        faces = self.inputs['Pols'].sv_get()
        offset = self.inputs['Offset'].sv_get()[0]
        nsides = self.inputs['N sides'].sv_get()[0][0]
        radius = self.inputs['Radius'].sv_get()[0]

        outv = []
        oute = []
        outo = []
        outn = []

        # for each object
        for verts_obj, faces_obj in zip(vertices, faces):
            fullList(offset, len(faces_obj))
            fullList(radius, len(faces_obj))
            verlen = set(range(len(verts_obj)))

            bm = bmesh_from_pydata(verts_obj, [], faces_obj, normal_update=True)
            result = self.Offset_pols(bm, offset, radius, nsides, verlen)
            outv.append(result[0])
            oute.append(result[1])
            outo.append(result[2])
            outn.append(result[3])

        self.outputs['Vers'].sv_set(outv)
        self.outputs['Edgs'].sv_set(oute)
        self.outputs['OutPols'].sv_set(outo)
        self.outputs['InPols'].sv_set(outn)
开发者ID:elfnor,项目名称:sverchok,代码行数:33,代码来源:offset.py

示例9: process

    def process(self):

        if not (self.inputs[0].is_linked and self.inputs[2].is_linked):
            return
        if not any(self.outputs[name].is_linked for name in ['Vertices', 'Edges', 'Polygons', 'NewPolys']):
            return

        out, result_bevel_faces = [], []

        meshes = match_long_repeat(self.get_socket_data())
        for vertices, edges, faces, bevel_edges, offset, segments, profile in zip(*meshes):
            bm = bmesh_from_pydata(vertices, edges, faces)
            b_edges = get_bevel_edges(bm, bevel_edges)

            geom = list(bm.verts) + list(b_edges) + list(bm.faces)
            bevel_faces = bmesh.ops.bevel(
                bm, geom=geom, offset=offset,
                offset_type=int(self.offsetType), segments=segments,
                profile=profile, vertex_only=self.vertexOnly, material=-1)['faces']

            new_bevel_faces = [[v.index for v in face.verts] for face in bevel_faces]
            out.append(pydata_from_bmesh(bm))
            bm.free()
            result_bevel_faces.append(new_bevel_faces)

        Vertices, Edges, Polygons, NewPolygons = self.outputs
        Vertices.sv_set([i[0] for i in out])
        Edges.sv_set([i[1] for i in out])
        Polygons.sv_set([i[2] for i in out])
        NewPolygons.sv_set(result_bevel_faces)
开发者ID:johnyc90,项目名称:sverchok,代码行数:30,代码来源:bevel.py

示例10: modal

    def modal(self, context, event):
        context.area.tag_redraw()
        scn = context.scene

        if event.type in {'MIDDLEMOUSE'}:
            return {'RUNNING_MODAL'}

        if event.type in {'RIGHTMOUSE', 'ESC'}:
            bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
            return {'CANCELLED'}

        if event.type in {'RET'}:
            bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
            bpy.ops.object.mode_set(mode='OBJECT')
            bpy.ops.object.modifier_apply(apply_as='DATA', modifier="sv_bool")
            context.active_object.show_wire = False
            context.active_object.show_all_edges = False
            bpy.ops.object.mode_set(mode='EDIT')
            return {'FINISHED'}

        scalar = scn.BGL_OFFSET_SCALAR
        VB, PB = generate_boolean_geom(self.verts, self.normal, scalar)

        bm = bmesh_from_pydata(VB, [], PB)
        n_obj = new_obj(bm, "ExtractObject", "Extract_mesh")
        n_obj.hide = True

        obj = bpy.context.active_object
        attache_boolean_modifier(obj, n_obj)

        return {'PASS_THROUGH'}
开发者ID:zeffii,项目名称:BlenderBooleanPush,代码行数:31,代码来源:tentative_carve_script.py

示例11: process

    def process(self):

        # bmesh operations
        verts = self.inputs['verts'].sv_get()
        faces = self.inputs['faces'].sv_get()
        face_masks = self.inputs['face_masks'].sv_get()
        out_verts, out_faces = [], []

        for _verts, _faces, _face_mask in zip(verts, faces, face_masks):

            bm = bmesh_from_pydata(_verts, [], _faces, normal_update=True)

            sel = []
            add_sell = sel.append
            for f in (f for f in bm.faces if f.index in set(_face_mask)):
                f.select = True
                add_sell(f)

            generated_data = perform_mextrude(self, bm, sel)
            if generated_data:
                outv, outf = generated_data
                out_verts.append(outv)
                out_faces.append(outf)

        self.outputs['verts'].sv_set(out_verts)
        self.outputs['faces'].sv_set(out_faces)
开发者ID:johnyc90,项目名称:sverchok,代码行数:26,代码来源:extrude_multi_alt.py

示例12: process

    def process(self):
        inputs = self.inputs
        outputs = self.outputs

        try:
            verts_in = inputs['Verts_in'].sv_get(deepcopy=False)[0]
            edges_in = inputs['Edges_in'].sv_get(deepcopy=False)[0]
            linked = outputs['Verts_out'].is_linked
        except (IndexError, KeyError) as e:
            return

        bm = bmesh_from_pydata(verts_in, edges_in, [])

        edge_indices = [e.index for e in bm.edges]
        trim_indices = len(edge_indices)
        for edge in bm.edges:
            edge.select = True

        cm = CAD_ops(epsilon=self.epsilon)

        d = get_intersection_dictionary(cm, bm, edge_indices)
        unselect_nonintersecting(bm, d.keys(), edge_indices)

        # store non_intersecting edge sequencer
        add_back = [[i.index for i in edge.verts] for edge in bm.edges if not edge.select]

        update_mesh(bm, d)
        verts_out = [v.co.to_tuple() for v in bm.verts]
        edges_out = [[j.index for j in i.verts] for i in bm.edges]

        # optional correction, remove originals, add back those that are not intersecting.
        edges_out = edges_out[trim_indices:]
        edges_out.extend(add_back)
        bm.free()

        # post processing step to remove doubles
        if self.rm_switch:
            bm = bmesh_from_pydata(verts_out, edges=edges_out)
            bmesh.ops.remove_doubles(bm, verts=bm.verts[:], dist=self.rm_doubles)
            verts_out = [v.co.to_tuple() for v in bm.verts]
            edges_out = [[j.index for j in i.verts] for i in bm.edges]

        outputs['Verts_out'].sv_set([verts_out])
        outputs['Edges_out'].sv_set([edges_out])
开发者ID:elfnor,项目名称:sverchok,代码行数:44,代码来源:edges_intersect_mk2.py

示例13: process

    def process(self):
        if not (self.inputs['Vertices'].is_linked and self.inputs['Polygons'].is_linked):
            return
        if not (any(self.outputs[name].is_linked for name in ['Vertices', 'Edges', 'Polygons', 'NewEdges', 'NewPolys'])):
            return

        vertices_s = self.inputs['Vertices'].sv_get(default=[[]])
        edges_s = self.inputs['Edges'].sv_get(default=[[]])
        faces_s = self.inputs['Polygons'].sv_get(default=[[]])
        mask_s = self.inputs['Mask'].sv_get(default=[[True]])

        result_vertices = []
        result_edges = []
        result_faces = []
        result_new_edges = []
        result_new_faces = []

        meshes = match_long_repeat([vertices_s, edges_s, faces_s, mask_s])

        for vertices, edges, faces, mask in zip(*meshes):

            bm = bmesh_from_pydata(vertices, edges, faces)
            fullList(mask, len(faces))

            b_faces = []
            for m, face in zip(mask, bm.faces):
                if m:
                    b_faces.append(face)

            res = bmesh.ops.triangulate(
                bm, faces=b_faces,
                quad_method=int(self.quad_mode),
                ngon_method=int(self.ngon_mode))

            b_new_edges = [tuple(v.index for v in edge.verts) for edge in res['edges']]
            b_new_faces = [[v.index for v in face.verts] for face in res['faces']]

            new_vertices, new_edges, new_faces = pydata_from_bmesh(bm)
            bm.free()

            result_vertices.append(new_vertices)
            result_edges.append(new_edges)
            result_faces.append(new_faces)
            result_new_edges.append(b_new_edges)
            result_new_faces.append(b_new_faces)

        if self.outputs['Vertices'].is_linked:
            self.outputs['Vertices'].sv_set(result_vertices)
        if self.outputs['Edges'].is_linked:
            self.outputs['Edges'].sv_set(result_edges)
        if self.outputs['Polygons'].is_linked:
            self.outputs['Polygons'].sv_set(result_faces)
        if self.outputs['NewEdges'].is_linked:
            self.outputs['NewEdges'].sv_set(result_new_edges)
        if self.outputs['NewPolys'].is_linked:
            self.outputs['NewPolys'].sv_set(result_new_faces)
开发者ID:TakamitsuNobe,项目名称:myblendercontrib,代码行数:56,代码来源:triangulate.py

示例14: calc_mesh_normals

def calc_mesh_normals(vertices, edges, faces):
    bm = bmesh_from_pydata(vertices, edges, faces, normal_update=True)
    vertex_normals = []
    face_normals = []
    for vertex in bm.verts:
        vertex_normals.append(tuple(vertex.normal))
    for face in bm.faces:
        face_normals.append(tuple(face.normal))
    bm.free()
    return vertex_normals, face_normals
开发者ID:johnyc90,项目名称:sverchok,代码行数:10,代码来源:normals.py

示例15: process

    def process(self):
        if not (self.inputs['Vertices'].is_linked and self.inputs['Polygons'].is_linked):
            return
        if not (any(self.outputs[name].is_linked for name in ['Vertices', 'Edges', 'Polygons', 'NewPolys'])):
            return

        vertices_s = self.inputs['Vertices'].sv_get(default=[[]])
        edges_s = self.inputs['Edges'].sv_get(default=[[]])
        faces_s = self.inputs['Polygons'].sv_get(default=[[]])
        offsets_s = self.inputs['Offset'].sv_get()[0]
        segments_s = self.inputs['Segments'].sv_get()[0]
        profiles_s = self.inputs['Profile'].sv_get()[0]
        bevel_edges_s = self.inputs['BevelEdges'].sv_get(default=[[]])

        result_vertices = []
        result_edges = []
        result_faces = []
        result_bevel_faces = []

        meshes = match_long_repeat([vertices_s, edges_s, faces_s, bevel_edges_s, offsets_s, segments_s, profiles_s])

        for vertices, edges, faces, bevel_edges, offset, segments, profile in zip(*meshes):

            bm = bmesh_from_pydata(vertices, edges, faces)

            if bevel_edges:
                b_edges = []
                for edge in bevel_edges:
                    b_edge = [e for e in bm.edges if set([v.index for v in e.verts]) == set(edge)]
                    b_edges.append(b_edge[0])
            else:
                b_edges = bm.edges

            geom = list(bm.verts) + list(b_edges) + list(bm.faces)
            bevel_faces = bmesh.ops.bevel(bm, geom=geom, offset=offset,
                            offset_type=int(self.offsetType), segments=segments,
                            profile=profile, vertex_only=self.vertexOnly,
                            #clamp_overlap=self.clampOverlap,
                            material=-1)['faces']
            new_bevel_faces = [[v.index for v in face.verts] for face in bevel_faces]
            new_vertices, new_edges, new_faces = pydata_from_bmesh(bm)
            bm.free()

            result_vertices.append(new_vertices)
            result_edges.append(new_edges)
            result_faces.append(new_faces)
            result_bevel_faces.append(new_bevel_faces)

        self.outputs['Vertices'].sv_set(result_vertices)
        if self.outputs['Edges'].is_linked:
            self.outputs['Edges'].sv_set(result_edges)
        if self.outputs['Polygons'].is_linked:
            self.outputs['Polygons'].sv_set(result_faces)
        if self.outputs['NewPolys'].is_linked:
            self.outputs['NewPolys'].sv_set(result_bevel_faces)
开发者ID:BitByte01,项目名称:myblendercontrib,代码行数:55,代码来源:bevel.py


注:本文中的sverchok.utils.sv_bmesh_utils.bmesh_from_pydata函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。