Changeset 970


Ignore:
Timestamp:
Feb 28, 2005, 4:53:26 PM (20 years ago)
Author:
duncan
Message:

update

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  
    454454        Given the edges in bdry, find the largest exterior components.
    455455        """
     456
     457        print "running _remove_holes \n"
     458       
    456459        def findroot(i):
    457460            if vptr[i] < 0:
     
    497500                    else:
    498501                        if vptr[rvl] > vptr[rvr]:
     502                            vptr[rvr] += vptr[rvl]
    499503                            vptr[rvl] = rvr
    500                             vptr[rvr] += vptr[rvl]
    501504                        else:
     505                            vptr[rvl] += vptr[rvr]
    502506                            vptr[rvr] = rvl
    503                             vptr[rvl] += vptr[rvr]
    504507                #print "vptr: ", vptr, "\n"
    505508
     
    513516        littleind = [k for k in range(len(vptr)) if (vptr[k]<0 and vptr[k]>-cutoff)]
    514517        if littleind:
    515             littlecomp = [k for k in range(len(vptr)) if findroot(k) in littlecomp]
     518            littlecomp = [k for k in range(len(vptr)) if findroot(k) in littleind]
    516519            vdiscard = [verts[k] for k in littlecomp]
    517520            newbdry = [e for e in bdry if not((e[0] in vdiscard) or (e[1] in vdiscard))]
     
    527530        Given edges in bdry, test for acute-angle indents and remove them.
    528531        """
     532
     533        print "running _smooth_indents \n"
     534       
    529535        # first find triangles not in alpha-shape
    530536        def tri_rad_gta(k):
     
    575581                    bdry.append(edga)       
    576582       
    577         newbdry = bdry
    578         return newbdry
     583        return bdry
    579584
    580585    def _expand_pinch(self,bdry):
    581586        """
    582         Given edges in bdry, test for vertices with more than 4 incident edges.
     587        Given edges in bdry, test for vertices with more than 2 incident edges.
    583588        Expand by adding back in associated triangles...
    584589        """
     590        print "running _expand_pinch \n"
    585591
    586592        #verts = self._vertices_from_edges(bdry)
     
    600606
    601607        # find exterior triangles that have a vertex in probv
    602 
    603         bdrytri = []
     608        probtri = []
    604609        for ind in extrind:
    605             bvct = 0
    606610            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
    618644   
    619645#-------------------------------------------------------------
  • inundation/ga/storm_surge/alpha_shape/test_alpha_shape.py

    r959 r970  
    128128        result = alpha.get_boundary()
    129129        #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)]
    131131        assert allclose(answer, result)
    132132        pass
Note: See TracChangeset for help on using the changeset viewer.