Skip to content

Commit 9e9bf34

Browse files
committed
fixes
1 parent e58d235 commit 9e9bf34

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

src/basic_types.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ abstract type AbstractSimplex{Dim,N,T} <: StaticVector{Dim,T} end
2323
return Polytope(P, F)(map(i-> points[i], face.data))
2424
end
2525

26-
@propagate_inbounds function Base.getindex(points::AbstractVector{P}, face::F) where {P<: Vec, F <: AbstractFace}
27-
return map(i-> points[i], face.data)
26+
@propagate_inbounds function Base.getindex(elements::AbstractVector, face::F) where {F <: AbstractFace}
27+
return map(i-> elements[i], face.data)
2828
end
2929

3030
@fixed_vector SimplexFace AbstractSimplexFace

src/meshes.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ function Base.merge(meshes::AbstractVector{<:Mesh})
107107
end
108108
end
109109

110+
function Base.merge(meshes::AbstractVector{T}) where T <: MetaMesh
111+
isempty(meshes) && return T(Point3f[], GLTriangleFace[])
112+
big_mesh = merge(map(Mesh, meshes))
113+
big_meta = deepcopy(meta(meshes[1]))
114+
for mesh in Iterators.drop(meshes, 1)
115+
mm = meta(mesh)
116+
for (k, v) in pairs(mm)
117+
append!(big_meta[k], v)
118+
end
119+
end
120+
return MetaMesh(big_mesh, big_meta)
121+
end
122+
123+
110124
function map_coordinates(f, mesh::Mesh)
111125
result = copy(mesh)
112126
map_coordinates!(f, result)

src/offsetintegers.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ OffsetInteger type mainly for indexing.
55
* `O` - The offset relative to Julia arrays. This helps reduce copying when
66
communicating with 0-indexed systems such as OpenGL.
77
"""
8-
struct OffsetInteger{O,T<:Integer}
8+
struct OffsetInteger{O,T<:Integer} <: Integer
99
i::T
1010
OffsetInteger{O,T}(x::Integer) where {O,T<:Integer} = new{O,T}(T(x + O))
1111
end
@@ -82,3 +82,13 @@ for op in (:(==), :(>=), :(<=), :(<), :(>), :sub_with_overflow)
8282
Base.$op(x::Integer, y::OffsetInteger) = $op(x, value(y))
8383
end
8484
end
85+
86+
Base.promote_rule(::Type{IT}, ::Type{<:OffsetInteger}) where {IT<:Integer} = IT
87+
88+
function Base.promote_rule(::Type{OffsetInteger{O1,T1}},
89+
::Type{OffsetInteger{O2,T2}}) where {O1,O2,T1<:Integer,
90+
T2<:Integer}
91+
return OffsetInteger{pure_max(O1, O2),promote_type(T1, T2)}
92+
end
93+
94+
Base.@pure pure_max(x1, x2) = x1 > x2 ? x1 : x2

src/viewtypes.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ function TupleView{N,M}(x::AbstractVector{T}; connect=false) where {T,N,M}
5656
return TupleView{NTuple{N,T},N,M,typeof(x)}(x, connect)
5757
end
5858

59-
function connected_line(points::AbstractVector{<:Point{N}},
60-
skip=N) where {N}
61-
return connect(points, Line, skip)
62-
end
63-
6459
"""
6560
connect(points::AbstractVector{<: Point}, P::Type{<: Polytope{N}}, skip::Int = N)
6661
@@ -83,7 +78,7 @@ end
8378

8479
function connect(indices::AbstractVector{T}, P::Type{<:AbstractFace{N}},
8580
skip::Int=N) where {T <: Integer, N}
86-
return map(Face(P, T), TupleView{N, skip}(indices))
81+
return collect(reinterpret(Face(P, T), TupleView{N, skip}(indices)))
8782
end
8883

8984
function connect(points::AbstractMatrix{T}, P::Type{<:Point{N}}) where {T <: Real, N}

0 commit comments

Comments
 (0)