-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PolyhedralGeometry: restrict signature of visualize, add visualize(Su…
…bdivisionOfPoints) (#2863) Co-authored-by: Lars Göttgens <[email protected]>
- Loading branch information
Showing
2 changed files
with
27 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,39 @@ | ||
@doc raw""" | ||
visualize(P::Union{Polyhedron{T}, Cone{T}, PolyhedralFan{T}, PolyhedralComplex{T}}) where T<:Union{QQFieldElem, Float64} | ||
visualize(P::Union{Polyhedron{T}, Cone{T}, PolyhedralFan{T}, PolyhedralComplex{T}, SubdivisionOfPoints{T}}) where T<:Union{QQFieldElem, Float64} | ||
Visualize a polyhedral object of dimension at most four (in 3-space). | ||
In dimensions up to 3 a usual embedding is shown. | ||
Four-dimensional polytopes are visualized as a Schlegel diagram, which is a projection onto one of the facets; e.g., see Chapter 5 of [Zie95](@cite). | ||
In higher dimensions there is no standard method; use projections to lower dimensions or try ideas from [GJRW10](@cite). | ||
""" | ||
function visualize(P::PolyhedralObject{T}) where T<:Union{QQFieldElem, Float64} | ||
function visualize(P::Union{Polyhedron{T}, Cone{T}, PolyhedralFan{T}, PolyhedralComplex{T}}) where T<:Union{QQFieldElem, Float64} | ||
d = ambient_dim(P) | ||
b = P isa Polyhedron | ||
if d < 4 || (d == 4 && b && dim(P) == 4) | ||
# polymake will by default use 0:n-1 as ray labels so we assign labels | ||
# starting from 1 here if there are no labels yet | ||
# (note: labels are mutable, i.e. they can be changed again later) | ||
if !Polymake.exists(pm_object(P), "RAY_LABELS") | ||
pm_object(P).RAY_LABELS = string.(1:Oscar.pm_object(P).N_RAYS) | ||
end | ||
pmo = pm_object(P) | ||
Polymake.visual(pmo) | ||
if b && d == 4 | ||
@req is_fulldimensional(P) "Can only visualize full-dimensional $(typeof(P)) of ambient dimension $d" | ||
else | ||
d == 4 && b && throw(ArgumentError("Can only visualize full-dimensional $(typeof(P)) of ambient dimension $d")) | ||
throw(ArgumentError("Can not visualize $(typeof(P)) of ambient dimension $d. Supported range: 1 <= d <= $(3 + b)")) | ||
@req d < 4 "Can not visualize $(typeof(P)) of ambient dimension $d. Supported range: 1 <= d <= $(3 + b)" | ||
end | ||
# polymake will by default use 0:n-1 as ray labels so we assign labels | ||
# starting from 1 here if there are no labels yet | ||
# (note: labels are mutable, i.e. they can be changed again later) | ||
if !Polymake.exists(pm_object(P), "RAY_LABELS") | ||
pm_object(P).RAY_LABELS = string.(1:Oscar.pm_object(P).N_RAYS) | ||
end | ||
pmo = pm_object(P) | ||
Polymake.visual(pmo) | ||
end | ||
|
||
function visualize(P::SubdivisionOfPoints{T}) where T<:Union{QQFieldElem, Float64} | ||
d = ambient_dim(P) | ||
@req d <= 3 "Can not visualize $(typeof(P)) of ambient dimension $d. Supported range: 1 <= d <= 3" | ||
# polymake will by default use 0:n-1 as labels so we assign labels | ||
# starting from 1 here if there are no labels yet | ||
# (note: labels are mutable, i.e. they can be changed again later) | ||
if !Polymake.exists(pm_object(P), "POINT_LABELS") | ||
pm_object(P).POINT_LABELS = string.(1:Oscar.pm_object(P).N_POINTS) | ||
end | ||
pmo = pm_object(P) | ||
Polymake.visual(pmo) | ||
end |