Changeset 1227
- Timestamp:
- Apr 14, 2005, 3:48:25 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/alpha_shape/alpha_shape.py
r987 r1227 428 428 429 429 #initialise vptr and eptr to negative number outside range 430 EMPTY = -max(verts) - len(bdry)430 EMPTY = -max(verts)-len(verts) 431 431 vptr = [EMPTY for k in range(len(verts))] 432 eptr = [EMPTY for k in range(len(bdry))]433 432 #print "vptr init: ", vptr, "\n" 434 433 … … 447 446 vptr[vl] = -2 448 447 vptr[vr] = vl 449 #eprt[i] = vl450 448 else: 451 449 vptr[vl] = rvr 452 vptr[rvr] -=1450 vptr[rvr] = vptr[rvr]-1 453 451 else: 454 452 if (vptr[vr]==EMPTY): 455 453 vptr[vr] = rvl 456 vptr[rvl] -=1454 vptr[rvl] = vptr[rvl]-1 457 455 else: 458 456 if vptr[rvl] > vptr[rvr]: 459 vptr[rvr] +=vptr[rvl]457 vptr[rvr] = vptr[rvr] + vptr[rvl] 460 458 vptr[rvl] = rvr 459 vptr[vl] = rvr 461 460 else: 462 vptr[rvl] +=vptr[rvr]461 vptr[rvl] = vptr[rvl] + vptr[rvr] 463 462 vptr[rvr] = rvl 463 vptr[vr] = rvl 464 464 #print "vptr: ", vptr, "\n" 465 465 466 466 # end edge loop 467 467 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" 470 470 # discard the edges in the little components 471 471 # (i.e. those components with less than 'small' fraction of bdry points) 472 472 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 473 478 littleind = [k for k in range(len(vptr)) if (vptr[k]<0 and vptr[k]>-cutoff)] 474 479 if littleind: 475 480 littlecomp = [k for k in range(len(vptr)) if findroot(k) in littleind] 476 481 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))] 478 483 # remove boundary triangles that touch discarded components 479 484 newbt = []
Note: See TracChangeset
for help on using the changeset viewer.