• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python sv_bmesh_utils.bmesh_from_pydata函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: makecube

    def makecube(self, size, divx, divy, divz):
        if 0 in (divx, divy, divz):
            return [], []

        b = size / 2.0

        verts = [
            [b, b, -b], [b, -b, -b], [-b, -b, -b],
            [-b, b, -b], [b, b, b], [b, -b, b],
            [-b, -b, b], [-b, b, b]
        ]

        faces = [[0, 1, 2, 3], [4, 7, 6, 5],
                 [0, 4, 5, 1], [1, 5, 6, 2],
                 [2, 6, 7, 3], [4, 0, 3, 7]]

        edges = [[0, 4], [4, 5], [5, 1], [1, 0],
                 [5, 6], [6, 2], [2, 1], [6, 7],
                 [7, 3], [3, 2], [7, 4], [0, 3]]

        if (divx, divy, divz) == (1, 1, 1):
            return verts, edges, faces

        bm = bmesh_from_pydata(verts, [], faces)
        dist = 0.0001
        section_dict = {0: divx, 1: divy, 2: divz}

        for axis in range(3):

            num_sections = section_dict[axis]
            if num_sections == 1:
                continue

            step = 1 / num_sections
            v1 = Vector(tuple((b if (i == axis) else 0) for i in [0, 1, 2]))
            v2 = Vector(tuple((-b if (i == axis) else 0) for i in [0, 1, 2]))

            for section in range(num_sections):
                mid_vec = v1.lerp(v2, section * step)
                plane_no = v2 - mid_vec
                plane_co = mid_vec
                visible_geom = bm.faces[:] + bm.verts[:] + bm.edges[:]

                bmesh.ops.bisect_plane(
                    bm, geom=visible_geom, dist=dist,
                    plane_co=plane_co, plane_no=plane_no,
                    use_snap_center=False,
                    clear_outer=False, clear_inner=False)

        indices = lambda i: [j.index for j in i.verts]

        verts = [list(v.co.to_tuple()) for v in bm.verts]
        faces = [indices(face) for face in bm.faces]
        edges = [indices(edge) for edge in bm.edges]
        return verts, edges, faces
开发者ID:johnyc90,项目名称:sverchok,代码行数:55,代码来源:box.py


示例17: process

    def process(self):
        vers = self.inputs['Vertices'].sv_get()
        pols = self.inputs['Polygons'].sv_get()

        normalsFORout = []
        for i, obj in enumerate(vers):
            bm = bmesh_from_pydata(obj, [], pols[i], normal_update=True)
            normalsFORout.append([v.normal[:] for v in bm.verts])
            bm.free()
        
        self.outputs['Normals'].sv_set(normalsFORout)
开发者ID:elfnor,项目名称:sverchok,代码行数:11,代码来源:normal.py


示例18: make_bmesh_geometry

def make_bmesh_geometry(node, idx, context, verts, *topology):
    scene = context.scene
    meshes = bpy.data.meshes
    objects = bpy.data.objects
    edges, faces, matrix = topology
    name = node.basemesh_name + "_" + str(idx)

    if name in objects:
        sv_object = objects[name]
    else:
        temp_mesh = default_mesh(name)
        sv_object = objects.new(name, temp_mesh)
        scene.objects.link(sv_object)

    # book-keeping via ID-props!? even this is can be broken by renames
    sv_object['idx'] = idx
    sv_object['madeby'] = node.name
    sv_object['basename'] = node.basemesh_name

    mesh = sv_object.data
    current_count = len(mesh.vertices)
    propose_count = len(verts)
    difference = (propose_count - current_count)

    ''' With this mode you make a massive assumption about the
        constant state of geometry. Assumes the count of verts
        edges/faces stays the same, and only updates the locations

        node.fixed_verts is not suitable for initial object creation
        but if over time you find that the only change is going to be
        vertices, this mode can be switched to to increase efficiency
    '''
    if node.fixed_verts and difference == 0:
        f_v = list(itertools.chain.from_iterable(verts))
        mesh.vertices.foreach_set('co', f_v)
        mesh.update()
    else:

        ''' get bmesh, write bmesh to obj, free bmesh'''
        bm = bmesh_from_pydata(verts, edges, faces)
        bm.to_mesh(sv_object.data)
        bm.free()

        sv_object.hide_select = False

    if matrix:
        matrix = matrix_sanitizer(matrix)
        if node.extended_matrix:
            sv_object.data.transform(matrix)
            sv_object.matrix_local = Matrix.Identity(4)
        else:
            sv_object.matrix_local = matrix
    else:
        sv_object.matrix_local = Matrix.Identity(4)
开发者ID:TakamitsuNobe,项目名称:myblendercontrib,代码行数:54,代码来源:viewer_bmesh_mk2.py


示例19: make_bmesh_geometry_merged

def make_bmesh_geometry_merged(node, idx, context, yielder_object):
    scene = context.scene
    meshes = bpy.data.meshes
    objects = bpy.data.objects
    name = node.basemesh_name + "_" + str(idx)

    if name in objects:
        sv_object = objects[name]
    else:
        temp_mesh = default_mesh(name)
        sv_object = objects.new(name, temp_mesh)
        scene.objects.link(sv_object)

    # book-keeping via ID-props!
    sv_object['idx'] = idx
    sv_object['madeby'] = node.name
    sv_object['basename'] = node.basemesh_name

    vert_count = 0
    big_verts = []
    big_edges = []
    big_faces = []

    for result in yielder_object:

        verts, topology = result
        edges, faces, matrix = topology

        if matrix:
            matrix = matrix_sanitizer(matrix)
            verts = [matrix * Vector(v) for v in verts]

        big_verts.extend(verts)
        big_edges.extend([[a + vert_count, b + vert_count] for a, b in edges])
        big_faces.extend([[j + vert_count for j in f] for f in faces])

        vert_count += len(verts)


    if node.fixed_verts and len(sv_object.data.vertices) == len(big_verts):
        mesh = sv_object.data
        f_v = list(itertools.chain.from_iterable(big_verts))
        mesh.vertices.foreach_set('co', f_v)
        mesh.update()
    else:
        ''' get bmesh, write bmesh to obj, free bmesh'''
        bm = bmesh_from_pydata(big_verts, big_edges, big_faces, normal_update=node.calc_normals)
        bm.to_mesh(sv_object.data)
        bm.free()

    sv_object.hide_select = False
    sv_object.matrix_local = Matrix.Identity(4)
开发者ID:elfnor,项目名称:sverchok,代码行数:52,代码来源:viewer_bmesh_mk2.py


示例20: fill_holes

def fill_holes(vertices, edges, s):

    if not edges and not vertices:
        return False

    if len(edges[0]) != 2:
        return False
    
    bm = bmesh_from_pydata(vertices, edges, [])

    bmesh.ops.holes_fill(bm, edges=bm.edges[:], sides=s)
    verts, edges, faces = pydata_from_bmesh(bm)
    return (verts, edges, faces)
开发者ID:elfnor,项目名称:sverchok,代码行数:13,代码来源:holes_fill.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python path.parse_path函数代码示例发布时间:2022-05-27
下一篇:
Python data_structure.updateNode函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap