@@ -20,26 +20,6 @@ abstract type AbstractNgonFace{N, T} <: AbstractFace{N, T} end
20
20
21
21
abstract type AbstractSimplex{Dim, N, T} <: StaticVector{Dim, T} end
22
22
23
- """
24
- coordinates(geometry)
25
- Returns the edges/vertices/coordinates of a geometry. Is allowed to return lazy iterators!
26
- Use `decompose(ConcretePointType, geometry)` to get `Vector{ConcretePointType}` with
27
- `ConcretePointType` to be something like `Point{3, Float32}`.
28
- """
29
- function coordinates (points:: AbstractVector{<:AbstractPoint} )
30
- return points
31
- end
32
-
33
- """
34
- faces(geometry)
35
- Returns the face connections of a geometry. Is allowed to return lazy iterators!
36
- Use `decompose(ConcreteFaceType, geometry)` to get `Vector{ConcreteFaceType}` with
37
- `ConcreteFaceType` to be something like `TriangleFace{Int}`.
38
- """
39
- function faces (f:: AbstractVector{<:AbstractFace} )
40
- return f
41
- end
42
-
43
23
"""
44
24
Face index, connecting points to form a simplex
45
25
"""
@@ -57,7 +37,9 @@ const LineFace{T} = NgonFace{2, T}
57
37
const TriangleFace{T} = NgonFace{3 , T}
58
38
const QuadFace{T} = NgonFace{4 , T}
59
39
60
- Base. show (io:: IO , x:: TriangleFace{T} ) where T = print (io, " TriangleFace(" , join (x, " , " ), " )" )
40
+ function Base. show (io:: IO , x:: TriangleFace{T} ) where T
41
+ print (io, " TriangleFace(" , join (x, " , " ), " )" )
42
+ end
61
43
62
44
Face (:: Type{<: NgonFace{N}} , :: Type{T} ) where {N, T} = NgonFace{N, T}
63
45
Face (F:: Type{NgonFace{N, FT}} , :: Type{T} ) where {FT, N, T} = F
@@ -100,14 +82,14 @@ Base.length(::NNgon{N}) where N = N
100
82
The Ngon Polytope element type when indexing an array of points with a SimplexFace
101
83
"""
102
84
function Polytope (P:: Type{<: AbstractPoint{Dim, T}} , :: Type{<: AbstractNgonFace{N, IT}} ) where {N, Dim, T, IT}
103
- Ngon{Dim, T, N, P}
85
+ return Ngon{Dim, T, N, P}
104
86
end
105
87
106
88
"""
107
89
The fully concrete Ngon type, when constructed from a point type!
108
90
"""
109
91
function Polytope (:: Type{<: NNgon{N}} , P:: Type{<: AbstractPoint{NDim, T}} ) where {N, NDim, T}
110
- Ngon{NDim, T, N, P}
92
+ return Ngon{NDim, T, N, P}
111
93
end
112
94
113
95
@@ -157,11 +139,10 @@ const Tetrahedron{T} = TetrahedronP{T, Point{3, T}}
157
139
158
140
Base. show (io:: IO , x:: TetrahedronP ) = print (io, " Tetrahedron(" , join (x, " , " ), " )" )
159
141
160
-
161
142
coordinates (x:: Simplex ) = x. points
162
143
163
144
function (:: Type{<: NSimplex{N}} )(points:: Vararg{P, N} ) where {P <: AbstractPoint{Dim, T} , N} where {Dim, T}
164
- Simplex {Dim, T, N, P} (SVector (points))
145
+ return Simplex {Dim, T, N, P} (SVector (points))
165
146
end
166
147
167
148
# Base Array interface
@@ -172,14 +153,14 @@ Base.length(::NSimplex{N}) where N = N
172
153
The Simplex Polytope element type when indexing an array of points with a SimplexFace
173
154
"""
174
155
function Polytope (P:: Type{<: AbstractPoint{Dim, T}} , :: Type{<: AbstractSimplexFace{N}} ) where {N, Dim, T}
175
- Simplex{Dim, T, N, P}
156
+ return Simplex{Dim, T, N, P}
176
157
end
177
158
178
159
"""
179
160
The fully concrete Simplex type, when constructed from a point type!
180
161
"""
181
162
function Polytope (:: Type{<: NSimplex{N}} , P:: Type{<: AbstractPoint{NDim, T}} ) where {N, NDim, T}
182
- Simplex{NDim, T, N, P}
163
+ return Simplex{NDim, T, N, P}
183
164
end
184
165
Base. show (io:: IO , x:: LineP ) = print (io, " Line(" , x[1 ], " => " , x[2 ], " )" )
185
166
@@ -193,13 +174,14 @@ struct LineString{
193
174
} <: AbstractVector{LineP{Dim, T, P}}
194
175
points:: V
195
176
end
177
+
196
178
coordinates (x:: LineString ) = x. points
197
179
198
180
Base. size (x:: LineString ) = size (coordinates (x))
199
181
Base. getindex (x:: LineString , i) = getindex (coordinates (x), i)
200
182
201
183
function LineString (points:: AbstractVector{LineP{Dim, T, P}} ) where {Dim, T, P}
202
- LineString {Dim, T, P, typeof(points)} (points)
184
+ return LineString {Dim, T, P, typeof(points)} (points)
203
185
end
204
186
205
187
"""
@@ -214,15 +196,15 @@ linestring = LineString(points)
214
196
```
215
197
"""
216
198
function LineString (points:: AbstractVector{<: AbstractPoint} , skip = 1 )
217
- LineString (connect (points, LineP, skip))
199
+ return LineString (connect (points, LineP, skip))
218
200
end
219
201
220
202
function LineString (points:: AbstractVector{<: Pair{P, P}} ) where P <: AbstractPoint{N, T} where {N, T}
221
- LineString (reinterpret (LineP{N, T, P}, points))
203
+ return LineString (reinterpret (LineP{N, T, P}, points))
222
204
end
223
205
224
206
function LineString (points:: AbstractVector{<: AbstractPoint} , faces:: AbstractVector{<: LineFace} )
225
- LineString (connect (points, faces))
207
+ return LineString (connect (points, faces))
226
208
end
227
209
228
210
"""
@@ -246,7 +228,7 @@ linestring = LineString(points, faces, 2)
246
228
"""
247
229
function LineString (points:: AbstractVector{<: AbstractPoint} , indices:: AbstractVector{<: Integer} , skip = 1 )
248
230
faces = connect (indices, LineFace, skip)
249
- LineString (points, faces)
231
+ return LineString (points, faces)
250
232
end
251
233
252
234
struct Polygon{
@@ -262,21 +244,21 @@ end
262
244
Base.:(== )(a:: Polygon , b:: Polygon ) = (a. exterior == b. exterior) && (a. interiors == b. interiors)
263
245
264
246
function Polygon (exterior:: E , interiors:: AbstractVector{E} ) where E <: AbstractVector{LineP{Dim, T, P}} where {Dim, T, P}
265
- Polygon {Dim, T, P, typeof(exterior), typeof(interiors)} (exterior, interiors)
247
+ return Polygon {Dim, T, P, typeof(exterior), typeof(interiors)} (exterior, interiors)
266
248
end
267
249
268
250
Polygon (exterior:: L ) where L <: AbstractVector{<: LineP} = Polygon (exterior, L[])
269
251
270
252
function Polygon (exterior:: AbstractVector{P} , skip:: Int = 1 ) where P <: AbstractPoint{Dim, T} where {Dim, T}
271
- Polygon (LineString (exterior, skip))
253
+ return Polygon (LineString (exterior, skip))
272
254
end
273
255
274
256
function Polygon (exterior:: AbstractVector{P} , faces:: AbstractVector{<: Integer} , skip:: Int = 1 ) where P <: AbstractPoint{Dim, T} where {Dim, T}
275
- Polygon (LineString (exterior, faces, skip))
257
+ return Polygon (LineString (exterior, faces, skip))
276
258
end
277
259
278
260
function Polygon (exterior:: AbstractVector{P} , faces:: AbstractVector{<: LineFace} ) where P <: AbstractPoint{Dim, T} where {Dim, T}
279
- Polygon (LineString (exterior, faces))
261
+ return Polygon (LineString (exterior, faces))
280
262
end
281
263
282
264
@@ -290,7 +272,7 @@ struct MultiPolygon{
290
272
end
291
273
292
274
function MultiPolygon (polygons:: AbstractVector{P} ; kw... ) where P <: AbstractPolygon{Dim, T} where {Dim, T}
293
- MultiPolygon (meta (polygons; kw... ))
275
+ return MultiPolygon (meta (polygons; kw... ))
294
276
end
295
277
296
278
Base. getindex (mp:: MultiPolygon , i) = mp. polygons[i]
@@ -306,7 +288,7 @@ struct MultiLineString{
306
288
end
307
289
308
290
function MultiLineString (linestrings:: AbstractVector{L} ; kw... ) where L <: AbstractVector{LineP{Dim, T, P}} where {Dim, T, P}
309
- MultiLineString (meta (linestrings; kw... ))
291
+ return MultiLineString (meta (linestrings; kw... ))
310
292
end
311
293
312
294
Base. getindex (ms:: MultiLineString , i) = ms. linestrings[i]
@@ -342,7 +324,7 @@ const AbstractMesh{Element} = AbstractVector{Element}
342
324
The conrecte AbstractMesh implementation
343
325
"""
344
326
struct Mesh{
345
- Dim, T <: Real ,
327
+ Dim, T <: Number ,
346
328
Element <: Polytope{Dim, T} ,
347
329
V <: AbstractVector{Element}
348
330
} <: AbstractMesh{Element}
0 commit comments