Skip to content

Commit acd1f64

Browse files
authored
Merge pull request #29 from compas-dev/feature/straight_skeleton_2
Added straight skeleton 2
2 parents e91ac21 + c229d1a commit acd1f64

17 files changed

+220
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
* Added `compas_cgal.straight_skeleton_2.create_interior_straight_skeleton`.
13+
1214
### Changed
1315

1416
### Removed
54.7 KB
Loading

docs/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ API Reference
1212
api/compas_cgal.reconstruction
1313
api/compas_cgal.slicer
1414
api/compas_cgal.skeletonization
15+
api/compas_cgal.straight_skeleton_2
1516
api/compas_cgal.subdivision
1617
api/compas_cgal.triangulation
1718
api/compas_cgal.types
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
********************************************************************************
2+
compas_cgal.straight_skeleton_2
3+
********************************************************************************
4+
5+
.. currentmodule:: compas_cgal.straight_skeleton_2
6+
7+
.. autosummary::
8+
:toctree: generated/
9+
:nosignatures:
10+
11+
create_interior_straight_skeleton
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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
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+
polygon = Polygon(points)
20+
lines = create_interior_straight_skeleton(points)
21+
graph = Graph.from_lines(lines)
22+
23+
# ==============================================================================
24+
# Viz
25+
# ==============================================================================
26+
27+
viewer = Viewer(width=1600, height=900)
28+
viewer.renderer_config.show_grid = False
29+
viewer.scene.add(graph, edgecolor=(1.0, 0.0, 0.0))
30+
viewer.scene.add(polygon)
31+
viewer.show()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
********************************************************************************
2+
2D Straight Skeleton
3+
********************************************************************************
4+
5+
.. figure:: /_images/cgal_straight_skeleton_2.png
6+
:figclass: figure
7+
:class: figure-img img-fluid
8+
9+
10+
.. literalinclude:: straight_skeleton_2.py
11+
:language: python

include/compas.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ namespace compas
2424
using Mesh = CGAL::Surface_mesh<Point>;
2525
using RowMatrixXd = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
2626
using RowMatrixXi = Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
27+
using Edge = std::tuple<std::vector<double>, std::vector<double>>;
28+
using Edges = std::list<Edge>;
2729

2830
Polyhedron polyhedron_from_vertices_and_faces(const RowMatrixXd &V, const RowMatrixXi &F);
2931

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def get_scip_library():
5252
"src/skeletonization.cpp",
5353
"src/reconstruction.cpp",
5454
"src/polygonal_surface_reconstruction.cpp",
55+
"src/straight_skeleton_2.cpp",
5556
]
5657
),
5758
include_dirs=["./include", get_eigen_include(), get_pybind_include()],

src/compas_cgal.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ void init_subdivision(pybind11::module &);
1212
void init_skeletonization(pybind11::module &);
1313
void init_reconstruction(pybind11::module &);
1414
void init_polygonal_surface_reconstruction(pybind11::module &);
15+
void init_straight_skeleton_2(pybind11::module &);
1516

1617
// the first parameter here ("_cgal") will be the name of the "so" or "pyd" file that will be produced by PyBind11
1718
// which is the entry point from where all other modules will be accessible.
@@ -30,4 +31,5 @@ PYBIND11_MODULE(_cgal, m)
3031
init_skeletonization(m);
3132
init_reconstruction(m);
3233
init_polygonal_surface_reconstruction(m);
34+
init_straight_skeleton_2(m);
3335
}

src/compas_cgal/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"compas_cgal.measure",
2323
"compas_cgal.slicer",
2424
"compas_cgal.triangulation",
25+
"compas_cgal.straight_skeleton_2",
2526
]
2627

2728
__all__ = ["HOME", "DATA", "DOCS", "TEMP"]

0 commit comments

Comments
 (0)