Changeset 970
- Timestamp:
- Feb 28, 2005, 4:53:26 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/alpha_shape
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/alpha_shape/alpha_shape.py
r959 r970 454 454 Given the edges in bdry, find the largest exterior components. 455 455 """ 456 457 print "running _remove_holes \n" 458 456 459 def findroot(i): 457 460 if vptr[i] < 0: … … 497 500 else: 498 501 if vptr[rvl] > vptr[rvr]: 502 vptr[rvr] += vptr[rvl] 499 503 vptr[rvl] = rvr 500 vptr[rvr] += vptr[rvl]501 504 else: 505 vptr[rvl] += vptr[rvr] 502 506 vptr[rvr] = rvl 503 vptr[rvl] += vptr[rvr]504 507 #print "vptr: ", vptr, "\n" 505 508 … … 513 516 littleind = [k for k in range(len(vptr)) if (vptr[k]<0 and vptr[k]>-cutoff)] 514 517 if littleind: 515 littlecomp = [k for k in range(len(vptr)) if findroot(k) in little comp]518 littlecomp = [k for k in range(len(vptr)) if findroot(k) in littleind] 516 519 vdiscard = [verts[k] for k in littlecomp] 517 520 newbdry = [e for e in bdry if not((e[0] in vdiscard) or (e[1] in vdiscard))] … … 527 530 Given edges in bdry, test for acute-angle indents and remove them. 528 531 """ 532 533 print "running _smooth_indents \n" 534 529 535 # first find triangles not in alpha-shape 530 536 def tri_rad_gta(k): … … 575 581 bdry.append(edga) 576 582 577 newbdry = bdry 578 return newbdry 583 return bdry 579 584 580 585 def _expand_pinch(self,bdry): 581 586 """ 582 Given edges in bdry, test for vertices with more than 4incident edges.587 Given edges in bdry, test for vertices with more than 2 incident edges. 583 588 Expand by adding back in associated triangles... 584 589 """ 590 print "running _expand_pinch \n" 585 591 586 592 #verts = self._vertices_from_edges(bdry) … … 600 606 601 607 # find exterior triangles that have a vertex in probv 602 603 bdrytri = [] 608 probtri = [] 604 609 for ind in extrind: 605 bvct = 0606 610 for j in [0,1,2]: 607 if self.deltri[ind][j] in probv: 608 bvct +=1 609 if bvct>0: 610 bdrytri.append(ind) 611 612 #print "boundary triangles ", bdrytri 613 614 615 616 newbdry = bdry 617 return newbdry 611 if (self.deltri[ind][j] in probv): 612 tr = (ind,j) 613 if probtri.count(tr)==0: 614 probtri.append(tr) 615 616 # print "problem boundary triangle indices ", probtri 617 618 # "add in" the problem triangles 619 for t in probtri: 620 tri = self.deltri[t[0]] 621 opeda = ( tri[(t[1]+1)%3], tri[(t[1]+2)%3] ) 622 opedb = ( tri[(t[1]+2)%3], tri[(t[1]+1)%3] ) 623 # oped is the edge opposite the problem vertex 624 # if oped is in bdry remove it and the other triangle edges 625 # otherwise add oped to the bdry and remove the other triangle edges 626 627 if opeda in bdry: 628 bdry.remove(opeda) 629 elif opedb in bdry: 630 bdry.remove(opedb) 631 else: 632 bdry.append(opeda) 633 634 if (tri[t[1]], tri[(t[1]+1)%3]) in bdry: 635 bdry.remove((tri[t[1]], tri[(t[1]+1)%3])) 636 if (tri[(t[1]+1)%3], tri[t[1]]) in bdry: 637 bdry.remove((tri[(t[1]+1)%3], tri[t[1]])) 638 if (tri[t[1]], tri[(t[1]+2)%3]) in bdry: 639 bdry.remove((tri[t[1]], tri[(t[1]+2)%3])) 640 if (tri[(t[1]+2)%3], tri[t[1]]) in bdry: 641 bdry.remove((tri[(t[1]+2)%3], tri[t[1]])) 642 643 return bdry 618 644 619 645 #------------------------------------------------------------- -
inundation/ga/storm_surge/alpha_shape/test_alpha_shape.py
r959 r970 128 128 result = alpha.get_boundary() 129 129 #print "result",result 130 result[(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 0)]130 answer = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 0)] 131 131 assert allclose(answer, result) 132 132 pass
Note: See TracChangeset
for help on using the changeset viewer.