[Bf-python] How does pointInside work?

lynx.abraxas at freenet.de lynx.abraxas at freenet.de
Wed May 20 17:37:43 CEST 2009


Hello again!


I'd  like to find all vertices of a mesh-object that lie within another closed
mesh-object (ellipsoid)  to  calulate  an  average  normal  for  the  enclosed
surface.

But  ellmesh.pointInside(v.co)  never  retruns  true  althogh  my  testobjects
definatly intersect.

Is there something wrong with my code below or is pointInside() only  checking
if a point is inside a triangle (not in a closed mesh)?

How do the boolean modifiers check this?

Thanks for any help or hints
Lynx


print "Evaluating ellipsoids now..."
ells = [ob for ob in obs if ob.name.find('Ellipsoid') >= 0] #get ellipsoids
for ell in ells:
  ellmesh= ell.getData(mesh=1)
  print ell.name
  vin = bpy.data.meshes.new('Imesh_')          # create a new mesh
  for v in potmesh.verts: #find all potato vertices inside this ellipsoid
    #print v.co
    #print len(vin.verts)

    if ellmesh.pointInside(v.co):

        vin.verts.extend(v) #append? No extend is from MVertSeq
        print "extended vert-list by: ", v
        #what if ell is smaller than potato trig??? Subsurf would help!
    #print len(vin.verts)
  if len(vin.verts):
        print vin
        print vin.verts
        if len(vin.trigs) < MinTrigs:
            print "Very few normals inside: ", len(vin.trigs)
            print "Perhaps megabool would help here"
            print "Just subsurfing won't help!"
        for t in vin.trigs:
            #calcNormals()#recalcNormals(direction=0)
            #subdivide(beauty=0)
            #QuadNormal(vec1, vec2, vec3, vec4)
            #quadToTriangle(mode=0)#triangleToQuad()
            a= B.Mathutils.TriangleArea(vec1, vec2, vec3)
            n= B.Mathutils.TriangleNormal(vec1, vec2, vec3)
            n.normalize() #normalize the normal
            ns= ns + a*n  #add area weighted normal to normal sum
        print "Normal sum of ellipsoid: ", ell, ns





More information about the Bf-python mailing list