Skip to content

Commit d1d8ebe

Browse files
authored
Use eachvertex in more places (#1137)
1 parent 7e94faf commit d1d8ebe

File tree

13 files changed

+20
-20
lines changed

13 files changed

+20
-20
lines changed

ext/grid.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function vizgridfallback!(plot, M, pdim, edim)
6363
# decide whether or not to reverse connectivity list
6464
rfunc = Makie.@lift _reverse($grid)
6565

66-
verts = Makie.@lift map(asmakie, vertices($grid))
66+
verts = Makie.@lift map(asmakie, eachvertex($grid))
6767
quads = Makie.@lift [GB.QuadFace($rfunc(indices(e))) for e in elements(topology($grid))]
6868

6969
dims = Makie.@lift size($grid)

ext/mesh.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function vizmesh!(plot, ::Type{<:𝔼}, ::Val{2}, ::Val)
6464
dim = embeddim($mesh)
6565
nvert = nvertices($mesh)
6666
nelem = nelements($mesh)
67-
verts = vertices($mesh)
67+
verts = eachvertex($mesh)
6868
topo = topology($mesh)
6969
elems = elements(topo)
7070

ext/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ asmakie(multis::AbstractVector{<:Multi}) = mapreduce(m -> asmakie.(parent(m)), v
3434

3535
function asmakie(poly::Polygon)
3636
rs = rings(poly)
37-
outer = [asmakie(p) for p in vertices(first(rs))]
37+
outer = map(asmakie, eachvertex(rs[1]))
3838
if hasholes(poly)
39-
inners = map(i -> [asmakie(p) for p in vertices(rs[i])], 2:length(rs))
39+
inners = map(i -> map(asmakie, eachvertex(rs[i])), 2:length(rs))
4040
Makie.Polygon(outer, inners)
4141
else
4242
Makie.Polygon(outer)

src/boundingboxes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function boundingbox end
1313
# FALLBACKS
1414
# ----------
1515

16-
boundingbox(p::Polytope) = _pboxes(vertices(p))
16+
boundingbox(p::Polytope) = _pboxes(eachvertex(p))
1717

1818
boundingbox(p::Primitive) = boundingbox(boundary(p))
1919

@@ -78,7 +78,7 @@ boundingbox(g::TransformedGrid{<:Any,<:Any,<:OrthoRegularGrid}) = boundingbox(pa
7878
boundingbox(g::TransformedGrid{<:Any,<:Any,<:OrthoRectilinearGrid}) =
7979
boundingbox(parent(g)) |> transform(g) |> boundingbox
8080

81-
boundingbox(m::Mesh) = _pboxes(vertices(m))
81+
boundingbox(m::Mesh) = _pboxes(eachvertex(m))
8282

8383
# ----------------
8484
# IMPLEMENTATIONS

src/discretization.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ function discretize(polygon::Polygon, method::BoundaryTriangulationMethod)
105105

106106
# handle degenerate polygons
107107
if nvertices(cpoly) == 1
108-
v = first(vertices(cpoly))
109-
points = [v, v, v]
108+
points = fill(vertex(cpoly, 1), 3)
110109
connec = [connect((1, 2, 3))]
111110
return SimpleMesh(points, connec)
112111
end

src/domains/meshes.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ function Base.getindex(g::Grid, I::CartesianIndices)
227227
odims = size(g)
228228
cinds = first(I):CartesianIndex(Tuple(last(I)) .+ 1)
229229
inds = vec(LinearIndices(odims .+ 1)[cinds])
230+
points = [vertex(g, ind) for ind in inds]
230231
periodic = isperiodic(topology(g)) .&& dims .== odims
231-
SimpleMesh(vertices(g)[inds], GridTopology(dims, periodic))
232+
SimpleMesh(points, GridTopology(dims, periodic))
232233
end
233234

234235
_asrange(::Int, r::UnitRange{Int}) = r

src/domains/meshes/transformedmesh.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct TransformedMesh{M<:Manifold,C<:CRS,TP<:Topology,MS<:Mesh,TR<:Transform} <
1818
end
1919

2020
function TransformedMesh(m::Mesh, t::Transform)
21-
p = t(first(vertices(m)))
21+
p = t(vertex(m, 1))
2222
TransformedMesh{manifold(p),crs(p)}(m, t)
2323
end
2424

src/hulls.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function convexhull end
3838
# FALLBACKS
3939
# ----------
4040

41-
convexhull(p::Polytope) = _pconvexhull(vertices(p))
41+
convexhull(p::Polytope) = _pconvexhull(eachvertex(p))
4242

4343
convexhull(p::Primitive) = convexhull(boundary(p))
4444

@@ -62,7 +62,7 @@ convexhull(t::Triangle) = t
6262

6363
convexhull(g::Grid) = Box(extrema(g)...)
6464

65-
convexhull(m::Mesh) = _pconvexhull(vertices(m))
65+
convexhull(m::Mesh) = _pconvexhull(eachvertex(m))
6666

6767
# ----------------
6868
# IMPLEMENTATIONS

src/pointification.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function pointify end
1616

1717
pointify(p::Primitive) = pointify(boundary(p))
1818

19-
pointify(p::Polytope) = collect(vertices(p))
19+
pointify(p::Polytope) = collect(eachvertex(p))
2020

2121
pointify(m::Multi) = pointify(parent(m))
2222

src/predicates/intersects.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ intersects(s::Segment, c::Chain) = intersects(c, s)
6161

6262
intersects(c₁::Chain, c₂::Chain) = intersects(segments(c₁), segments(c₂))
6363

64-
intersects(c::Chain, g::Geometry) = any((g), vertices(c)) || intersects(c, boundary(g))
64+
intersects(c::Chain, g::Geometry) = any((g), eachvertex(c)) || intersects(c, boundary(g))
6565

6666
intersects(g::Geometry, c::Chain) = intersects(c, g)
6767

0 commit comments

Comments
 (0)