Skip to content

Commit 3cdb91f

Browse files
authored
Merge pull request #177 from JuliaGeometry/sjk/aqua1
Add Aqua
2 parents 92755fc + 18f8b60 commit 3cdb91f

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
@@ -12,16 +12,18 @@ StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
1212
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
1313

1414
[compat]
15+
EarCut_jll = "2"
1516
IterTools = "1.3.0"
1617
StaticArrays = "0.12, 1.0"
1718
StructArrays = "0.6"
1819
Tables = "0.2, 1"
1920
julia = "1.3"
2021

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

2628
[targets]
27-
test = ["Test", "Random", "OffsetArrays"]
29+
test = ["Aqua", "Test", "Random", "OffsetArrays"]

src/GeometryBasics.jl

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

5151
# all the different predefined mesh types
@@ -60,11 +60,11 @@ export NormalUVWMesh, GLNormalUVWMesh, GLNormalUVWMesh2D, GLNormalUVWMesh3D
6060
export triangle_mesh, triangle_mesh, uv_mesh
6161
export uv_mesh, normal_mesh, uv_normal_mesh
6262

63-
export height, origin, radius, width, widths, xwidth, yheight
63+
export height, origin, radius, width, widths
6464
export HyperSphere, Circle, Sphere
6565
export Cylinder, Cylinder2, Cylinder3, Pyramid, extremity
6666
export HyperRectangle, Rect, Rect2, Rect3, Recti, Rect2i, Rect3i, Rectf, Rect2f, Rect3f
67-
export before, during, isinside, isoutside, meets, overlaps, intersects, finishes
67+
export before, during, meets, overlaps, intersects, finishes
6868
export centered, direction, area, volume, update
6969
export max_dist_dim, max_euclidean, max_euclideansq, min_dist_dim, min_euclidean
7070
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.
@@ -63,9 +63,10 @@ end
6363

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

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

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

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

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

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

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

150151
coordinates(x::Simplex) = x.points
151152

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

157159
# 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
@@ -715,4 +715,9 @@ end
715715
include("fixed_arrays.jl")
716716
end
717717

718+
using Aqua
719+
# Aqua tests
720+
# Intervals brings a bunch of ambiquities unfortunately
721+
Aqua.test_all(GeometryBasics; ambiguities=false)
722+
718723
end # testset "GeometryBasics"

0 commit comments

Comments
 (0)