Skip to content

Commit a307f44

Browse files
committed
2 parents e87aebd + bbc802c commit a307f44

15 files changed

+518
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
* Added `compas_cgal.straight_skeleton_2.create_interior_straight_skeleton`.
13+
* Added `compas_cgal.straight_skeleton_2.create_interior_straight_skeleton_with_holes`.
14+
* Added `compas_cgal.straight_skeleton_2.create_offset_polygons_2_inner`.
15+
* Added `compas_cgal.straight_skeleton_2.create_offset_polygons_2_outer`.
16+
* Added `compas_cgal.straight_skeleton_2.create_weighted_offset_polygons_2_inner`.
17+
* Added `compas_cgal.straight_skeleton_2.create_weighted_offset_polygons_2_outer`.
1318

1419
### Changed
1520

docs/PLACEHOLDER

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/_images/PLACEHOLDER

Lines changed: 0 additions & 1 deletion
This file was deleted.
71.4 KB
Loading
44 KB
Loading
35.6 KB
Loading

docs/api/compas_cgal.straight_skeleton_2.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ compas_cgal.straight_skeleton_2
99
:nosignatures:
1010

1111
create_interior_straight_skeleton
12+
create_interior_straight_skeleton_with_holes

docs/examples/straight_skeleton_2.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,30 @@
99

1010
.. literalinclude:: straight_skeleton_2.py
1111
:language: python
12+
13+
14+
.. figure:: /_images/cgal_straight_skeleton_2_holes.png
15+
:figclass: figure
16+
:class: figure-img img-fluid
17+
18+
19+
.. literalinclude:: straight_skeleton_2_holes.py
20+
:language: python
21+
22+
23+
.. figure:: /_images/cgal_straight_skeleton_2_offset.png
24+
:figclass: figure
25+
:class: figure-img img-fluid
26+
27+
28+
.. literalinclude:: straight_skeleton_2_offset.py
29+
:language: python
30+
31+
32+
.. figure:: /_images/cgal_straight_skeleton_2_offset_weighted.png
33+
:figclass: figure
34+
:class: figure-img img-fluid
35+
36+
37+
.. literalinclude:: straight_skeleton_2_offset_weighted.py
38+
:language: python
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from compas.datastructures import Graph
2+
from compas.geometry import Polygon
3+
from compas_viewer import Viewer
4+
5+
from compas_cgal.straight_skeleton_2 import create_interior_straight_skeleton_with_holes
6+
7+
points = [
8+
(-1.91, 3.59, 0.0),
9+
(-5.53, -5.22, 0.0),
10+
(-0.39, -1.98, 0.0),
11+
(2.98, -5.51, 0.0),
12+
(4.83, -2.02, 0.0),
13+
(9.70, -3.63, 0.0),
14+
(12.23, 1.25, 0.0),
15+
(3.42, 0.66, 0.0),
16+
(2.92, 4.03, 0.0),
17+
(-1.91, 3.59, 0.0),
18+
]
19+
20+
holes = [
21+
[(0.42, 0.88, 0.0), (1.1, -1.0, 0.0), (-1.97, -0.93, 0.0), (-1.25, 1.82, 0.0)],
22+
[(4.25, -0.64, 0.0), (2.9, -3.03, 0.0), (2.12, -2.16, 0.0), (2.89, -0.36, 0.0)],
23+
[(10.6, 0.29, 0.0), (9.48, -1.54, 0.0), (5.48, -1.26, 0.0), (5.98, -0.04, 0.0)],
24+
]
25+
26+
27+
polygon = Polygon(points)
28+
holes = [Polygon(hole) for hole in holes]
29+
lines = create_interior_straight_skeleton_with_holes(polygon, holes)
30+
graph = Graph.from_lines(lines)
31+
32+
# ==============================================================================
33+
# Viz
34+
# ==============================================================================
35+
36+
viewer = Viewer(width=1600, height=900)
37+
viewer.renderer_config.show_grid = False
38+
viewer.scene.add(graph, edgecolor=(1.0, 0.0, 0.0))
39+
viewer.scene.add(polygon)
40+
for hole in holes:
41+
viewer.scene.add(hole)
42+
viewer.show()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from compas.geometry import Polygon
2+
from compas_viewer import Viewer
3+
4+
from compas_cgal.straight_skeleton_2 import create_offset_polygons_2
5+
6+
points = [
7+
(-1.91, 3.59, 0.0),
8+
(-5.53, -5.22, 0.0),
9+
(-0.39, -1.98, 0.0),
10+
(2.98, -5.51, 0.0),
11+
(4.83, -2.02, 0.0),
12+
(9.70, -3.63, 0.0),
13+
(12.23, 1.25, 0.0),
14+
(3.42, 0.66, 0.0),
15+
(2.92, 4.03, 0.0),
16+
(-1.91, 3.59, 0.0),
17+
]
18+
polygon = Polygon(points)
19+
offset = 1.5
20+
21+
offset_polygons_inner = create_offset_polygons_2(points, offset)
22+
offset_polygons_outer = create_offset_polygons_2(points, -offset)
23+
24+
# ==============================================================================
25+
# Viz
26+
# ==============================================================================
27+
28+
viewer = Viewer(width=1600, height=900)
29+
viewer.scene.add(polygon)
30+
viewer.config.renderer.show_grid = False
31+
32+
for opolygon in offset_polygons_inner:
33+
viewer.scene.add(opolygon, linecolor=(1.0, 0.0, 0.0), facecolor=(1.0, 1.0, 1.0, 0.0))
34+
for opolygon in offset_polygons_outer:
35+
viewer.scene.add(opolygon, linecolor=(0.0, 0.0, 1.0), facecolor=(1.0, 1.0, 1.0, 0.0))
36+
37+
viewer.show()

0 commit comments

Comments
 (0)