Skip to content

Commit 35c9307

Browse files
authored
Merge pull request #1179 from compas-dev/lts-backports/sync-230905
LTS backports/sync 230905
2 parents eb090a0 + 9f5a476 commit 35c9307

File tree

10 files changed

+46
-10
lines changed

10 files changed

+46
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
* Fixed uninstall post-process.
1919
* Fixed `area_polygon` that was, in some cases, returning a negative area
2020
* Fixed support for `System.Decimal` data type on json serialization.
21+
* Fixed `AttributeError` in Plotter's `PolylineArtist` and `SegementArtist`.
22+
* Fixed wrong key type when de-serializing `Graph` with integer keys leading to node not found.
23+
* Fixed bug in `VolMeshArtist.draw_cells` for Rhino, Blender and Grasshopper.
24+
* Fixed bug in the `is_polygon_in_polygon_xy` that was not correctly generating all the edges of the second polygon before checking for intersections.
2125

2226
### Removed
2327

src/compas/datastructures/assembly/assembly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ def JSONSCHEMANAME(self):
5858
def data(self):
5959
data = {
6060
"attributes": self.attributes,
61-
"graph": self.graph.data,
61+
"graph": self.graph,
6262
}
6363
return data
6464

6565
@data.setter
6666
def data(self, data):
6767
self.attributes.update(data["attributes"] or {})
68-
self.graph.data = data["graph"]
68+
self.graph = data["graph"]
6969
self._parts = {part.guid: part.key for part in self.parts()}
7070

7171
# ==========================================================================

src/compas/geometry/predicates/predicates_2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def is_polygon_in_polygon_xy(polygon1, polygon2):
383383
for i in range(len(polygon1)):
384384
line = [polygon1[-i], polygon1[-i - 1]]
385385
for j in range(len(polygon2)):
386-
line_ = [polygon2[-j], polygon2[j - 1]]
386+
line_ = [polygon2[-j], polygon2[-j - 1]]
387387
if is_intersection_segment_segment_xy(line, line_):
388388
return False
389389
for pt in polygon2:

src/compas_blender/artists/volmeshartist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def draw_cells(
310310
faces = self.volmesh.cell_faces(cell)
311311
vertex_index = dict((vertex, index) for index, vertex in enumerate(vertices))
312312
vertices = [vertex_xyz[vertex] for vertex in vertices]
313-
faces = [[vertex_index[vertex] for vertex in self.halfface_vertices(face)] for face in faces]
313+
faces = [[vertex_index[vertex] for vertex in self.volmesh.halfface_vertices(face)] for face in faces]
314314
obj = compas_blender.draw_mesh(
315315
vertices,
316316
faces,

src/compas_ghpython/artists/volmeshartist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def draw_cells(self, cells=None, color=None):
167167
faces = self.volmesh.cell_faces(cell)
168168
vertex_index = dict((vertex, index) for index, vertex in enumerate(vertices))
169169
vertices = [vertex_xyz[vertex] for vertex in vertices]
170-
faces = [[vertex_index[vertex] for vertex in self.halfface_vertices(face)] for face in faces]
170+
faces = [[vertex_index[vertex] for vertex in self.volmesh.halfface_vertices(face)] for face in faces]
171171
mesh = compas_ghpython.draw_mesh(vertices, faces, color=self.cell_color[cell].rgb255)
172172
meshes.append(mesh)
173173
return meshes

src/compas_plotters/artists/polylineartist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ def redraw(self) -> None:
107107
self._mpl_line.set_xdata(x)
108108
self._mpl_line.set_ydata(y)
109109
self._mpl_line.set_color(self.color)
110-
self._mpl_line.set_linewidth(self.width)
110+
self._mpl_line.set_linewidth(self.linewidth)

src/compas_plotters/artists/segmentartist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def redraw(self) -> None:
106106
self._mpl_line.set_xdata([self.line.start[0], self.line.end[0]])
107107
self._mpl_line.set_ydata([self.line.start[1], self.line.end[1]])
108108
self._mpl_line.set_color(self.color)
109-
self._mpl_line.set_linewidth(self.width)
109+
self._mpl_line.set_linewidth(self.linewidth)
110110
if self.draw_points:
111111
self._start_artist.redraw()
112112
self._end_artist.redraw()

src/compas_rhino/artists/volmeshartist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def draw_cells(self, cells=None, color=None):
268268
faces = self.volmesh.cell_faces(cell)
269269
vertex_index = dict((vertex, index) for index, vertex in enumerate(vertices))
270270
vertices = [vertex_xyz[vertex] for vertex in vertices]
271-
faces = [[vertex_index[vertex] for vertex in self.halfface_vertices(face)] for face in faces]
271+
faces = [[vertex_index[vertex] for vertex in self.volmesh.halfface_vertices(face)] for face in faces]
272272
guid = compas_rhino.draw_mesh(
273273
vertices,
274274
faces,

tests/compas/datastructures/test_assembly.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import pytest
22

3+
from compas.data import json_dumps
4+
from compas.data import json_loads
35
from compas.datastructures import Assembly
46
from compas.datastructures import AssemblyError
57
from compas.datastructures import Part
@@ -69,9 +71,22 @@ def test_find_by_key():
6971
assert assembly.find_by_key("100") is None
7072

7173

72-
def test_find_by_key_after_deserialization():
74+
def test_find_by_key_after_from_data():
7375
assembly = Assembly()
7476
part = Part()
7577
assembly.add_part(part, key=2)
7678
assembly = Assembly.from_data(assembly.to_data())
7779
assert assembly.find_by_key(2) == part
80+
81+
82+
def test_find_by_key_after_deserialization():
83+
assembly = Assembly()
84+
part = Part(name="test_part")
85+
assembly.add_part(part, key=2)
86+
assembly = json_loads(json_dumps(assembly))
87+
88+
deserialized_part = assembly.find_by_key(2)
89+
assert deserialized_part.name == part.name
90+
assert deserialized_part.key == part.key
91+
assert deserialized_part.guid == part.guid
92+
assert deserialized_part.attributes == part.attributes

tests/compas/geometry/predicates/test_predicates_2.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from compas.geometry import Circle
22
from compas.geometry import Plane
33
from compas.geometry import Point
4+
from compas.geometry import Polygon
45
from compas.geometry import Vector
5-
from compas.geometry import is_point_in_circle_xy
6+
from compas.geometry import is_point_in_circle_xy, is_polygon_in_polygon_xy
67

78

89
def test_is_point_in_circle_xy():
@@ -24,3 +25,19 @@ def test_is_point_in_circle_xy_class_input():
2425

2526
pt_outside = Point(15, 15, 0)
2627
assert is_point_in_circle_xy(pt_outside, circle) is False
28+
29+
30+
def test_is_polygon_in_polygon_xy():
31+
polygon_contour = Polygon([(0, 0, 0), (4, 2, 0), (10, 0, 0), (11, 10, 0), (8, 12, 0), (0, 10, 0)])
32+
polygon_inside = Polygon([(5, 5, 0), (10, 5, 0), (10, 10, 0), (5, 10, 0)])
33+
assert is_polygon_in_polygon_xy(polygon_contour, polygon_inside)
34+
35+
polygon_outside = Polygon([(15, 5, 0), (20, 5, 0), (20, 10, 0), (15, 10, 0)])
36+
assert not is_polygon_in_polygon_xy(polygon_contour, polygon_outside)
37+
38+
polygon_intersecting = Polygon([(10, 10, 0), (10, 5, 0), (15, 5, 0), (15, 10, 0)])
39+
assert not is_polygon_in_polygon_xy(polygon_contour, polygon_intersecting)
40+
41+
# shifting the vertices list of the same polygon shouldn't affect the containment check output anymore
42+
polygon_intersecting_shifted = Polygon(polygon_intersecting[1:] + polygon_intersecting[:1])
43+
assert not is_polygon_in_polygon_xy(polygon_contour, polygon_intersecting_shifted)

0 commit comments

Comments
 (0)