mesh_edges2curves - edge key optimize and made use of scn.objects rather then Object.New()..

Object.py - passIndex mistake
This commit is contained in:
2006-12-12 21:38:04 +00:00
parent 80ee52e444
commit 824f391c75
2 changed files with 29 additions and 33 deletions

View File

@@ -42,8 +42,13 @@ Supported:<br>
from Blender import *
def sortPair(a,b):
return min(a,b), max(a,b)
def edkey(ed):
i1 = ed.v1.index
i2 = ed.v2.index
if i1>i2:
return (i2,i1), ed
else:
return (i1,i2), ed
def polysFromMesh(me):
# a polyline is 2
@@ -51,10 +56,17 @@ def polysFromMesh(me):
polyLines = []
# Get edges not used by a face
edgeDict= dict([ (sortPair(ed.v1.index, ed.v2.index), ed) for ed in me.edges ])
edgeDict= dict([ edkey(ed) for ed in me.edges ])
for f in me.faces:
for i in xrange(len(f.v)):
key= sortPair(f.v[i].index, f.v[i-1].index)
fvi = [v.index for v in f]
for i in xrange(len(fvi)):
i1 = fvi[i]
i2 = fvi[i-1]
if i1>i2:
key = i2,i1
else:
key = i1,i2
try:
del edgeDict[key]
except:
@@ -62,21 +74,6 @@ def polysFromMesh(me):
edges= edgeDict.values()
'''
# build vert connectivite
vertConnex= [list() for i in xrange(len(me.verts))]
for ed in edges:
i1= ed.v1.index
i2= ed.v2.index
vertConnex[i1].append(i2)
vertConnex[i2].append(i1)
# verts without 2 users are none.
vertConnex=[ [None,vc][len(vc)==2] for vc in vertConnex
'''
while edges:
currentEdge= edges.pop()
startVert= currentEdge.v2
@@ -94,25 +91,25 @@ def polysFromMesh(me):
polyLine.append(ed.v2)
endVert= polyLine[-1]
ok=1
edges.pop(i)
del edges[i]
#break
elif ed.v2 == endVert:
polyLine.append(ed.v1)
endVert= polyLine[-1]
ok=1
edges.pop(i)
del edges[i]
#break
elif ed.v1 == startVert:
polyLine.insert(0, ed.v2)
startVert= polyLine[0]
ok=1
edges.pop(i)
del edges[i]
#break
elif ed.v2 == startVert:
polyLine.insert(0, ed.v1)
startVert= polyLine[0]
ok=1
edges.pop(i)
del edges[i]
#break
polyLines.append((polyLine, polyLine[0]==polyLine[-1]))
print len(edges), len(polyLines)
@@ -121,10 +118,10 @@ def polysFromMesh(me):
def mesh2polys():
scn= Scene.GetCurrent()
for ob in scn.getChildren():
for ob in scn.objects:
ob.sel= 0
meshOb= scn.getActiveObject()
if meshOb==None or meshOb.getType() != 'Mesh':
meshOb= scn.objects.active
if meshOb==None or meshOb.type != 'Mesh':
Draw.PupMenu( 'ERROR: No Active Mesh Selected, Aborting' )
return
Window.WaitCursor(1)
@@ -133,13 +130,12 @@ def mesh2polys():
polygons= polysFromMesh(me)
w=t=1
cu= Curve.New()
cu.name = me.name
cu.setFlag(1)
ob= Object.New('Curve', me.name)
ob.link(cu)
scn.link(ob)
ob.Layers= meshOb.Layers
ob = scn.objects.new(cu)
ob.setMatrix(meshOb.matrixWorld)
ob.sel= 1
i=0
for poly, closed in polygons:
if closed:

View File

@@ -438,7 +438,7 @@ class Object:
@type DupOff: int
@ivar passIndex: Index # for the IndexOB render pass.
Value is clamped to [0,1000].
@type DupOff: int
@type passIndex: int
@ivar drawSize: The size to display the Empty.
Value clamped to [0.01,10.0].
@type drawSize: float