Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make delaunay and triangulate a default symbol #3804

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Initialization/init_Polyhedra.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import .Polyhedra: polyhedron
export polyhedron, triangulate
export polyhedron
using .Polyhedra: HRep, VRep,
removehredundancy!, removevredundancy!

Expand Down
17 changes: 12 additions & 5 deletions src/Interfaces/LazySet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export LazySet,
singleton_list,
chebyshev_center_radius,
○,
flatten
flatten,
delaunay,
triangulate

"""
LazySet{N}
Expand Down Expand Up @@ -126,6 +128,14 @@ Zonotope
"""
abstract type LazySet{N} end

function delaunay(X)
require(@__MODULE__, :MiniQhull, fun_name="delaunay")
end

function triangulate(X)
require(@__MODULE__, :Polyhedra, fun_name="triangulate")
end

"""
○(c, a)

Expand Down Expand Up @@ -1057,9 +1067,6 @@ end

function load_delaunay_MiniQhull()
return quote
import .MiniQhull: delaunay
export delaunay

"""
delaunay(X::LazySet)

Expand Down Expand Up @@ -1109,7 +1116,7 @@ function load_delaunay_MiniQhull()
m = length(vlist)
coordinates = vcat(vlist...)
flags = compute_triangles_3d ? "qhull Qt" : nothing
connectivity_matrix = delaunay(n, m, coordinates, flags)
connectivity_matrix = MiniQhull.delaunay(n, m, coordinates, flags)
return vlist, connectivity_matrix
end
end
Expand Down
3 changes: 2 additions & 1 deletion src/Sets/EmptySet/EmptySetModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using ReachabilityBase.Require: require
cartesian_product, convex_hull, difference, distance,
intersection, ≈, isdisjoint, ⊆, linear_combination,
minkowski_difference, minkowski_sum
@reexport import ..LazySets: chebyshev_center_radius, rationalize
@reexport import ..LazySets: chebyshev_center_radius, delaunay, rationalize
import ..LazySets: plot_recipe
import Base: convert, copy
@reexport using ..API
Expand All @@ -31,6 +31,7 @@ include("EmptySet.jl")
include("an_element.jl")
include("area.jl")
include("complement.jl")
include("delaunay.jl")
include("diameter.jl")
include("dim.jl")
include("high.jl")
Expand Down
3 changes: 3 additions & 0 deletions src/Sets/EmptySet/delaunay.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function delaunay(::EmptySet)
throw(ArgumentError("cannot compute a Delaunay triangulation for an empty set"))
end
5 changes: 3 additions & 2 deletions src/Sets/Universe/UniverseModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ using ReachabilityBase.Require: require
isoperationtype, isuniversal, norm, radius, rand,
reflect, ∈, permute, project, scale, scale!, ρ, σ,
translate, translate!, cartesian_product, intersection
@reexport import ..LazySets: constrained_dimensions, linear_map_inverse,
rationalize, tosimplehrep
@reexport import ..LazySets: constrained_dimensions, delaunay,
linear_map_inverse, rationalize, tosimplehrep
import Base: copy
@reexport using ..API

Expand All @@ -27,6 +27,7 @@ include("complement.jl")
include("constraints.jl")
include("constraints_list.jl")
include("copy.jl")
include("delaunay.jl")
include("diameter.jl")
include("dim.jl")
include("isbounded.jl")
Expand Down
3 changes: 3 additions & 0 deletions src/Sets/Universe/delaunay.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function delaunay(::Universe)
throw(ArgumentError("cannot compute a Delaunay triangulation for a universal set"))
end
4 changes: 1 addition & 3 deletions test/Sets/EmptySet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ for N in [Float64, Float32, Rational{Int}]
@test isidentical(E, E2)

# delaunay
if isdefined(@__MODULE__, :MiniQhull) # TODO this should throw a normal error without MiniQhull
@test_broken delaunay(E)
end
@test_throws ArgumentError delaunay(E)

# diameter
@test_throws ArgumentError diameter(E) # TODO this should maybe change
Expand Down
4 changes: 1 addition & 3 deletions test/Sets/Universe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ for N in [Float64, Float32, Rational{Int}]
@test isidentical(U, U2)

# delaunay
if isdefined(@__MODULE__, :MiniQhull) # TODO throwing an error should work without MiniQhull
@test_throws ArgumentError delaunay(U)
end
@test_throws ArgumentError delaunay(U)

# diameter
@test_throws ErrorException diameter(U) # TODO this should become an ArgumentError
Expand Down
Loading