Skip to content

Commit

Permalink
fix(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 committed Jun 19, 2024
1 parent b309459 commit a83ce56
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 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

0 comments on commit a83ce56

Please sign in to comment.