Skip to content

Commit

Permalink
style(room): Add extra step to remove degenerate geo during intersect
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Jun 19, 2024
1 parent b309459 commit c22383e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion honeybee/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ def reset_ids(self, repair_surface_bcs=True):
new_id = clean_and_number_string(
dr.display_name, dr_dict, 'Door identifier')
dr_map[dr.identifier] = new_id
dr.identifier =new_id
dr.identifier = new_id
for shade in self.shades:
shade.identifier = clean_and_number_string(
shade.display_name, shd_dict, 'Shade identifier')
Expand Down
7 changes: 6 additions & 1 deletion honeybee/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,12 @@ def coplanar_split(self, geometry, tolerance=0.01, angle_tolerance=1):
for f_geo in geo_dict[face_1.identifier]:
f_split, _ = Face3D.coplanar_split(
f_geo, face_2, tolerance, ang_tol)
new_geo.extend(f_split)
for sp_g in f_split:
try:
sp_g = sp_g.remove_colinear_vertices(tolerance)
new_geo.append(sp_g)
except AssertionError: # degenerate geometry to ignore
pass
geo_dict[face_1.identifier] = new_geo

# use the intersected geometry to remake this room's faces
Expand Down
11 changes: 6 additions & 5 deletions tests/model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,15 @@ def test_reset_room_ids():
"""Test the reset_room_ids method."""
model_json = './tests/json/model_with_adiabatic.hbjson'
parsed_model = Model.from_hbjson(model_json)

new_model = parsed_model.duplicate()
new_model.reset_room_ids()

assert new_model.rooms[0].identifier != parsed_model.rooms[0].identifier


def test_reset_ids():
"""Test the reset_room_ids method."""
"""Test the reset_ids method."""
model_json = './tests/json/model_with_adiabatic.hbjson'
parsed_model = Model.from_hbjson(model_json)

Expand All @@ -404,7 +404,7 @@ def test_offset_aperture_edges():
new_area = test_face.aperture_area
assert new_area < orig_area
assert len(test_face.apertures) == 3

test_face.offset_aperture_edges(0.6, 0.01)
new_area = test_face.aperture_area
assert new_area > orig_area
Expand Down Expand Up @@ -619,7 +619,8 @@ def test_rotate():
assert room.center.x == pytest.approx(r_cent.x, rel=1e-3)
assert room.center.y == pytest.approx(r_cent.y, rel=1e-3)
assert room.center.z == pytest.approx(r_cent.z, rel=1e-3)
shd_cent = model.rooms[0][3].apertures[0].outdoor_shades[0].center.rotate(axis, math.radians(-90), origin)
shd_cent = model.rooms[0][3].apertures[0].outdoor_shades[0].center.rotate(
axis, math.radians(-90), origin)
assert south_face.apertures[0].outdoor_shades[0].center.x == pytest.approx(shd_cent.x, rel=1e-3)
assert south_face.apertures[0].outdoor_shades[0].center.y == pytest.approx(shd_cent.y, rel=1e-3)
assert south_face.apertures[0].outdoor_shades[0].center.z == pytest.approx(shd_cent.z, rel=1e-3)
Expand Down Expand Up @@ -832,7 +833,7 @@ def test_check_duplicate_shade_mesh_identifiers():
assert model.check_duplicate_shade_mesh_identifiers(False) == ''
pts2 = (Point3D(0, 0, 2), Point3D(0, 2, 2), Point3D(2, 2, 2))
mesh2 = Mesh3D(pts2, [(0, 1, 2)])
model.add_shade_mesh( ShadeMesh('Awning_1', mesh2))
model.add_shade_mesh(ShadeMesh('Awning_1', mesh2))
assert model.check_duplicate_shade_mesh_identifiers(False) != ''
with pytest.raises(ValueError):
model.check_duplicate_shade_mesh_identifiers(True)
Expand Down
6 changes: 3 additions & 3 deletions tests/room_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from honeybee.facetype import face_types



def test_init():
"""Test the initialization of a room and basic properties."""
pts_1 = [Point3D(0, 0, 0), Point3D(0, 10, 0), Point3D(10, 10, 0), Point3D(10, 0, 0)]
Expand Down Expand Up @@ -575,7 +574,7 @@ def test_find_adjacency():
assert len(adj_faces) == 1
assert len(adj_faces[0]) == 2

adj_info = Room.solve_adjacency([room_south, room_north], 0.01)
Room.solve_adjacency([room_south, room_north], 0.01)

# make sure it all still works after the Surface BC is already set
adj_faces = Room.find_adjacency([room_south, room_north], 0.01)
Expand Down Expand Up @@ -684,7 +683,7 @@ def test_group_by_orientation():
room_5 = Room.from_polyface3d('Zone5', pf_5)

rooms = [room_1, room_2, room_3, room_4, room_5]
adj_info = Room.solve_adjacency(rooms, 0.01)
Room.solve_adjacency(rooms, 0.01)
grouped_rooms, core_rooms, orientations = Room.group_by_orientation(rooms)

assert len(grouped_rooms) == 4
Expand All @@ -706,6 +705,7 @@ def test_horizontal_boundary():
assert isinstance(hb, Face3D)
assert hb.area > 99


def test_grouped_horizontal_boundary():
"""Test the grouped_horizontal_boundary method."""
geo_file = './tests/json/polygons_for_gap_boundary.json'
Expand Down

0 comments on commit c22383e

Please sign in to comment.