Skip to content

Commit 7a232fe

Browse files
committed
Revert "adding inner and outer offsets"
This reverts commit 4310a02.
1 parent 4310a02 commit 7a232fe

File tree

5 files changed

+2
-139
lines changed

5 files changed

+2
-139
lines changed

docs/examples/straight_skeleton_offset.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/compas_cgal/straight_skeleton_2.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22
from compas.geometry import normal_polygon
3-
from compas.geometry import Polygon
43
from compas.tolerance import TOL
54

65
from compas_cgal._cgal import straight_skeleton_2
@@ -67,17 +66,3 @@ def create_interior_straight_skeleton_with_holes(points, holes) -> PolylinesNump
6766
hole = np.asarray(points, dtype=np.float64)
6867
H.append(hole)
6968
return straight_skeleton_2.create_interior_straight_skeleton_with_holes(V, H)
70-
71-
72-
def create_offset_polygons_2(points, offset) -> PolylinesNumpy:
73-
points = list(points)
74-
if not TOL.is_allclose(normal_polygon(points, True), [0, 0, 1]):
75-
raise ValueError("Please pass a polygon with a normal vector of [0, 0, 1].")
76-
V = np.asarray(points, dtype=np.float64)
77-
offset = float(offset)
78-
if offset < 0: # outside
79-
offset_polygons = straight_skeleton_2.create_offset_polygons_2_outer(V, abs(offset))[1:] # first one is box
80-
else: # inside
81-
offset_polygons = straight_skeleton_2.create_offset_polygons_2_inner(V, offset)
82-
return [Polygon(points.tolist()) for points in offset_polygons]
83-

src/straight_skeleton_2.cpp

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <CGAL/Polygon_2.h>
44
#include <CGAL/create_straight_skeleton_2.h>
55
#include <CGAL/create_straight_skeleton_from_polygon_with_holes_2.h>
6-
#include <CGAL/create_offset_polygons_2.h>
76

87
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
98
typedef K::Point_2 Point;
@@ -13,8 +12,6 @@ typedef CGAL::Straight_skeleton_2<K> Ss;
1312
typedef boost::shared_ptr<Ss> SsPtr;
1413
typedef CGAL::Straight_skeleton_2<K>::Halfedge_const_handle Halfedge_const_handle;
1514
typedef CGAL::Straight_skeleton_2<K>::Vertex_const_handle Vertex_const_handle;
16-
typedef boost::shared_ptr<Polygon_2> PolygonPtr;
17-
typedef std::vector<PolygonPtr> PolygonPtrVector;
1815

1916
compas::Edges pmp_create_interior_straight_skeleton(
2017
Eigen::Ref<const compas::RowMatrixXd> &V)
@@ -89,52 +86,6 @@ compas::Edges pmp_create_interior_straight_skeleton_with_holes(
8986

9087
}
9188

92-
std::vector<compas::RowMatrixXd> pmp_create_offset_polygons_2_inner(Eigen::Ref<const compas::RowMatrixXd> &V, double &offset){
93-
Polygon_2 poly;
94-
for (int i = 0; i < V.rows(); i++){
95-
poly.push_back(Point(V(i, 0), V(i, 1)));
96-
}
97-
PolygonPtrVector offset_polygons = CGAL::create_interior_skeleton_and_offset_polygons_2(offset, poly);
98-
99-
std::vector<compas::RowMatrixXd> result;
100-
for(auto pi = offset_polygons.begin(); pi != offset_polygons.end(); ++pi){
101-
std::size_t n = (*pi)->size();
102-
compas::RowMatrixXd points(n, 3);
103-
int j = 0;
104-
for (auto vi = (*pi)->vertices_begin(); vi != (*pi)->vertices_end(); ++vi){
105-
points(j, 0) = (double)(*vi).x();
106-
points(j, 1) = (double)(*vi).y();
107-
points(j, 2) = 0;
108-
j++;
109-
}
110-
result.push_back(points);
111-
}
112-
return result;
113-
}
114-
115-
std::vector<compas::RowMatrixXd> pmp_create_offset_polygons_2_outer(Eigen::Ref<const compas::RowMatrixXd> &V, double &offset){
116-
Polygon_2 poly;
117-
for (int i = 0; i < V.rows(); i++){
118-
poly.push_back(Point(V(i, 0), V(i, 1)));
119-
}
120-
PolygonPtrVector offset_polygons = CGAL::create_exterior_skeleton_and_offset_polygons_2(offset, poly);
121-
122-
std::vector<compas::RowMatrixXd> result;
123-
for(auto pi = offset_polygons.begin(); pi != offset_polygons.end(); ++pi){
124-
std::size_t n = (*pi)->size();
125-
compas::RowMatrixXd points(n, 3);
126-
int j = 0;
127-
for (auto vi = (*pi)->vertices_begin(); vi != (*pi)->vertices_end(); ++vi){
128-
points(j, 0) = (double)(*vi).x();
129-
points(j, 1) = (double)(*vi).y();
130-
points(j, 2) = 0;
131-
j++;
132-
}
133-
result.push_back(points);
134-
}
135-
return result;
136-
}
137-
13889
// ===========================================================================
13990
// PyBind11
14091
// ===========================================================================
@@ -153,16 +104,4 @@ void init_straight_skeleton_2(pybind11::module &m)
153104
&pmp_create_interior_straight_skeleton_with_holes,
154105
pybind11::arg("V").noconvert(),
155106
pybind11::arg("holes").noconvert());
156-
157-
submodule.def(
158-
"create_offset_polygons_2_inner",
159-
&pmp_create_offset_polygons_2_inner,
160-
pybind11::arg("V").noconvert(),
161-
pybind11::arg("offset").noconvert());
162-
163-
submodule.def(
164-
"create_offset_polygons_2_outer",
165-
&pmp_create_offset_polygons_2_outer,
166-
pybind11::arg("V").noconvert(),
167-
pybind11::arg("offset").noconvert());
168107
};

src/straight_skeleton_2.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,9 @@
77
compas::Edges pmp_create_interior_straight_skeleton(
88
Eigen::Ref<const compas::RowMatrixXd> &V);
99

10+
1011
compas::Edges pmp_create_interior_straight_skeleton_with_holes(
1112
Eigen::Ref<const compas::RowMatrixXd> &V,
1213
std::vector<Eigen::Ref<const compas::RowMatrixXd>> &holes);
1314

14-
std::vector<compas::RowMatrixXd> pmp_create_offset_polygons_2_inner(
15-
Eigen::Ref<const compas::RowMatrixXd> &V,
16-
double &offset);
17-
18-
std::vector<compas::RowMatrixXd> pmp_create_offset_polygons_2_outer(
19-
Eigen::Ref<const compas::RowMatrixXd> &V,
20-
double &offset);
21-
2215
#endif /* COMPAS_STRAIGHT_SKELETON_2_H */

tests/test_straight_skeleton_2.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from compas_cgal.straight_skeleton_2 import create_interior_straight_skeleton
44
from compas_cgal.straight_skeleton_2 import create_interior_straight_skeleton_with_holes
5-
from compas_cgal.straight_skeleton_2 import create_offset_polygons_2
5+
66

77
def test_straight_polygon():
88
points = [
@@ -73,21 +73,3 @@ def test_straight_polygon_2_compare():
7373
# the line direction sometimes changes ...
7474
assert TOL.is_allclose(sa, se) or TOL.is_allclose(sa, ee)
7575
assert TOL.is_allclose(ea, ee) or TOL.is_allclose(ea, se)
76-
77-
78-
def test_offset():
79-
points = [
80-
(-1, -1, 0),
81-
(0, -12, 0),
82-
(1, -1, 0),
83-
(12, 0, 0),
84-
(1, 1, 0),
85-
(0, 12, 0),
86-
(-1, 1, 0),
87-
(-12, 0, 0),
88-
]
89-
offset = 0.5
90-
polygons = create_offset_polygons_2(points, offset)
91-
assert len(polygons) == 1, len(polygons)
92-
polygons = create_offset_polygons_2(points, -offset)
93-
assert len(polygons) == 1, len(polygons)

0 commit comments

Comments
 (0)