Changeset 1227


Ignore:
Timestamp:
Apr 14, 2005, 3:48:25 PM (20 years ago)
Author:
duncan
Message:

from vanessa

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/alpha_shape/alpha_shape.py

    r987 r1227  
    428428
    429429        #initialise vptr and eptr to negative number outside range
    430         EMPTY = -max(verts) - len(bdry)
     430        EMPTY = -max(verts)-len(verts)
    431431        vptr = [EMPTY for k in range(len(verts))]
    432         eptr = [EMPTY for k in range(len(bdry))]
    433432        #print "vptr init: ", vptr, "\n"
    434433
     
    447446                        vptr[vl] = -2
    448447                        vptr[vr] = vl
    449                         #eprt[i] = vl
    450448                    else:
    451449                        vptr[vl] = rvr
    452                         vptr[rvr] -= 1
     450                        vptr[rvr] = vptr[rvr]-1
    453451                else:
    454452                    if (vptr[vr]==EMPTY):
    455453                        vptr[vr] = rvl
    456                         vptr[rvl] -= 1
     454                        vptr[rvl] = vptr[rvl]-1
    457455                    else:
    458456                        if vptr[rvl] > vptr[rvr]:
    459                             vptr[rvr] += vptr[rvl]
     457                            vptr[rvr] = vptr[rvr] + vptr[rvl]
    460458                            vptr[rvl] = rvr
     459                            vptr[vl] = rvr
    461460                        else:
    462                             vptr[rvl] += vptr[rvr]
     461                            vptr[rvl] = vptr[rvl] + vptr[rvr]
    463462                            vptr[rvr] = rvl
     463                            vptr[vr] = rvl
    464464                #print "vptr: ", vptr, "\n"
    465465
    466466        # end edge loop
    467467
    468         #print "vertex component tree: ", vptr, "\n"
    469 
     468        # print "vertex component tree: ", [-v for v in vptr if v<0], "\n"
     469        # print "largest component has: ", -min(vptr), " points. \n"
    470470        # discard the edges in the little components
    471471        # (i.e. those components with less than 'small' fraction of bdry points)
    472472        cutoff = round(small*len(verts))
     473        # print "cutoff component size is ", cutoff, "\n"
     474        largest_component = -min(vptr)
     475        if cutoff > largest_component:
     476            cutoff = round((1-small)*largest_component)
     477       
    473478        littleind = [k for k in range(len(vptr)) if (vptr[k]<0 and vptr[k]>-cutoff)]
    474479        if littleind:
    475480            littlecomp = [k for k in range(len(vptr)) if findroot(k) in littleind]
    476481            vdiscard = [verts[k] for k in littlecomp]
    477             newbdry = [e for e in bdry if not((e[0] in vdiscard) or (e[1] in vdiscard))]
     482            newbdry = [e for e in bdry if not((e[0] in vdiscard) and (e[1] in vdiscard))]
    478483            # remove boundary triangles that touch discarded components
    479484            newbt = []
Note: See TracChangeset for help on using the changeset viewer.