Skip to content

Commit e67ba47

Browse files
committed
improvements
1 parent 263bce4 commit e67ba47

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

src/basic_types.jl

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Face index, connecting points to form a simplex
2929

3030
@fixed_vector SimplexFace AbstractSimplexFace
3131
const LineFace{T} = SimplexFace{2, T}
32-
Base.show(io::IO, x::Type{<: LineFace{T}}) where T = print(io, "LineFace{", T, "}")
3332
Face(::Type{<: SimplexFace{N}}, ::Type{T}) where {N, T} = SimplexFace{N, T}
3433

3534

@@ -40,7 +39,11 @@ Face index, connecting points to form an Ngon
4039

4140
@fixed_vector NgonFace AbstractNgonFace
4241
const TriangleFace{T} = NgonFace{3, T}
43-
Base.show(io::IO, x::Type{<: TriangleFace{T}}) where T = print(io, "TriangleFace{", T, "}")
42+
43+
const QuadFace{T} = NgonFace{4, T}
44+
45+
Base.show(io::IO, x::TriangleFace{T}) where T = print(io, "TriangleFace(", join(x, ", "), ")")
46+
4447
Face(::Type{<: NgonFace{N}}, ::Type{T}) where {N, T} = NgonFace{N, T}
4548

4649
@propagate_inbounds Base.getindex(x::Polytope, i::Integer) = coordinates(x)[i]
@@ -93,14 +96,9 @@ end
9396
# Since Ngon is supposed to be flat and a triangle is flat, lets prefer Ngon
9497
# for triangle:
9598
const TriangleP{Dim, T, P <: AbstractPoint{Dim, T}} = Ngon{Dim, T, 3, P}
96-
9799
const Triangle{Dim, T} = TriangleP{Dim, T, Point{Dim, T}}
98100
const Triangle3d{T} = Triangle{3, T}
99101

100-
function Base.show(io::IO, ::Type{TriangleP{D, T, P}}) where {D, T, P}
101-
print(io, "Tetrahedron{", D, ", ", T, "}")
102-
end
103-
Base.show(io::IO, ::Type{Triangle}) = print(io, "Triangle")
104102
Base.show(io::IO, x::TriangleP) = print(io, "Triangle(", join(x, ", "), ")")
105103

106104
const Quadrilateral{Dim, T} = Ngon{Dim, T, 4, P} where P <: AbstractPoint{Dim, T}
@@ -136,14 +134,11 @@ const Line{Dim, T} = LineP{Dim, T, Point{Dim, T}}
136134
const TetrahedronP{T, P <: AbstractPoint{3, T}} = Simplex{3, T, 4, P}
137135
const Tetrahedron{T} = TetrahedronP{T, Point{3, T}}
138136

139-
function Base.show(io::IO, ::Type{TetrahedronP{T, P}}) where {T, P}
140-
print(io, "Tetrahedron{", T, "}")
141-
end
142-
Base.show(io::IO, ::Type{Tetrahedron}) = print(io, "Tetrahedron")
143137
Base.show(io::IO, x::TetrahedronP) = print(io, "Tetrahedron(", join(x, ", "), ")")
144138

145139

146140
coordinates(x::Simplex) = x.points
141+
147142
function (::Type{<: NSimplex{N}})(points::Vararg{P, N}) where {P <: AbstractPoint{Dim, T}, N} where {Dim, T}
148143
Simplex{Dim, T, N, P}(SVector(points))
149144
end
@@ -165,11 +160,6 @@ The fully concrete Simplex type, when constructed from a point type!
165160
function Polytope(::Type{<: NSimplex{N}}, P::Type{<: AbstractPoint{NDim, T}}) where {N, NDim, T}
166161
Simplex{NDim, T, N, P}
167162
end
168-
169-
function Base.show(io::IO, ::Type{LineP{D, T, P}}) where {D, T, P}
170-
print(io, "Line{", D, ", ", T, "}")
171-
end
172-
Base.show(io::IO, ::Type{Line}) = print(io, "Line")
173163
Base.show(io::IO, x::LineP) = print(io, "Line(", x[1], " => ", x[2], ")")
174164

175165
"""

src/viewtypes.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,17 @@ end
121121
return element
122122
end
123123

124-
125124
function connect(points::AbstractVector{P}, faces::AbstractVector{F}) where {P <: AbstractPoint, F <: AbstractFace}
126125
FaceView{Polytope(P, F), P, F, typeof(points), typeof(faces)}(points, faces)
127126
end
128127

129128

130-
function connect(points::AbstractVector{P}, faces::AbstractVector{<: Integer}, ::Type{F}) where {P <: AbstractPoint, F <: AbstractFace}
131-
FaceView{Polytope(P, F), P, F, typeof(points), typeof(faces)}(points, faces)
129+
130+
const FaceMesh{Dim, T, Element} = Mesh{Dim, T, Element, <: FaceView{Element}}
131+
132+
function coordinates(mesh::FaceMesh)
133+
mesh.simplices.points
134+
end
135+
function faces(mesh::FaceMesh)
136+
mesh.simplices.faces
132137
end

0 commit comments

Comments
 (0)