Skip to content

Commit 4d19ce1

Browse files
committed
lint, formatting and migrations
1 parent 8a02d17 commit 4d19ce1

22 files changed

Lines changed: 432 additions & 981 deletions

src/compas_assembly/__init__.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
1-
"""
2-
********************************************************************************
3-
compas_assembly
4-
********************************************************************************
5-
6-
.. currentmodule:: compas_assembly
7-
8-
9-
.. toctree::
10-
:maxdepth: 1
11-
12-
compas_assembly.algorithms
13-
compas_assembly.artists
14-
compas_assembly.datastructures
15-
compas_assembly.geometry
16-
compas_assembly.rhino
17-
compas_assembly.viewer
18-
19-
"""
201
from __future__ import print_function
212
from __future__ import absolute_import
223
from __future__ import division
234

245
import os
256

26-
__author__ = ["Tom Van Mele <van.mele@arch.ethz.ch>"]
27-
__copyright__ = "Block Research Group - ETH Zurich"
7+
__author__ = ["Tom Van Mele"]
8+
__copyright__ = "ETH Zurich - Block Research Group"
289
__license__ = "MIT License"
29-
__email__ = "van.mele@arch.ethz.ch"
30-
10+
__email__ = "tom.v.mele@gmail.com"
3111
__version__ = "0.6.2"
3212

3313

src/compas_assembly/algorithms/__init__.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
"""
2-
********************************************************************************
3-
compas_assembly.algorithms
4-
********************************************************************************
5-
6-
.. currentmodule:: compas_assembly.algorithms
7-
8-
9-
Functions
10-
=========
11-
12-
.. autosummary::
13-
:toctree: generated/
14-
:nosignatures:
15-
16-
assembly_hull
17-
assembly_hull_numpy
18-
assembly_interfaces
19-
assembly_interfaces_numpy
20-
mesh_mesh_interfaces
21-
merge_coplanar_interfaces
22-
23-
"""
241
from __future__ import absolute_import
252

263
import compas

src/compas_assembly/algorithms/hull.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from __future__ import division
33
from __future__ import print_function
44

5-
from compas.utilities import flatten
65
from compas.geometry import convex_hull
6+
from compas.itertools import flatten
77
from compas.topology import unify_cycles
88

99

@@ -36,7 +36,7 @@ def assembly_hull(assembly, keys=None, unify=True):
3636
points = []
3737
for key in keys:
3838
block = assembly.blocks[key]
39-
points.extend(block.vertices_attributes('xyz'))
39+
points.extend(block.vertices_attributes("xyz"))
4040

4141
faces = convex_hull(points)
4242
vertices = list(set(flatten(faces)))

src/compas_assembly/algorithms/hull_numpy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def assembly_hull_numpy(assembly, keys=None, unify=True):
2121
tuple
2222
The vertices and faces of the hull.
2323
24-
Warning
25-
-------
24+
Warnings
25+
--------
2626
This function requires Numpy and cannot be used directly inside Rhino.
2727
2828
Examples
@@ -34,7 +34,7 @@ def assembly_hull_numpy(assembly, keys=None, unify=True):
3434
points = []
3535
for key in keys:
3636
block = assembly.blocks[key]
37-
points.extend(block.vertices_attributes('xyz'))
37+
points.extend(block.vertices_attributes("xyz"))
3838

3939
vertices, faces = convex_hull_numpy(points)
4040

src/compas_assembly/algorithms/interfaces.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
from typing import List
2-
31
from math import fabs
2+
from typing import List
43

54
from shapely.geometry import Polygon as ShapelyPolygon
65

6+
from compas.datastructures import Mesh
77
from compas.geometry import Frame
8-
from compas.geometry import Transformation
98
from compas.geometry import Plane
109
from compas.geometry import Polygon
10+
from compas.geometry import Transformation
1111
from compas.geometry import centroid_polygon
12-
13-
# from compas.geometry import bestfit_frame_numpy
14-
from compas.geometry import transform_points
15-
from compas.geometry import is_coplanar
1612
from compas.geometry import is_colinear
17-
13+
from compas.geometry import is_coplanar
14+
from compas.geometry import transform_points
1815
from compas.utilities import window
19-
20-
from compas.datastructures import Mesh
21-
from compas.datastructures import mesh_merge_faces
22-
16+
from compas_assembly.algorithms.nnbrs import find_nearest_neighbours
2317
from compas_assembly.datastructures import Assembly
2418
from compas_assembly.datastructures import Block
2519
from compas_assembly.datastructures import Interface
26-
from compas_assembly.algorithms.nnbrs import find_nearest_neighbours
2720

2821

2922
def assembly_interfaces(
@@ -76,7 +69,7 @@ def assembly_interfaces(
7669
# a block has no interfaces with itself
7770
continue
7871

79-
if assembly.graph.has_edge(n, node, directed=False):
72+
if assembly.graph.has_edge((n, node), directed=False):
8073
# the interfaces between these two blocks have already been identified
8174
continue
8275

@@ -148,7 +141,6 @@ def mesh_mesh_interfaces(
148141
coords = transform_points(coords, matrix.inverted())[:-1]
149142

150143
interface = Interface(
151-
type="face_face",
152144
size=area,
153145
points=coords,
154146
frame=Frame(
@@ -216,7 +208,7 @@ def merge_coplanar_interfaces(assembly, tol=1e-6):
216208
points.append(temp.vertex_coordinates(vertex))
217209

218210
if is_coplanar(points, tol=tol):
219-
mesh_merge_faces(temp, [face, nbr])
211+
temp.merge_faces([face, nbr])
220212
has_merged = True
221213
reconstruct = True
222214
break
@@ -232,11 +224,8 @@ def merge_coplanar_interfaces(assembly, tol=1e-6):
232224
for face in temp.faces():
233225
points = temp.face_coordinates(face)
234226
area = temp.face_area(face)
235-
frame = Frame.from_plane(
236-
Plane(temp.face_centroid(face), temp.face_normal(face))
237-
)
227+
frame = Frame.from_plane(Plane(temp.face_centroid(face), temp.face_normal(face)))
238228
interface = Interface(
239-
type="face_face",
240229
size=area,
241230
points=points,
242231
frame=frame,

src/compas_assembly/algorithms/interfaces_numpy.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
from shapely.geometry import Polygon
77

88
from compas.geometry import Frame
9-
from compas.geometry import local_to_world_coordinates_numpy
109
from compas.geometry import centroid_points
11-
10+
from compas.geometry import local_to_world_coordinates_numpy
11+
from compas_assembly.algorithms.nnbrs import find_nearest_neighbours
1212
from compas_assembly.datastructures import Assembly
1313
from compas_assembly.datastructures import Block
1414
from compas_assembly.datastructures import Interface
15-
from compas_assembly.algorithms.nnbrs import find_nearest_neighbours
1615

1716

1817
def assembly_interfaces_numpy(
@@ -125,7 +124,6 @@ def mesh_mesh_interfaces(
125124
rst = {key: rst[k_i[key]] for key in b.vertices()}
126125

127126
for f1 in b.faces():
128-
129127
rst1 = [rst[key] for key in b.face_vertices(f1)]
130128

131129
if any(fabs(t) > tmax for r, s, t in rst1):
@@ -146,11 +144,8 @@ def mesh_mesh_interfaces(
146144
continue
147145

148146
coords = [[x, y, 0.0] for x, y, z in intersection.exterior.coords]
149-
coords = local_to_world_coordinates_numpy(
150-
Frame(o, A[0], A[1]), coords[:-1]
151-
).tolist()
147+
coords = local_to_world_coordinates_numpy(Frame(o, A[0], A[1]), coords[:-1]).tolist()
152148
interface = Interface(
153-
type="face_face",
154149
size=area,
155150
points=coords,
156151
frame=Frame(

src/compas_assembly/artists/__init__.py

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

src/compas_assembly/artists/assemblyartist.py

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

0 commit comments

Comments
 (0)