[Bf-python] Most efficient way to copy faces

lynx.abraxas at freenet.de lynx.abraxas at freenet.de
Thu May 28 10:11:09 CEST 2009


On 25/05/09 21:39:01, joe wrote:
> You put the faces into one big list, then you feed that to


Well, is there a more efficient way to create the big list than iterating over
all potato.faces checking iteratively their verts if they are the same as  one
of  the inside.verts list? That way I have three nested for loops. I wonder if
there is a better way using pythons set check with in?

Thanks
Lynx


> mesh.faces.extend().  Not sure how you handle UVs and the like though,
> it's kindof a pain, I think.
> 
> Joe
> 
> On Sun, May 24, 2009 at 12:41 PM,  <lynx.abraxas at freenet.de> wrote:
> > Hello,
> >
> >
> >
> > Next question: What is the most efficient way to copy faces from another mesh?
> > I have now the verts that lie within an ellipsoid and now I'd like to copy the
> > faces that belong to these verts. I'm doing it currently like this:
> >
> >
> >
> > if len(vin.verts) > 2: # we need at least one face => three verts minimum
> >      #find inside faces in potato to copy
> >      for i in range(0, len(potmesh.faces)): #check all potato faces
> >         nvi= 0
> >         f= []
> >         for j in range(0, len(potmesh.faces[i].verts)): #if all verts of a face
> >            for k in vin.verts: #are in the list of the inside verts
> >               if k.co == potmesh.faces[i].verts[j].co:
> >               #if k in potmesh.faces[i].verts:#this does not work! why?
> >                  nvi+= 1
> >                  f.append(k)#create face with vin.verts indices!
> >         if nvi == len(potmesh.faces[i].verts): #if all verts of a potato face are in the inside verts list
> >            vin.faces.extend(f) #add it to the list of insede faces
> >         elif nvi > len(potmesh.faces[i].verts):
> >            print "Potato mesh contains double verts!"
> >            #vin.faces.extend(f) #only possible for 2 to 4 verts!
> >         #else:
> >         #   print "Face not completly inside ellipsoid."
> >
> >
> > This  is  taking  a  long time for my big "potato" (3 million verts, 1 million
> > faces). Is there a better way to do this?
> >
> > Many thanks for any help or hints
> > Lynx
> >
> >
> > _______________________________________________
> > Bf-python mailing list
> > Bf-python at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-python
> >
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python



More information about the Bf-python mailing list