[Bf-python] Thinmesh module, v1.1

Ken Hughes khughes at pacific.edu
Sat Sep 24 01:41:34 CEST 2005


Joseph Gilbert wrote:
> Ken Hughes wrote:
> 
>>    mesh.appendEdges( [ (v[0],v[1]), (v[1],v[2]), (v[2],v[0]) ] )
>  
> Looks a little cumbersome to me. Maybe just (v[0],v[1]), (v[1],v[2]), 
> (v[2],v[0]) without the list. (remember args is passed as a tuple) You 
> could probably extract using the sequence protocol. I like the 
> multi-edge construction - it's nice.  Why not have both?

I picked lists since they're mutable; I wasn't thinking about a user 
doing the above all the time but building a list of edges to be added. 
Of course the method could look scan either type of sequence without 
much trouble.  I'll change it to do that.

>> Advantage of this: there's only one MEM_callocN() / memcpy() needed 
>> for this since I process the list of edges once
> 
> *ACK* BPy should never use guardedmalloc directly to alloc/free memory. 
> Your looking for trouble mister.

Even if the memory was allocated by MEM_callocN()?  This is the Blender 
mesh list of edges, not a BPython list.

>> But since I'm relying on Python to build my list of tuples (and 
>> assuming a more complex script is going to be using append() 
>> operations to build the actual list) I don't know which is more 
>> advantageous.  So later this weekend I'll try some tests with larger 
>> meshs and see what results.
> 
> How would someone call an edge? (just wondering) For instance 
> Mesh.edge[1] ? How do I know that mesh.appendEdges(v[0],v[1]) makes me 
> and .edge[1]?

Should addEdges() return a sequence of edges, corresponging to each 
vertex pair?  Or is the edge list only needed to add faces; maybe in 
that case we just make an addFaces() method which takes vert pairs 
and/or edges and makes the faces, creating edges and verts where needed?

> Also it seems edges are an ugly manual process where the user needs to 
> define what an edge is. If it was me i would load all my verts into a 
> list and run a loop:
> e =([v1, v3],[ v3, v4], [v4, v5], [v6, v7])
> for a, b in e:
> ...mesh.appendEdge(a,b)

That's exactly what addEdges() does, except you could do this instead:

  e =((v1, v3),(v3, v4), (v4, v5), (v6, v7))
  mesh.addEdges(e)

Ken



More information about the Bf-python mailing list