Skip to content

Commit

Permalink
style(pep8): Clean up the code
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Feb 21, 2024
1 parent 0871367 commit 42b0787
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
12 changes: 7 additions & 5 deletions honeybee/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def rectangularize_apertures(
if max_separation is not None:
if merge_all or (not merge_all and len(non_rect_geos) > 1):
edits_occurred = True
if max_separation <= tol: # just join the Apertures at the tolerance
if max_separation <= tol: # just join the Apertures at the tolerance
non_rect_geos = Face3D.join_coplanar_faces(non_rect_geos, tol)
else: # join the Apertures using the max_separation
# get polygons for the faces that all lie within the same plane
Expand Down Expand Up @@ -744,10 +744,10 @@ def rectangularize_apertures(
new_ap = Aperture('{}_RectGlz{}'.format(self.identifier, i), ap_face)
else:
new_ap = Aperture(exist_ap.identifier, ap_face,
is_operable=exist_ap.is_operable)
is_operable=exist_ap.is_operable)
new_ap.display_name = '{}_{}'.format(exist_ap.display_name, i)
new_aps.append(new_ap)

# we can just add the apertures if there's no subdivision going on
if subdivision_distance is None:
# remove any Apertures that are overlapping
Expand Down Expand Up @@ -775,11 +775,13 @@ def rectangularize_apertures(
# group face by y value. All the rows will be merged together
vertices = grid.vertices
groups = {}
start_y = None
last_y = vertices[grid.faces[0][0]].y
for i, face in enumerate(grid.faces):
min_2d = vertices[face[0]]
for xy in groups:
if abs(min_2d.x - xy[0]) < tolerance and abs(min_2d.y - last_y) < tolerance:
if abs(min_2d.x - xy[0]) < tolerance and \
abs(min_2d.y - last_y) < tolerance:
groups[(xy[0], start_y)].append(face)
break
else:
Expand Down Expand Up @@ -862,7 +864,7 @@ def _get_last_row(groups, start=0):

def _reference_plane(self, angle_tolerance):
"""Get a Plane for this Face geometry derived from the Face3D plane.
This will be oriented with the plane Y-Axis either aligned with the
World Z or World Y, which is helpful in rectangularization.
Expand Down
5 changes: 2 additions & 3 deletions honeybee/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ def from_stl(cls, file_path, geometry_to_faces=False, units='Meters',
all_id = clean_string(stl_obj.name)
all_geo = []
if geometry_to_faces:

for verts, normal in zip(stl_obj.face_vertices, stl_obj.face_normals):
all_geo.append(Face3D(verts, plane=Plane(normal, verts[0])))
hb_objs = [Face(all_id + '_' + str(uuid.uuid4())[:8], go) for go in all_geo]
Expand Down Expand Up @@ -1633,7 +1632,7 @@ def simplify_apertures(self, resolve_adjacency=True, tolerance=None):
room.simplify_apertures(tol)
if resolve_adjacency:
self.solve_adjacency()

def rectangularize_apertures(
self, subdivision_distance=None, max_separation=None, merge_all=False,
resolve_adjacency=True, tolerance=None, angle_tolerance=None):
Expand Down Expand Up @@ -1780,7 +1779,7 @@ def convert_to_units(self, units='Meters'):

def rooms_to_orphaned(self):
"""Convert all Rooms in this Model to orphaned geometry objects.
This is useful when the energy load balance of Rooms is not important
and they are only significant as context shading. Note that this method
will effectively discount any geometries with a Surface boundary condition
Expand Down
28 changes: 14 additions & 14 deletions honeybee/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,14 @@ def add_prefix(self, prefix):

def horizontal_boundary(self, match_walls=False, tolerance=0.01):
"""Get a Face3D representing the horizontal boundary around the Room.
This will be generated from all downward-facing Faces of the Room (essentially
the Floor faces but can also include overhanging slanted walls). So, for
a valid closed-volume Honeybee Room, the result should always represent
the Room in the XY plane.
The Z height of the resulting Face3D will be at the minimum floor height.
Args:
match_walls: Boolean to note whether vertices should be inserted into
the final Face3D that will help match the segments of the result
Expand All @@ -583,7 +583,7 @@ def horizontal_floor_boundaries(self, match_walls=False, tolerance=0.01):
floor area in the result.
The Z height of the resulting Face3D will be at the minimum floor height.
Args:
match_walls: Boolean to note whether vertices should be inserted into
the final Face3Ds that will help match the segments of the result
Expand All @@ -610,7 +610,7 @@ def horizontal_floor_boundaries(self, match_walls=False, tolerance=0.01):
holes = None
if flr_geo[0].has_holes:
holes = [[Point3D(p.x, p.y, floor_height) for p in hole]
for hole in flr_geo[0].holes]
for hole in flr_geo[0].holes]
horiz_bound = [Face3D(bound, holes=holes)]
else: # multiple geometries to be joined together
floor_height = self.geometry.min.z
Expand All @@ -624,7 +624,7 @@ def horizontal_floor_boundaries(self, match_walls=False, tolerance=0.01):
holes = None
if fg.has_holes:
holes = [[Point3D(p.x, p.y, floor_height) for p in hole]
for hole in fg.holes]
for hole in fg.holes]
horiz_geo.append(Face3D(bound, holes=holes))
# join the coplanar horizontal faces together
horiz_bound = Face3D.join_coplanar_faces(horiz_geo, tolerance)
Expand Down Expand Up @@ -886,7 +886,7 @@ def simplify_apertures(self, tolerance=0.01):
if not isinstance(face.boundary_condition, Outdoors):
face.boundary_condition = boundary_conditions.outdoors
face.apertures_by_ratio(face.aperture_ratio, tolerance)

def rectangularize_apertures(
self, subdivision_distance=None, max_separation=None, merge_all=False,
tolerance=0.01, angle_tolerance=1.0):
Expand Down Expand Up @@ -1487,7 +1487,7 @@ def merge_coplanar_faces(
intact. Useful for cases where alignment of walls with the
Room.horizontal_boundary is desired without disrupting the roof
geometry. (Default: False).
Returns:
A list containing only the new Faces that were created as part of the
merging process. These new Faces will have as many properties of the
Expand Down Expand Up @@ -2073,13 +2073,13 @@ def check_room_volume_collisions(rooms, tolerance=0.01, detailed=False):
def grouped_horizontal_boundary(
rooms, min_separation=0, tolerance=0.01, floors_only=True):
"""Get a list of Face3D for the horizontal boundary around several Rooms.
This method will attempt to produce a boundary that follows along the
This method will attempt to produce a boundary that follows along the
outer parts of the Floors of the Rooms so it is not suitable for groups
of Rooms that overlap one another in plan. This method may return an empty
list if the min_separation is so large that a continuous boundary could not
be determined.
Args:
rooms: A list of Honeybee Rooms for which the horizontal boundary will
be computed.
Expand Down Expand Up @@ -2140,7 +2140,7 @@ def grouped_horizontal_boundary(
# if the min_separation is small, use the more reliable intersection method
if min_separation <= tolerance:
closed_polys = Polygon2D.joined_intersected_boundary(floor_polys, tolerance)
else: # otherwise, use the more intense and less reliable gap crossing method
else: # otherwise, use the more intense and less reliable gap crossing method
closed_polys = Polygon2D.gap_crossing_boundary(
floor_polys, min_separation, tolerance)

Expand All @@ -2161,7 +2161,7 @@ def grouped_horizontal_boundary(
else: # need to separate holes from distinct Face3Ds
bound_faces = []
for poly in clean_polys:
pts3d = tuple(Point3D(pt.x, pt.y, z_min) for pt in poly)
pts3d = tuple(Point3D(pt.x, pt.y, z_min) for pt in poly)
bound_faces.append(Face3D(pts3d))
return Face3D.merge_faces_to_holes(bound_faces, tolerance)

Expand Down Expand Up @@ -2427,7 +2427,7 @@ def _base_horiz_boundary(self, tolerance=0.01):
holes = None
if flr_geo[0].has_holes:
holes = [[Point3D(p.x, p.y, floor_height) for p in hole]
for hole in flr_geo[0].holes]
for hole in flr_geo[0].holes]
return Face3D(bound, holes=holes)
else: # multiple geometries to be joined together
floor_height = self.geometry.min.z
Expand All @@ -2441,7 +2441,7 @@ def _base_horiz_boundary(self, tolerance=0.01):
holes = None
if fg.has_holes:
holes = [[Point3D(p.x, p.y, floor_height) for p in hole]
for hole in fg.holes]
for hole in fg.holes]
horiz_geo.append(Face3D(bound, holes=holes))
# sense if there are overlapping geometries to be boolean unioned
overlap_groups = Face3D.group_by_coplanar_overlap(horiz_geo, tolerance)
Expand Down

0 comments on commit 42b0787

Please sign in to comment.