Skip to content

Commit 0768957

Browse files
committed
more elaborate error
1 parent 1170d40 commit 0768957

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/compas_cgal/straight_skeleton_2.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ def create_interior_straight_skeleton(points) -> PolylinesNumpy:
2727
If the normal of the polygon is not [0, 0, 1].
2828
"""
2929
points = list(points)
30-
if not TOL.is_allclose(normal_polygon(points, True), [0, 0, 1]):
31-
raise ValueError("Please pass a polygon with a normal vector of [0, 0, 1].")
30+
normal = normal_polygon(points, True)
31+
if not TOL.is_allclose(normal, [0, 0, 1]):
32+
raise ValueError("The normal of the polygon should be [0, 0, 1]. The normal of the provided polygon is {}".format(normal))
3233
V = np.asarray(points, dtype=np.float64)
3334
return straight_skeleton_2.create_interior_straight_skeleton(V)
3435

@@ -55,15 +56,17 @@ def create_interior_straight_skeleton_with_holes(points, holes) -> PolylinesNump
5556
If the normal of a hole is not [0, 0, -1].
5657
"""
5758
points = list(points)
58-
if not TOL.is_allclose(normal_polygon(points, True), [0, 0, 1]):
59-
raise ValueError("Please pass a polygon with a normal vector of [0, 0, 1].")
59+
normal = normal_polygon(points, True)
60+
if not TOL.is_allclose(normal, [0, 0, 1]):
61+
raise ValueError("The normal of the polygon should be [0, 0, 1]. The normal of the provided polygon is {}".format(normal))
6062
V = np.asarray(points, dtype=np.float64)
6163

6264
H = []
63-
for hole in holes:
65+
for i, hole in enumerate(holes):
6466
points = list(hole)
65-
if not TOL.is_allclose(normal_polygon(points, True), [0, 0, -1]):
66-
raise ValueError("Please pass a hole with a normal vector of [0, 0, -1].")
67+
normal_hole = normal_polygon(points, True)
68+
if not TOL.is_allclose(normal_hole, [0, 0, -1]):
69+
raise ValueError("The normal of the hole should be [0, 0, -1]. The normal of the provided {}-th hole is {}".format(i, normal_hole))
6770
hole = np.asarray(points, dtype=np.float64)
6871
H.append(hole)
6972
return straight_skeleton_2.create_interior_straight_skeleton_with_holes(V, H)
@@ -90,8 +93,9 @@ def create_offset_polygons_2(points, offset):
9093
If the normal of the polygon is not [0, 0, 1].
9194
"""
9295
points = list(points)
93-
if not TOL.is_allclose(normal_polygon(points, True), [0, 0, 1]):
94-
raise ValueError("Please pass a polygon with a normal vector of [0, 0, 1].")
96+
normal = normal_polygon(points, True)
97+
if not TOL.is_allclose(normal, [0, 0, 1]):
98+
raise ValueError("The normal of the polygon should be [0, 0, 1]. The normal of the provided polygon is {}".format(normal))
9599
V = np.asarray(points, dtype=np.float64)
96100
offset = float(offset)
97101
if offset < 0: # outside
@@ -126,8 +130,10 @@ def create_weighted_offset_polygons_2(points, offset, weights):
126130
If the number of weights does not match the number of points.
127131
"""
128132
points = list(points)
129-
if not TOL.is_allclose(normal_polygon(points, True), [0, 0, 1]):
130-
raise ValueError("Please pass a polygon with a normal vector of [0, 0, 1].")
133+
normal = normal_polygon(points, True)
134+
if not TOL.is_allclose(normal, [0, 0, 1]):
135+
raise ValueError("The normal of the polygon should be [0, 0, 1]. The normal of the provided polygon is {}".format(normal))
136+
131137
V = np.asarray(points, dtype=np.float64)
132138
offset = float(offset)
133139
W = np.asarray(weights, dtype=np.float64)

0 commit comments

Comments
 (0)