Skip to content

Commit c3fc48c

Browse files
Merge branch 'compas-dev:main' into datastructures-bounding-boxes
2 parents b261d8b + 96c2ea7 commit c3fc48c

File tree

24 files changed

+334
-28
lines changed

24 files changed

+334
-28
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
### Removed
1818

1919

20+
## [2.13.0] 2025-06-04
21+
22+
### Added
23+
24+
* Added `compas.scene.Scene.add_group()` for adding group.
25+
* Added `compas.scene.Group.add_from_list()` for adding a list of items to a group.
26+
* Added implementation for `compas.geometry.SphericalSurface.isocurve_u`.
27+
* Added implementation for `compas.geometry.SphericalSurface.isocurve_v`.
28+
* Added implementation for `compas.geometry.CylindricalSurface.isocurve_u`.
29+
* Added implementation for `compas.geometry.CylindricalSurface.isocurve_v`.
30+
31+
### Changed
32+
33+
* Fixed error in `circle_to_compas` from Rhino.
34+
* Fixed Rhino to Rhino brep serialization.
35+
* Upated `compas.scene.Group.add()` to pass on group kwargs as default for child items.
36+
* Fixed bug in context detection, which wrongly defaults to `Viewer` instead of `None`.
37+
* Fixed bug in calculation of `compas.geometry.Polyhedron.edges` if geometry is computed using numpy.
38+
* Fixed bug in `Grpah.from_pointcloud` which uses degree parameter wrongly.
39+
40+
### Removed
41+
42+
2043
## [2.12.0] 2025-05-28
2144

2245
### Added

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ doctest_optionflags = [
8484
# ============================================================================
8585

8686
[tool.bumpversion]
87-
current_version = "2.12.0"
87+
current_version = "2.13.0"
8888
message = "Bump version to {new_version}"
8989
commit = true
9090
tag = true

src/compas/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
__copyright__ = "Copyright 2014-2022 - ETH Zurich, Copyright 2023 - COMPAS Association"
2121
__license__ = "MIT License"
2222
__email__ = "[email protected]"
23-
__version__ = "2.12.0"
23+
__version__ = "2.13.0"
2424

2525

2626
HERE = compas._os.realpath(os.path.dirname(__file__))
@@ -275,9 +275,10 @@ def safe_extract(tar, path=".", members=None, numeric_owner=False):
275275
return bunny
276276

277277

278-
def devday(year, is_open):
278+
def devday(year, open=True):
279279
import zlib
280280
import base64
281281

282-
encoded = b"eJxNksFq20AQhu/7FINPLSSxk1BaBDmYOGkoDjW2ac4jaSQNWu2I3VVStxRy6TG00OTQU6AP0Rfom+QJ8ggduTL0siz/zv/tvz/LBXz+AicncDQ5epVA69nFF6PRyJy+v1xMVzCja7LSkocZbrZD5orSwJESqGJsQzIe5wWmB5ZdPc7pOseNMc+PP76qoR+67G1vYvXP+/z48B3W3OjB4XEymcA+HL5Ojie94w7mkmFkcQmcrS/g4s9vV5bkU/LlHizP5z335zeYZrWTG0t5SQ25GIxZV+hq2EgHUUAD+404gptKoMGcIFYcQHNBKyFwagmebu9VJcjERc9pF8WHPRBfouNP1O/R5YDWghRbbs9KtZsShl70IssFHRizailjtMrTEKE/kM5DaAlrJSXGPN3+gtOK9q+IYc4OYKvMpGHHNSyJA2bVoJ5ZcgxTSx95UN5yLjBjstSgC4P4jqy+4pz6RDhoC3QSdG2Vhh4tNql0O8OiYmu5bdVk9cKsUtguyRILJKvOED26HW6FTaeqlk3+v+EPGNhqnVMrXQxaV87B6H95+Rd/oc5T" # noqa: E501
283-
exec(zlib.decompress(base64.b64decode(encoded)).decode().format(year))
282+
if open:
283+
encoded = b"eJxNksFq20AQhu/7FINPLSSxk1BaBDmYOGkoDjW2ac4jaSQNWu2I3VVStxRy6TG00OTQU6AP0Rfom+QJ8ggduTL0siz/zv/tvz/LBXz+AicncDQ5epVA69nFF6PRyJy+v1xMVzCja7LSkocZbrZD5orSwJESqGJsQzIe5wWmB5ZdPc7pOseNMc+PP76qoR+67G1vYvXP+/z48B3W3OjB4XEymcA+HL5Ojie94w7mkmFkcQmcrS/g4s9vV5bkU/LlHizP5z335zeYZrWTG0t5SQ25GIxZV+hq2EgHUUAD+404gptKoMGcIFYcQHNBKyFwagmebu9VJcjERc9pF8WHPRBfouNP1O/R5YDWghRbbs9KtZsShl70IssFHRizailjtMrTEKE/kM5DaAlrJSXGPN3+gtOK9q+IYc4OYKvMpGHHNSyJA2bVoJ5ZcgxTSx95UN5yLjBjstSgC4P4jqy+4pz6RDhoC3QSdG2Vhh4tNql0O8OiYmu5bdVk9cKsUtguyRILJKvOED26HW6FTaeqlk3+v+EPGNhqnVMrXQxaV87B6H95+Rd/oc5T" # noqa: E501
284+
exec(zlib.decompress(base64.b64decode(encoded)).decode().format(year))

src/compas/datastructures/graph/graph.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from ast import literal_eval
66
from itertools import combinations
77
from random import sample
8+
from random import shuffle
89

910
import compas
1011

@@ -159,7 +160,13 @@ def __from_data__(cls, data):
159160
graph._max_node = data.get("max_node", graph._max_node)
160161
return graph
161162

162-
def __init__(self, default_node_attributes=None, default_edge_attributes=None, name=None, **kwargs):
163+
def __init__(
164+
self,
165+
default_node_attributes=None,
166+
default_edge_attributes=None,
167+
name=None,
168+
**kwargs
169+
): # fmt: skip
163170
super(Graph, self).__init__(kwargs, name=name)
164171
self._max_node = -1
165172
self.node = {}
@@ -375,8 +382,16 @@ def from_pointcloud(cls, cloud, degree=3):
375382
graph = cls()
376383
for x, y, z in cloud:
377384
graph.add_node(x=x, y=y, z=z)
385+
nodes = list(graph.nodes())
378386
for u in graph.nodes():
379-
for v in graph.node_sample(size=degree):
387+
shuffle(nodes)
388+
for v in nodes:
389+
if v == u:
390+
continue
391+
if graph.degree(v) == degree:
392+
continue
393+
if graph.degree(u) == degree:
394+
break
380395
graph.add_edge(u, v)
381396
return graph
382397

src/compas/datastructures/mesh/mesh.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,14 @@ def __from_data__(cls, data):
229229

230230
return mesh
231231

232-
def __init__(self, default_vertex_attributes=None, default_edge_attributes=None, default_face_attributes=None, name=None, **kwargs): # fmt: skip
232+
def __init__(
233+
self,
234+
default_vertex_attributes=None,
235+
default_edge_attributes=None,
236+
default_face_attributes=None,
237+
name=None,
238+
**kwargs
239+
): # fmt: skip
233240
super(Mesh, self).__init__(kwargs, name=name)
234241
self._max_vertex = -1
235242
self._max_face = -1

src/compas/files/gltf/gltf_node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def rotation(self, value):
162162
if self._matrix:
163163
raise Exception("Cannot set rotation when matrix is set.")
164164
if not isinstance(value, list) or len(value) != 4 or fabs(sum([q**2 for q in value]) - 1) > 1e-03:
165-
raise Exception("Invalid rotation. Rotations are expected to be given as " "unit quaternions of the form [q1, q2, q3, q4]")
165+
raise Exception("Invalid rotation. Rotations are expected to be given as unit quaternions of the form [q1, q2, q3, q4]")
166166
self._rotation = value
167167

168168
@property
@@ -199,7 +199,7 @@ def matrix(self, value):
199199
raise Exception("Invalid matrix. A 4x4 matrix is expected.")
200200
if value[3] != [0, 0, 0, 1]:
201201
raise Exception(
202-
"Invalid matrix. A matrix without shear or skew is expected. It must be of " "the form TRS, where T is a translation, R is a rotation and S is a scaling."
202+
"Invalid matrix. A matrix without shear or skew is expected. It must be of the form TRS, where T is a translation, R is a rotation and S is a scaling."
203203
)
204204
self._matrix = value
205205

src/compas/geometry/polyhedron.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from compas.geometry import Point
99
from compas.geometry import Polygon
1010
from compas.geometry import transform_points
11-
from compas.itertools import pairwise
1211
from compas.tolerance import TOL
1312

1413
from .geometry import Geometry
@@ -301,7 +300,9 @@ def faces(self, faces):
301300
def edges(self):
302301
seen = set()
303302
for face in self.faces:
304-
for u, v in pairwise(face + face[:1]):
303+
for i in range(-1, len(face) - 1):
304+
u = face[i]
305+
v = face[i + 1]
305306
if (u, v) not in seen:
306307
seen.add((u, v))
307308
seen.add((v, u))

src/compas/geometry/surfaces/cylindrical.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from compas.geometry import Circle
1010
from compas.geometry import Frame
11+
from compas.geometry import Line
1112
from compas.geometry import Point
1213
from compas.geometry import Vector
1314

@@ -162,6 +163,39 @@ def from_three_points(cls, a, b, c):
162163
# Methods
163164
# =============================================================================
164165

166+
def isocurve_u(self, u):
167+
"""Compute the isoparametric curve at parameter u.
168+
169+
Parameters
170+
----------
171+
u : float
172+
173+
Returns
174+
-------
175+
:class:`compas.geometry.Line`
176+
177+
"""
178+
base = self.point_at(u=u, v=0.5)
179+
return Line.from_point_direction_length(base, self.frame.zaxis, 1.0)
180+
181+
def isocurve_v(self, v):
182+
"""Compute the isoparametric curve at parameter v.
183+
184+
Parameters
185+
----------
186+
v : float
187+
188+
Returns
189+
-------
190+
:class:`compas.geometry.Circle`
191+
192+
"""
193+
point = self.center + self.frame.zaxis * v
194+
xaxis = self.frame.xaxis
195+
yaxis = self.frame.yaxis
196+
frame = Frame(point, xaxis, yaxis)
197+
return Circle(radius=self.radius, frame=frame)
198+
165199
def point_at(self, u, v, world=True):
166200
"""Compute a point on the surface at the given parameters.
167201

src/compas/geometry/surfaces/spherical.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,44 @@ def from_points(cls, points):
191191
# Methods
192192
# =============================================================================
193193

194+
def isocurve_u(self, u):
195+
"""Compute the isoparametric curve at parameter u.
196+
197+
Parameters
198+
----------
199+
u : float
200+
201+
Returns
202+
-------
203+
:class:`compas.geometry.Circle`
204+
205+
"""
206+
origin = self.center
207+
xaxis = self.point_at(u=u, v=0) - origin
208+
yaxis = self.point_at(u=u, v=0.25) - origin
209+
frame = Frame(origin, xaxis, yaxis)
210+
return Circle(radius=xaxis.length, frame=frame)
211+
212+
def isocurve_v(self, v):
213+
"""Compute the isoparametric curve at parameter v.
214+
215+
Parameters
216+
----------
217+
v : float
218+
219+
Returns
220+
-------
221+
:class:`compas.geometry.Circle`
222+
223+
"""
224+
x = self.point_at(u=0, v=v)
225+
y = self.point_at(u=0.25, v=v)
226+
origin = self.center + self.frame.zaxis * (x - self.center).dot(self.frame.zaxis)
227+
xaxis = x - origin
228+
yaxis = y - origin
229+
frame = Frame(origin, xaxis, yaxis)
230+
return Circle(radius=xaxis.length, frame=frame)
231+
194232
def point_at(self, u, v, world=True):
195233
"""Construct a point on the sphere.
196234

src/compas/geometry/surfaces/surface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def isocurve_v(self, v):
474474
475475
Returns
476476
-------
477-
:class:`compas_occ.geometry.Curve`
477+
:class:`compas.geometry.Curve`
478478
479479
"""
480480
raise NotImplementedError

0 commit comments

Comments
 (0)