Skip to content

Commit 2607b42

Browse files
authored
Merge branch 'master' into feat/geointerface-traits
2 parents b28b9a4 + 3cdb91f commit 2607b42

File tree

6 files changed

+29
-20
lines changed

6 files changed

+29
-20
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
1313
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
1414

1515
[compat]
16+
EarCut_jll = "2"
1617
IterTools = "1.3.0"
1718
StaticArrays = "0.12, 1.0"
1819
StructArrays = "0.6"
1920
Tables = "0.2, 1"
2021
julia = "1.6"
2122

2223
[extras]
24+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
2325
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
2426
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2527
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2628

2729
[targets]
28-
test = ["Test", "Random", "OffsetArrays"]
30+
test = ["Aqua", "Test", "Random", "OffsetArrays"]

src/GeometryBasics.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ export PolygonMeta, MultiPointMeta, MultiLineStringMeta, MeshMeta, LineStringMet
4545
export decompose, coordinates, faces, normals, decompose_uv, decompose_normals,
4646
texturecoordinates
4747
export Tesselation, pointmeta, Normal, UV, UVW
48-
export GLTriangleFace, GLNormalMesh3D, GLPlainTriangleMesh, GLUVMesh3D, GLUVNormalMesh3D
48+
export GLTriangleFace, GLUVMesh3D
4949
export AbstractMesh, Mesh, TriangleMesh
50-
export GLNormalMesh2D, PlainTriangleMesh
50+
export GLNormalMesh2D
5151
export MetaT, meta_table
5252

5353
# all the different predefined mesh types
@@ -62,11 +62,11 @@ export NormalUVWMesh, GLNormalUVWMesh, GLNormalUVWMesh2D, GLNormalUVWMesh3D
6262
export triangle_mesh, triangle_mesh, uv_mesh
6363
export uv_mesh, normal_mesh, uv_normal_mesh
6464

65-
export height, origin, radius, width, widths, xwidth, yheight
65+
export height, origin, radius, width, widths
6666
export HyperSphere, Circle, Sphere
6767
export Cylinder, Cylinder2, Cylinder3, Pyramid, extremity
6868
export HyperRectangle, Rect, Rect2, Rect3, Recti, Rect2i, Rect3i, Rectf, Rect2f, Rect3f
69-
export before, during, isinside, isoutside, meets, overlaps, intersects, finishes
69+
export before, during, meets, overlaps, intersects, finishes
7070
export centered, direction, area, volume, update
7171
export max_dist_dim, max_euclidean, max_euclideansq, min_dist_dim, min_euclidean
7272
export min_euclideansq, minmax_dist_dim, minmax_euclidean, minmax_euclideansq

src/basic_types.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Abstract Geometry in R{Dim} with Number type T
33
"""
44
abstract type AbstractGeometry{Dim,T<:Number} end
55
abstract type GeometryPrimitive{Dim,T} <: AbstractGeometry{Dim,T} end
6-
Base.ndims(x::AbstractGeometry{Dim}) where {Dim} = Dim
6+
Base.ndims(::AbstractGeometry{Dim}) where {Dim} = Dim
77

88
"""
99
Geometry made of N connected points. Connected as one flat geometry, it makes a Ngon / Polygon.
@@ -62,9 +62,10 @@ end
6262

6363
const NNgon{N} = Ngon{Dim,T,N,P} where {Dim,T,P}
6464

65-
function (::Type{<:NNgon{N}})(points::Vararg{P,N}) where {P<:AbstractPoint{Dim,T},
66-
N} where {Dim,T}
67-
return Ngon{Dim,T,N,P}(SVector(points))
65+
function (::Type{<:NNgon{N1}})(p0::P, points::Vararg{P,N2}) where {P<:AbstractPoint{Dim,T},
66+
N1, N2} where {Dim,T}
67+
@assert N1 == N2+1
68+
return Ngon{Dim,T,N1,P}(SVector(p0, points...))
6869
end
6970
Base.show(io::IO, x::NNgon{N}) where {N} = print(io, "Ngon{$N}(", join(x, ", "), ")")
7071

@@ -100,12 +101,12 @@ const Triangle{Dim,T} = TriangleP{Dim,T,Point{Dim,T}}
100101
const Triangle3d{T} = Triangle{3,T}
101102

102103
Base.show(io::IO, x::TriangleP) = print(io, "Triangle(", join(x, ", "), ")")
103-
Base.summary(io::IO, x::Type{<:TriangleP}) = print(io, "Triangle")
104+
Base.summary(io::IO, ::Type{<:TriangleP}) = print(io, "Triangle")
104105

105106
const Quadrilateral{Dim,T} = Ngon{Dim,T,4,P} where {P<:AbstractPoint{Dim,T}}
106107

107108
Base.show(io::IO, x::Quadrilateral) = print(io, "Quad(", join(x, ", "), ")")
108-
Base.summary(io::IO, x::Type{<:Quadrilateral}) = print(io, "Quad")
109+
Base.summary(io::IO, ::Type{<:Quadrilateral}) = print(io, "Quad")
109110

110111
function coordinates(lines::AbstractArray{LineP{Dim,T,PointType}}) where {Dim,T,PointType}
111112
return if lines isa Base.ReinterpretArray
@@ -147,9 +148,10 @@ Base.show(io::IO, x::TetrahedronP) = print(io, "Tetrahedron(", join(x, ", "), ")
147148

148149
coordinates(x::Simplex) = x.points
149150

150-
function (::Type{<:NSimplex{N}})(points::Vararg{P,N}) where {P<:AbstractPoint{Dim,T},
151-
N} where {Dim,T}
152-
return Simplex{Dim,T,N,P}(SVector(points))
151+
function (::Type{<:NSimplex{N1}})(p0::P, points::Vararg{P,N2}) where {P<:AbstractPoint{Dim,T},
152+
N1, N2} where {Dim,T}
153+
@assert N1 == N2+1
154+
return Simplex{Dim,T,N1,P}(SVector(p0, points...))
153155
end
154156

155157
# Base Array interface

src/meshes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ end
206206
Calculate the signed volume of one tetrahedron. Be sure the orientation of your
207207
surface is right.
208208
"""
209-
function volume(triangle::Triangle) where {VT,FT}
209+
function volume(triangle::Triangle)
210210
v1, v2, v3 = triangle
211211
sig = sign(orthogonal_vector(v1, v2, v3) v1)
212212
return sig * abs(v1 (v2 × v3)) / 6
@@ -218,7 +218,7 @@ end
218218
Calculate the signed volume of all tetrahedra. Be sure the orientation of your
219219
surface is right.
220220
"""
221-
function volume(mesh::Mesh) where {VT,FT}
221+
function volume(mesh::Mesh)
222222
return sum(volume, mesh)
223223
end
224224

src/primitives/rectangles.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ function Rect(v1::Vec{N,T1}, v2::Vec{N,T2}) where {N,T1,T2}
4848
return Rect{N,T}(Vec{N,T}(v1), Vec{N,T}(v2))
4949
end
5050

51-
function RectT{T}(v1::VecTypes{N,T1}, v2::VecTypes{N,T2}) where {N,T,T1,T2}
51+
function RectT{T}(v1::VecTypes{N}, v2::VecTypes{N}) where {N,T}
5252
return if T <: Integer
5353
Rect{N,T}(round.(T, v1), round.(T, v2))
5454
else
5555
return Rect{N,T}(Vec{N,T}(v1), Vec{N,T}(v2))
5656
end
5757
end
5858

59-
function Rect{N}(v1::VecTypes{N,T1}, v2::VecTypes{N,T2}) where {N,T1,T2}
60-
T = promote_type(T1, T2)
59+
function Rect{N}(v1::VecTypes{N}, v2::VecTypes{N}) where {N}
60+
T = promote_type(eltype(v1), eltype(v2))
6161
return Rect{N,T}(Vec{N,T}(v1), Vec{N,T}(v2))
6262
end
6363

@@ -512,7 +512,7 @@ Base.isequal(b1::Rect, b2::Rect) = b1 == b2
512512

513513
centered(R::Type{Rect{N,T}}) where {N,T} = R(Vec{N,T}(-0.5), Vec{N,T}(1))
514514
centered(R::Type{Rect{N}}) where {N} = R(Vec{N,Float32}(-0.5), Vec{N,Float32}(1))
515-
centered(R::Type{Rect}) where {N} = R(Vec{2,Float32}(-0.5), Vec{2,Float32}(1))
515+
centered(R::Type{Rect}) = R(Vec{2,Float32}(-0.5), Vec{2,Float32}(1))
516516

517517
##
518518
# Rect2 decomposition

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,4 +720,9 @@ end
720720
include("geointerface.jl")
721721
end
722722

723+
using Aqua
724+
# Aqua tests
725+
# Intervals brings a bunch of ambiquities unfortunately
726+
Aqua.test_all(GeometryBasics; ambiguities=false)
727+
723728
end # testset "GeometryBasics"

0 commit comments

Comments
 (0)