[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1786] contrib/py/scripts/addons/ mesh_bridge.py: removed from contrib/py/scripts/addons/mesh_bridge.py

Brendon Murphy meta.androcto1 at gmail.com
Tue Apr 5 11:23:48 CEST 2011


Revision: 1786
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1786
Author:   meta-androcto
Date:     2011-04-05 09:23:48 +0000 (Tue, 05 Apr 2011)
Log Message:
-----------
removed from contrib/py/scripts/addons/mesh_bridge.py
script has been merged with looptools script in trunk
Many thanks to Crouch

Removed Paths:
-------------
    contrib/py/scripts/addons/mesh_bridge.py

Deleted: contrib/py/scripts/addons/mesh_bridge.py
===================================================================
--- contrib/py/scripts/addons/mesh_bridge.py	2011-04-05 01:06:36 UTC (rev 1785)
+++ contrib/py/scripts/addons/mesh_bridge.py	2011-04-05 09:23:48 UTC (rev 1786)
@@ -1,1041 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-#  This program is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2
-#  of the License, or (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-bl_info = {
-    'name': 'Bridge',
-    'author': 'Bartius Crouch',
-    'version': (1, 4, 7),
-    'blender': (2, 5, 7),
-    'api': 34674,
-    'location': 'View3D > Ctrl+F > Bridge',
-    'warning': '',
-    'description': 'Bridge two, or loft several, loops of vertices.',
-    'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.5/Py/'\
-        'Scripts/Modeling/Bridge',
-    'tracker_url': 'http://projects.blender.org/tracker/index.php?'\
-        'func=detail&aid=23889',
-    'category': 'Mesh'}
-
-"""
-Bridge
-
-How to use:
-- Select a mesh and go into editmode
-- Select two or more edge-loops
-- Press Ctrl+F
-- Select the Bridge or Loft option
-"""
-
-
-import bpy
-import mathutils
-
-
-# gather initial data
-def initialise(interpolation):
-    global_undo = bpy.context.user_preferences.edit.use_global_undo
-    bpy.context.user_preferences.edit.use_global_undo = False
-    bpy.ops.object.mode_set(mode = 'OBJECT')
-    mesh = bpy.context.active_object.data
-    old_selected_faces = [face.index for face in mesh.faces if face.select and not face.hide]
-    
-    smooth = False
-    if mesh.faces:
-        if sum([face.use_smooth for face in mesh.faces])/len(mesh.faces) >= 0.5:
-            smooth = True
-
-    if interpolation == 'cubic':
-        # dictionary with the edge-key as key
-        # and a list of connected valid faces as value
-        face_blacklist = [face.index for face in mesh.faces if face.select or face.hide]
-        edge_faces = dict([[edge.key, []] for edge in mesh.edges if not edge.hide])
-        for face in mesh.faces:
-            if face.index in face_blacklist:
-                continue
-            for key in face.edge_keys:
-                edge_faces[key].append(face)
-        # dictionary with the edge-key as key and edge as value
-        edgekey_to_edge = dict([[edge.key, edge] for edge in mesh.edges if edge.select and not edge.hide])
-    else:
-        edge_faces = False
-        edgekey_to_edge = False
-    
-    return global_undo, mesh, old_selected_faces, smooth, edge_faces, edgekey_to_edge
-
-
-# clean up and set settings back to original state
-def terminate(global_undo):
-    bpy.ops.object.mode_set(mode = 'EDIT')
-    bpy.context.user_preferences.edit.use_global_undo = global_undo
-
-
-# return a list of 2 non-connected loops (vertex indices), or False
-def get_selection(mesh):
-    # create list of internal edges, which should be skipped
-    eks_of_selected_faces = [item for sublist in [face.edge_keys for face in mesh.faces if face.select and not face.hide] for item in sublist]
-    edge_count = {}
-    for ek in eks_of_selected_faces:
-        if ek in edge_count:
-            edge_count[ek] += 1
-        else:
-            edge_count[ek] = 1
-    internal_edges = [ek for ek in edge_count if edge_count[ek]>1]
-    
-    selected_edges = [edge.key for edge in mesh.edges if edge.select and not edge.hide and edge.key not in internal_edges]
-    vert_connections = {}
-    loops = []
-    # dict with vertex index as key, list of connected vertices as value
-    for key in selected_edges:
-        for i in range(2):
-            if key[i] not in vert_connections:
-                vert_connections[key[i]] = [key[1-i]]
-            else:
-                if len(vert_connections[key[i]]) == 2:
-                    return False
-                vert_connections[key[i]].append(key[1-i])
-    
-    while len(vert_connections) > 0:
-        loop = [iter(vert_connections.keys()).__next__()]
-        growing = True
-        sides_left = True
-
-        while growing:
-            # no more connection data for current vertex
-            if loop[-1] not in vert_connections:
-                if sides_left == True:
-                    loop.reverse()
-                    sides_left = False
-                else:
-                    growing = False
-            else:
-                extended = False
-                for connection_index, connecting_vertex in enumerate(vert_connections[loop[-1]]):
-                    if connecting_vertex not in loop:
-                        vert_connections[loop[-1]].pop(connection_index)
-                        if len(vert_connections[loop[-1]]) == 0:
-                            del vert_connections[loop[-1]]
-                        # remove connection both ways
-                        if connecting_vertex in vert_connections:
-                            if len(vert_connections[connecting_vertex]) == 1:
-                                del vert_connections[connecting_vertex]
-                            else:
-                                vert_connections[connecting_vertex].remove(loop[-1])
-                        loop.append(connecting_vertex)
-                        extended = True
-                        break
-                if not extended:
-                    # found one end of the loop, continue with next
-                    if sides_left == True:
-                        loop.reverse()
-                        sides_left = False
-                    # found both ends of the loop, stop growing
-                    elif sides_left == False:
-                        growing = False
-                    
-        # check for circular
-        if loop[0] in vert_connections:
-            if loop[-1] in vert_connections[loop[0]]:
-                # is circular
-                if len(vert_connections[loop[0]]) == 1:
-                    del vert_connections[loop[0]]
-                else:
-                    vert_connections[loop[0]].remove(loop[-1])
-                if len(vert_connections[loop[-1]]) == 1:
-                    del vert_connections[loop[-1]]
-                else:
-                    vert_connections[loop[-1]].remove(loop[-1])
-                loop = [loop, True]
-            else:
-                # not circular
-                loop = [loop, False]
-        else:
-            # not circular
-            loop = [loop, False]
-        
-        loops.append(loop)
-    
-    if len(loops) < 2:
-        # can't bridge if there is only 1 loop (or none)
-        return False
-    else:
-        return loops
-
-
-# sort loops, so they are connected in the correct order when lofting
-def sort_loops(mesh, loops, loft_loop):
-    # simplify loops to single points, and prepare for pathfinding
-    x, y, z = [[sum([mesh.vertices[i].co[j] for i in loop[0]]) / len(loop[0]) for loop in loops] for j in range(3)]
-    nodes = [mathutils.Vector([x[i], y[i], z[i]]) for i in range(len(loops))]
-    
-    active_node = 0
-    open = [i for i in range(1, len(loops))]
-    path = [[0,0]]
-    # connect node to path, that is shortest to active_node
-    while len(open) > 0:
-        distances = [(nodes[active_node] - nodes[i]).length for i in open]
-        active_node = open[distances.index(min(distances))]
-        open.remove(active_node)
-        path.append([active_node, min(distances)])
-    # check if we didn't start in the middle of the path
-    for i in range(2, len(path)):
-        if (nodes[path[i][0]]-nodes[0]).length < path[i][1]:
-            temp = path[:i]
-            path.reverse()
-            path = path[:-i] + temp
-            break
-    
-    # reorder loops
-    loops = [loops[i[0]] for i in path]
-    # if requested, duplicate first loop at last position, so loft can loop
-    if loft_loop:
-        loops = loops + [loops[0]]
-    return loops
-
-
-# match up loops in pairs, used for multi-input bridging
-def match_loops(mesh, loops):
-    # calculate average loop normals and centers
-    normals = []
-    centers = []
-    for vertices, circular in loops:
-        normal = mathutils.Vector([0, 0, 0])
-        center = mathutils.Vector([0, 0, 0])
-        for vertex in vertices:
-            normal += mesh.vertices[vertex].normal
-            center += mesh.vertices[vertex].co
-        normals.append(normal / len(vertices) / 10)
-        centers.append(center / len(vertices))
-    
-    # possible matches if loop normals are faced towards the center of the other loop
-    matches = dict([[i, []] for i in range(len(loops))])
-    matches_amount = 0
-    for i in range(len(loops) + 1):
-        for j in range(i+1, len(loops)):
-            if (centers[i] - centers[j]).length > (centers[i] - (centers[j] + normals[j])).length and \
-            (centers[j] - centers[i]).length > (centers[j] - (centers[i] + normals[i])).length:
-                matches_amount += 1
-                matches[i].append([(centers[i] - centers[j]).length, i, j])
-                matches[j].append([(centers[i] - centers[j]).length, j, i])
-    # if no loops face each other, just make matches between all the loops
-    if matches_amount == 0:
-        for i in range(len(loops) + 1):
-            for j in range(i+1, len(loops)):
-                matches[i].append([(centers[i] - centers[j]).length, i, j])
-                matches[j].append([(centers[i] - centers[j]).length, j, i])
-    for key, value in matches.items():
-        value.sort()
-
-    # make matches based on distance between centers and number of vertices in loops
-    new_order = []
-    for loop_index in range(len(loops)):
-        if loop_index in new_order:
-            continue
-        loop_matches = matches[loop_index]
-        if not loop_matches:
-            continue
-        shortest_distance = loop_matches[0][0]

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list