[SciPy-User] Scipy.spatial.Delaunay

Daniel Lepage dplepage@gmail....
Thu Mar 17 07:57:57 CDT 2011


Python's built-in `set` class removes duplicates automatically (if you
make sure to sort the indices so that each edge always has the same
representation):

edges = set()
def add_edge(v1, v2):
    edges.add((min(v1, v2), max(v1, v2))

for i in xrange(x.nsimplex):
    add_edge(x.vertices[i,0], x.vertices[i,1])
    add_edge(x.vertices[i,0], x.vertices[i,2])
    add_edge(x.vertices[i,0], x.vertices[i,3])
    add_edge(x.vertices[i,1], x.vertices[i,2])
    add_edge(x.vertices[i,1], x.vertices[i,3])
    add_edge(x.vertices[i,2], x.vertices[i,3])

You can then iterate over edges directly, or call `list(edges)` if you
need them in an ordered list.

-- 
Dan Lepage

On Thu, Mar 17, 2011 at 5:20 AM, Dan Richards <D.Richards@mmu.ac.uk> wrote:
> Thanks Pauli, Dan and Rob, this is excellent!
>
> I will look into writing my own brute force algorithm to remove duplicate
> edges/faces as your example.
>
>>https://github.com/pv/scipy-work/blob/enh%2Finterpnd-smooth/scipy/spatial/q
> hull.pyx#L969
>
> Thanks again, much appreciated.
> Dan
>
> "Before acting on this email or opening any attachments you should read the Manchester Metropolitan University email disclaimer available on its website http://www.mmu.ac.uk/emaildisclaimer "
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list