Render polygon holes in XY for 3D inputs
This commit is contained in:
parent
5f88e02775
commit
1f098fd4ca
2 changed files with 3 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
from numpy import asarray
|
from numpy import asarray
|
||||||
|
from shapely import force_3d
|
||||||
from shapely.geometry import Polygon, box
|
from shapely.geometry import Polygon, box
|
||||||
|
|
||||||
from inire.utils.visualization import plot_routing_results
|
from inire.utils.visualization import plot_routing_results
|
||||||
|
|
@ -7,7 +8,7 @@ from scripts.render_documentation_figures import _polygon
|
||||||
|
|
||||||
|
|
||||||
def test_polygon_holes_remain_unfilled_in_routes_and_documentation() -> None:
|
def test_polygon_holes_remain_unfilled_in_routes_and_documentation() -> None:
|
||||||
keepout = Polygon(box(1, 1, 9, 9).exterior, [box(3, 3, 7, 7).exterior])
|
keepout = force_3d(Polygon(box(1, 1, 9, 9).exterior, [box(3, 3, 7, 7).exterior]), z=1)
|
||||||
figure, route_axes = plot_routing_results({}, [keepout], (0, 0, 10, 10))
|
figure, route_axes = plot_routing_results({}, [keepout], (0, 0, 10, 10))
|
||||||
walkthrough_axes = figure.add_axes((0.6, 0.6, 0.25, 0.25))
|
walkthrough_axes = figure.add_axes((0.6, 0.6, 0.25, 0.25))
|
||||||
_polygon(walkthrough_axes, keepout, fill="gray", edge="black")
|
_polygon(walkthrough_axes, keepout, fill="gray", edge="black")
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ def draw_polygon(ax: Axes, polygon: Polygon, **style: object) -> None:
|
||||||
return
|
return
|
||||||
|
|
||||||
polygon = orient(polygon)
|
polygon = orient(polygon)
|
||||||
paths = [Path(list(ring.coords), closed=True) for ring in (polygon.exterior, *polygon.interiors)]
|
paths = [Path(numpy.column_stack(ring.xy), closed=True) for ring in (polygon.exterior, *polygon.interiors)]
|
||||||
ax.add_patch(PathPatch(Path.make_compound_path(*paths), **style))
|
ax.add_patch(PathPatch(Path.make_compound_path(*paths), **style))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue