@@ -174,36 +174,47 @@ function vizmeshfacets!(plot, ::Type, ::Val{2}, ::Val)
174174 segmentcolor = plot[:segmentcolor ]
175175 segmentsize = plot[:segmentsize ]
176176
177- # retrieve coordinates parameters
177+ # retrieve raw coordinates
178178 coords = Makie. @lift let
179179 # relevant settings
180- T = Unitful. numtype (Meshes. lentype ($ mesh))
180+ ℒ = Meshes. lentype ($ mesh)
181+ T = Unitful. numtype (ℒ)
181182 dim = embeddim ($ mesh)
182183 topo = topology ($ mesh)
183184 nvert = nvertices ($ mesh)
184185 verts = vertices ($ mesh)
185- coords = map (p -> ustrip .(to (p)), verts)
186186
187- # use a sophisticated data structure
188- # to extract the edges from the n-gons
189- t = convert (HalfEdgeTopology, topo )
190- ∂ = Boundary {1,0} (t )
187+ # extract coordinates and insert sentinel
188+ # vertex with NaN coordinates at the end
189+ xyz = map (p -> ustrip .( to (p)), verts )
190+ push! (xyz, SVector ( ntuple (i -> T ( NaN ), dim)) )
191191
192- # append indices of incident vertices
193- # interleaved with a sentinel index
192+ # find indices of incident vertices
194193 inds = Int[]
195- for i in 1 : nfacets (t)
196- for j in ∂ (i)
197- push! (inds, j)
194+ try # efficient algorithm with half-edge topology
195+ t = convert (HalfEdgeTopology, topo)
196+ ∂ = Boundary {1,0} (t)
197+ for i in 1 : nfacets (t)
198+ for j in ∂ (i)
199+ push! (inds, j)
200+ end
201+ # interleave with a sentinel index
202+ push! (inds, nvert + 1 )
203+ end
204+ catch # brute force algorithm with duplicate edges
205+ t = topo
206+ ∂ = Boundary {2,0} (t)
207+ for i in 1 : nelements (t)
208+ for j in ∂ (i)
209+ push! (inds, j)
210+ end
211+ # interleave with a sentinel index
212+ push! (inds, nvert + 1 )
198213 end
199- push! (inds, nvert + 1 )
200214 end
201215
202- # fill sentinel index with NaN coordinates
203- push! (coords, SVector (ntuple (i -> T (NaN ), dim)))
204-
205216 # extract incident vertices
206- coords [inds]
217+ xyz [inds]
207218 end
208219
209220 Makie. lines! (plot, coords, color= segmentcolor, linewidth= segmentsize)
0 commit comments