/
polyhedron.jl
68 lines (51 loc) · 2.24 KB
/
polyhedron.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Mandatory
export polyhedron, loadpolyhedron!
export hrepiscomputed, hrep, vrepiscomputed, vrep
export volume, surface
"""
polyhedron(rep::Representation{T})
Creates a polyhedron from the representation `rep` using the default library including in the Polyhedra package.
"""
polyhedron(rep::Representation{T}) where {T} = polyhedron(rep, default_library(FullDim(rep), T))
"""
hrepiscomputed(p::Polyhedron)
Returns whether the H-representation of this polyhedron has been computed.
"""
function hrepiscomputed end
"""
hrep(p::Polyhedron)
Returns an H-representation for the polyhedron `p`.
"""
hrep(p::Polyhedron) = error("`hrep` not implemented for `$(eltype(p))`")
"""
vrepiscomputed(p::Polyhedron)
Returns whether the V-representation of this polyhedron has been computed.
"""
function vrepiscomputed end
"""
vrep(p::Polyhedron)
Returns a V-representation for the polyhedron `p`.
"""
vrep(p::Polyhedron) = error("`vrep` not implemented for `$(eltype(p))`")
"""
volume(p::Polyhedron{T}) where {T}
Returns the `fulldim(p)`-dimensional hyper-volume of the polyhedron `p`.
Returns `Inf` or `-one(T)` if it is infinite depending on whether the type `T` has an infinite value.
"""
function volume end
"""
surface(p::Polyhedron{T}) where {T}
Returns the `fulldim(p)-1`-dimensional hyper-volume of the surface of the polyhedron `p`.
Returns `Inf` or `-one(T)` if it is infinite depending on whether the type `T` has an infinite value.
"""
function surface end
loadpolyhedron!(p::Polyhedron, filename::AbstractString, extension::Type{Val{:ine}}) = error("loadpolyhedron! not implemented for .ine")
loadpolyhedron!(p::Polyhedron, filename::AbstractString, extension::Type{Val{:ext}}) = error("loadpolyhedron! not implemented for .ext") # FIXME ExtFileVRepresentation or just ExtFile
loadpolyhedron!(p::Polyhedron, filename::AbstractString, extension::Symbol) = loadpolyhedron!(p, filename, Val{extension})
function loadpolyhedron!(p::Polyhedron, filename::AbstractString, extension::AbstractString)
s = something(findfirst(isequal(extension), ["ext", "ine"]), 0)
if s == 0
error("Invalid extension $extension, please give 'ext' for V-representation or 'ine' for H-representation")
end
loadpolyhedron!(p, filename, [:ext, :ine][s])
end