Line data Source code
1 0 : function graphviz(io::IO, mesh::Mesh)
2 0 : print(io, "digraph {\n")
3 :
4 0 : print(io, " { node [shape=circle]\n")
5 0 : for v in vertices(mesh)
6 0 : x = vattr(mesh, :x)[v] * 10
7 0 : print(io, " v$(Int(v)) [label=<<B>$(Int(v))</B> $(Int(halfedge(mesh, v)))→>, pos=\"$(x[1]),$(x[2])!\"];\n")
8 0 : end
9 :
10 0 : for f in faces(mesh)
11 0 : v = collect(vertices(mesh, f))
12 0 : x = sum(vattr(mesh, :x)[v] for v in v) / length(v) * 10
13 :
14 0 : print(io, " f$(Int(f)) [color=\"cyan\", label=<<B>$(Int(f))</B> →$(Int(halfedge(mesh, f)))>, pos=\"$(x[1]),$(x[2])!\"];\n")
15 0 : end
16 :
17 0 : print(io, " }\n\n")
18 :
19 0 : for h01 in halfedges(mesh)
20 0 : for h in h01
21 0 : a, b = vertices(mesh, h)
22 :
23 0 : color = Int(h) & 0x1 == 0 ? "blue" : "red"
24 :
25 0 : f = face(mesh, h)
26 0 : print(io, "v$(Int(a)) -> v$(Int(b)) [color=\"$(color)\", fontcolor=\"$(color)\", label=<<SUB>$(Int(prev(mesh, h)))</SUB><B>$(Int(h))</B><SUP>$(Int(next(mesh, h)))</SUP> Δ<I>$(Int(f))</I> →$(Int(destination(mesh, h)))>];\n")
27 0 : end
28 0 : end
29 :
30 : # for f ...
31 :
32 : # for v ...
33 :
34 0 : print(io, "}\n")
35 : end
36 :
37 0 : function graphviz(mesh::Mesh; filename = tempname(), display = true, ext = :pdf)
38 0 : open("$(filename).dot", "w+") do f
39 0 : graphviz(f, mesh)
40 : end
41 :
42 0 : run(`neato $(filename).dot -T$(ext) -o $(filename).$(ext)`)
43 0 : if display
44 0 : ext == :pdf && run(`xdg-open $(filename).pdf`)
45 0 : ext == :svg && run(`xsvg $(filename).svg`)
46 : end
47 : end
48 :
49 : """
50 : graphviz(io, mesh)
51 : graphviz(mesh[; filename=tempname(), display=true, ext=:pdf])
52 :
53 : Output [GraphViz](https://graphviz.org/) DOT representation for 2d
54 : `mesh`. This method is intended for debugging internals. The graph
55 : representation displays handles and [`link`](@ref) attributes of
56 : elements.
57 :
58 : `ext` determines the output format (see `dot` manual). If
59 : `display==true`, show result in PDF viewer (`xdg-open` for
60 : `ext==:pdf`) or SVG viewer (`xsvg` for `ext==:avg`).
61 : """ graphviz
|