From f92c939739f4c4cc0c23dd59556aef702296e30c Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Fri, 17 May 2024 14:37:45 -0700 Subject: [PATCH] fix(room2d): Ensure that joining rooms across distance preserves windows --- dragonfly/room2d.py | 53 ++++++++++++++++++-- tests/json/model_with_with_separation.dfjson | 1 + tests/model_test.py | 17 ++++++- 3 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 tests/json/model_with_with_separation.dfjson diff --git a/dragonfly/room2d.py b/dragonfly/room2d.py index 44ac1e7c..64038ef1 100644 --- a/dragonfly/room2d.py +++ b/dragonfly/room2d.py @@ -1731,6 +1731,13 @@ def update_floor_geometry(self, new_floor_geometry, edit_code, tolerance=0.01): which they are considered co-located, used to determine colinearity. Default: 0.01, suitable for objects in meters. """ + # process the new floor geometry so that it abides by Room2D rules + if new_floor_geometry.normal.z <= 0: # ensure upward-facing Face3D + new_floor_geometry = new_floor_geometry.flip() + o_pl = Plane(Vector3D(0, 0, 1), Point3D(0, 0, new_floor_geometry.plane.o.z)) + new_floor_geometry = Face3D(new_floor_geometry.boundary, o_pl, + new_floor_geometry.holes) + # get the original and the new floor segments orig_segs = self.floor_segments new_segs = new_floor_geometry.boundary_segments if new_floor_geometry.holes is \ @@ -3016,12 +3023,50 @@ def join_room_2ds(room_2ds, min_separation=0, tolerance=0.01): if len(h_bnds) == len(room_2ds): # no Room2Ds to join; return them as they are return room_2ds - # ensure vertices at the boundary exist + # ensure Room2D vertices at the boundary exist if min_separation <= tolerance: room_2ds = Room2D.intersect_adjacency(room_2ds, tolerance) - else: - pass - #update_floor_geometry + else: # we have to figure out if new vertices were added to cross the boundary + # gather all vertices across the horizontal boundaries + bnd_verts = [] + for h_bnd in h_bnds: + bnd_verts.extend([Point2D(pt.x, pt.y) for pt in h_bnd.boundary]) + if h_bnd.has_holes: + for hole in h_bnd.holes: + bnd_verts.extend([Point2D(pt.x, pt.y) for pt in hole]) + # loop through rooms and identify vertices to insert + inter_rooms = [] + search_dist = tolerance * 2 + for room in room_2ds: + floor_segs = [room.floor_geometry.boundary_polygon2d.segments] + if room.floor_geometry.has_holes: + for hole in room.floor_geometry.hole_polygon2d: + floor_segs.append(hole.segments) + pts_2d, edit_code = [], [] + for loop in floor_segs: + loop_pts_2d = [] + for seg in loop: + loop_pts_2d.append(seg.p1) + edit_code.append('K') + for bnd_pt in bnd_verts: + if seg.distance_to_point(bnd_pt) <= search_dist: + if not seg.p1.is_equivalent(bnd_pt, tolerance) and \ + not seg.p2.is_equivalent(bnd_pt, tolerance): + loop_pts_2d.append(bnd_pt) # vertex to insert ! + edit_code.append('A') + pts_2d.append(loop_pts_2d) + edit_code = ''.join(edit_code) + if 'A' in edit_code: # room geometry must be updated + room = room.duplicate() # duplicate to avoid editing original geo + z_v = room.floor_height + pts_3d = [] + for loop in pts_2d: + pts_3d.append([Point3D(pt.x, pt.y, z_v) for pt in loop]) + new_geo = Face3D(pts_3d[0]) if len(pts_3d) == 1 else \ + Face3D(pts_3d[0], holes=pts_3d[1:]) + room.update_floor_geometry(new_geo, edit_code, search_dist) + inter_rooms.append(room) + room_2ds = inter_rooms # join the Room2Ds according to the horizontal boundaries that were found joined_rooms = [] diff --git a/tests/json/model_with_with_separation.dfjson b/tests/json/model_with_with_separation.dfjson new file mode 100644 index 00000000..e0f52db4 --- /dev/null +++ b/tests/json/model_with_with_separation.dfjson @@ -0,0 +1 @@ +{"display_name": "Model_63a86abc-3891-4a90-83dd-5aa7111c57fc", "identifier": "Model_63a86abc-3891-4a90-83dd-5aa7111c57fc", "tolerance": 0.01, "angle_tolerance": 1.0, "buildings": [{"display_name": "Unnamed", "identifier": "Model_63a86abc-3891-4a90-83dd-5aa7111c57fc", "unique_stories": [{"display_name": "0", "identifier": "0", "multiplier": 1, "floor_to_floor_height": 3.0, "room_2ds": [{"display_name": "Room 2", "identifier": "Room_afe9e143", "floor_boundary": [[5.0, -0.20000000000000001], [0.0, -0.20000000000000001], [0.0, -5.2000000000000002], [5.0, -5.2000000000000002]], "is_ground_contact": true, "is_top_exposed": true, "skylight_parameters": {"are_doors": [false], "type": "DetailedSkylights", "polygons": [[[1.7416287770370027, -3.5381030478768922], [3.2917975215855746, -3.5381030478768922], [3.2917975215855746, -2.4523511118915877], [1.7416287770370027, -2.4523511118915877]]]}, "floor_to_ceiling_height": 3.0, "user_data": {"__layer__": "Default"}, "type": "Room2D", "window_parameters": [null, {"are_doors": [false], "type": "DetailedWindows", "polygons": [[[0.91886116991581024, 2.448683298050514], [0.91886116991581024, 0.55131670194948623], [4.08113883008419, 0.55131670194948623], [4.08113883008419, 2.448683298050514]]]}, {"are_doors": [false], "type": "DetailedWindows", "polygons": [[[0.91886116991581024, 2.448683298050514], [0.91886116991581024, 0.55131670194948623], [4.08113883008419, 0.55131670194948623], [4.08113883008419, 2.448683298050514]]]}, {"are_doors": [false], "type": "DetailedWindows", "polygons": [[[4.08113883008419, 0.55131670194948623], [4.08113883008419, 2.448683298050514], [0.91886116991581002, 2.448683298050514], [0.91886116991581002, 0.55131670194948623]]]}], "floor_height": 0.0, "boundary_conditions": [{"view_factor": {"type": "Autocalculate"}, "sun_exposure": true, "wind_exposure": true, "type": "Outdoors"}, {"view_factor": {"type": "Autocalculate"}, "sun_exposure": true, "wind_exposure": true, "type": "Outdoors"}, {"view_factor": {"type": "Autocalculate"}, "sun_exposure": true, "wind_exposure": true, "type": "Outdoors"}, {"view_factor": {"type": "Autocalculate"}, "sun_exposure": true, "wind_exposure": true, "type": "Outdoors"}], "properties": {"radiance": {"type": "Room2DRadiancePropertiesAbridged"}, "energy": {"type": "Room2DEnergyPropertiesAbridged"}, "type": "Room2DPropertiesAbridged", "uwg": {"type": "Room2DUWGPropertiesAbridged"}}}, {"display_name": "Room 2", "identifier": "Room_6ed35c1a", "floor_boundary": [[10.0, 5.0], [0.0, 5.0], [0.0, 0.0], [10.0, 0.0]], "is_ground_contact": true, "is_top_exposed": true, "skylight_parameters": {"are_doors": [false], "type": "DetailedSkylights", "polygons": [[[5.4723798882043333, 2.1067721958180647], [8.2278316303866035, 2.1067721958180647], [8.2278316303866035, 3.6432466399962631], [5.4723798882043333, 3.6432466399962631]]]}, "floor_to_ceiling_height": 3.0, "user_data": {"__layer__": "Default"}, "type": "Room2D", "window_parameters": [{"are_doors": [false], "type": "DetailedWindows", "polygons": [[[8.16227766016838, 0.55131670194948623], [8.16227766016838, 2.448683298050514], [1.83772233983162, 2.448683298050514], [1.83772233983162, 0.55131670194948623]]]}, {"are_doors": [false], "type": "DetailedWindows", "polygons": [[[4.08113883008419, 0.55131670194948623], [4.08113883008419, 2.448683298050514], [0.91886116991581002, 2.448683298050514], [0.91886116991581002, 0.55131670194948623]]]}, {"are_doors": [false], "type": "DetailedWindows", "polygons": [[[6.4680055394714326, 2.448683298050514], [6.4680055394714326, 0.55131670194948623], [9.2047777110119799, 0.55131670194948623], [9.2047777110119799, 2.448683298050514]]]}, {"are_doors": [false], "type": "DetailedWindows", "polygons": [[[0.91886116991581024, 2.448683298050514], [0.91886116991581024, 0.55131670194948623], [4.08113883008419, 0.55131670194948623], [4.08113883008419, 2.448683298050514]]]}], "floor_height": 0.0, "boundary_conditions": [{"view_factor": {"type": "Autocalculate"}, "sun_exposure": true, "wind_exposure": true, "type": "Outdoors"}, {"view_factor": {"type": "Autocalculate"}, "sun_exposure": true, "wind_exposure": true, "type": "Outdoors"}, {"view_factor": {"type": "Autocalculate"}, "sun_exposure": true, "wind_exposure": true, "type": "Outdoors"}, {"view_factor": {"type": "Autocalculate"}, "sun_exposure": true, "wind_exposure": true, "type": "Outdoors"}], "properties": {"radiance": {"type": "Room2DRadiancePropertiesAbridged"}, "energy": {"type": "Room2DEnergyPropertiesAbridged"}, "type": "Room2DPropertiesAbridged", "uwg": {"type": "Room2DUWGPropertiesAbridged"}}}], "type": "Story", "floor_height": 0.0, "properties": {"radiance": {"type": "StoryRadiancePropertiesAbridged"}, "energy": {"type": "StoryEnergyPropertiesAbridged"}, "type": "StoryPropertiesAbridged", "uwg": {"type": "StoryUWGPropertiesAbridged"}}}], "type": "Building", "properties": {"radiance": {"type": "BuildingRadiancePropertiesAbridged"}, "energy": {"type": "BuildingEnergyPropertiesAbridged"}, "type": "BuildingPropertiesAbridged", "uwg": {"fract_heat_to_canyon": 0.5, "vintage": "New", "roof_veg_fraction": 0.0, "program": "LargeOffice", "type": "BuildingUWGPropertiesAbridged"}}}], "type": "Model", "version": "1.11.2", "units": "Meters", "properties": {"radiance": {"modifiers": [], "type": "ModelRadianceProperties", "global_modifier_set": {"shade_set": {"type": "ShadeModifierSetAbridged", "interior_modifier": "generic_interior_shade_0.50", "exterior_modifier": "generic_exterior_shade_0.35"}, "roof_ceiling_set": {"type": "RoofCeilingModifierSetAbridged", "interior_modifier": "generic_ceiling_0.80", "exterior_modifier": "generic_ceiling_0.80"}, "context_modifier": "generic_context_0.20", "modifiers": [{"dependencies": [], "modifier": null, "g_reflectance": 0.5, "identifier": "generic_wall_0.50", "specularity": 0.0, "b_reflectance": 0.5, "r_reflectance": 0.5, "type": "Plastic", "roughness": 0.0}, {"b_transmissivity": 0.95841543286105957, "r_transmissivity": 0.95841543286105957, "modifier": null, "identifier": "generic_interior_window_vis_0.88", "refraction_index": null, "type": "Glass", "dependencies": [], "g_transmissivity": 0.95841543286105957}, {"dependencies": [], "modifier": null, "g_reflectance": 0.5, "identifier": "generic_interior_shade_0.50", "specularity": 0.0, "b_reflectance": 0.5, "r_reflectance": 0.5, "type": "Plastic", "roughness": 0.0}, {"dependencies": [], "modifier": null, "g_reflectance": 0.20000000000000001, "identifier": "generic_floor_0.20", "specularity": 0.0, "b_reflectance": 0.20000000000000001, "r_reflectance": 0.20000000000000001, "type": "Plastic", "roughness": 0.0}, {"dependencies": [], "modifier": null, "g_reflectance": 0.80000000000000004, "identifier": "generic_ceiling_0.80", "specularity": 0.0, "b_reflectance": 0.80000000000000004, "r_reflectance": 0.80000000000000004, "type": "Plastic", "roughness": 0.0}, {"b_transmissivity": 0.69757618153843315, "r_transmissivity": 0.69757618153843315, "modifier": null, "identifier": "generic_exterior_window_vis_0.64", "refraction_index": null, "type": "Glass", "dependencies": [], "g_transmissivity": 0.69757618153843315}, {"r_reflectance": 1.0, "b_reflectance": 1.0, "roughness": 0.0, "identifier": "air_boundary", "type": "Trans", "dependencies": [], "g_reflectance": 1.0, "specularity": 0.0, "transmitted_diff": 1.0, "transmitted_spec": 1.0, "modifier": null}, {"dependencies": [], "modifier": null, "g_reflectance": 0.34999999999999998, "identifier": "generic_exterior_shade_0.35", "specularity": 0.0, "b_reflectance": 0.34999999999999998, "r_reflectance": 0.34999999999999998, "type": "Plastic", "roughness": 0.0}, {"dependencies": [], "modifier": null, "g_reflectance": 0.5, "identifier": "generic_opaque_door_0.50", "specularity": 0.0, "b_reflectance": 0.5, "r_reflectance": 0.5, "type": "Plastic", "roughness": 0.0}, {"dependencies": [], "modifier": null, "g_reflectance": 0.20000000000000001, "identifier": "generic_context_0.20", "specularity": 0.0, "b_reflectance": 0.20000000000000001, "r_reflectance": 0.20000000000000001, "type": "Plastic", "roughness": 0.0}], "wall_set": {"type": "WallModifierSetAbridged", "interior_modifier": "generic_wall_0.50", "exterior_modifier": "generic_wall_0.50"}, "door_set": {"exterior_glass_modifier": "generic_exterior_window_vis_0.64", "interior_glass_modifier": "generic_interior_window_vis_0.88", "overhead_modifier": "generic_opaque_door_0.50", "exterior_modifier": "generic_opaque_door_0.50", "interior_modifier": "generic_opaque_door_0.50", "type": "DoorModifierSetAbridged"}, "floor_set": {"type": "FloorModifierSetAbridged", "interior_modifier": "generic_floor_0.20", "exterior_modifier": "generic_floor_0.20"}, "type": "GlobalModifierSet", "aperture_set": {"interior_modifier": "generic_interior_window_vis_0.88", "window_modifier": "generic_exterior_window_vis_0.64", "skylight_modifier": "generic_exterior_window_vis_0.64", "type": "ApertureModifierSetAbridged", "operable_modifier": "generic_exterior_window_vis_0.64"}, "air_boundary_modifier": "air_boundary"}, "modifier_sets": []}, "energy": {"constructions": [], "materials": [], "shws": [], "hvacs": [], "schedule_type_limits": [], "type": "ModelEnergyProperties", "global_construction_set": {"constructions": [{"solar_reflectance": 0.20000000000000001, "identifier": "Generic Context", "visible_reflectance": 0.20000000000000001, "is_specular": false, "type": "ShadeConstruction"}, {"type": "WindowConstructionAbridged", "identifier": "Generic Single Pane", "materials": ["Generic Clear Glass"]}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Interior Wall", "materials": ["Generic Gypsum Board", "Generic Wall Air Gap", "Generic Gypsum Board"]}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Exposed Floor", "materials": ["Generic Painted Metal", "Generic Ceiling Air Gap", "Generic 50mm Insulation", "Generic LW Concrete"]}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Roof", "materials": ["Generic Roof Membrane", "Generic 50mm Insulation", "Generic LW Concrete", "Generic Ceiling Air Gap", "Generic Acoustic Tile"]}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Exterior Door", "materials": ["Generic Painted Metal", "Generic 25mm Insulation", "Generic Painted Metal"]}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Interior Door", "materials": ["Generic 25mm Wood"]}, {"air_mixing_schedule": "Always On", "type": "AirBoundaryConstructionAbridged", "identifier": "Generic Air Boundary", "air_mixing_per_area": 0.10000000000000001}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Interior Floor", "materials": ["Generic Acoustic Tile", "Generic Ceiling Air Gap", "Generic LW Concrete"]}, {"solar_reflectance": 0.34999999999999998, "identifier": "Generic Shade", "visible_reflectance": 0.34999999999999998, "is_specular": false, "type": "ShadeConstruction"}, {"type": "WindowConstructionAbridged", "identifier": "Generic Double Pane", "materials": ["Generic Low-e Glass", "Generic Window Air Gap", "Generic Clear Glass"]}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Underground Roof", "materials": ["Generic 50mm Insulation", "Generic HW Concrete", "Generic Ceiling Air Gap", "Generic Acoustic Tile"]}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Exterior Wall", "materials": ["Generic Brick", "Generic LW Concrete", "Generic 50mm Insulation", "Generic Wall Air Gap", "Generic Gypsum Board"]}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Underground Wall", "materials": ["Generic 50mm Insulation", "Generic HW Concrete", "Generic Wall Air Gap", "Generic Gypsum Board"]}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Interior Ceiling", "materials": ["Generic LW Concrete", "Generic Ceiling Air Gap", "Generic Acoustic Tile"]}, {"type": "OpaqueConstructionAbridged", "identifier": "Generic Ground Slab", "materials": ["Generic 50mm Insulation", "Generic HW Concrete"]}], "materials": [{"conductivity": 0.14999999999999999, "specific_heat": 1630.0, "density": 608.0, "thermal_absorptance": 0.90000000000000002, "thickness": 0.025399999999999999, "solar_absorptance": 0.5, "visible_absorptance": 0.5, "roughness": "MediumSmooth", "type": "EnergyMaterial", "identifier": "Generic 25mm Wood"}, {"visible_reflectance_back": 0.20999999999999999, "solar_reflectance": 0.35999999999999999, "visible_reflectance": 0.20999999999999999, "type": "EnergyWindowMaterialGlazing", "emissivity_back": 0.047, "emissivity": 0.83999999999999997, "dirt_correction": 1.0, "solar_diffusing": false, "visible_transmittance": 0.70999999999999996, "infrared_transmittance": 0.0, "conductivity": 1.0, "solar_reflectance_back": 0.35999999999999999, "identifier": "Generic Low-e Glass", "solar_transmittance": 0.45000000000000001, "thickness": 0.0060000000000000001}, {"conductivity": 0.53000000000000003, "specific_heat": 840.0, "density": 1280.0, "thermal_absorptance": 0.90000000000000002, "thickness": 0.10000000000000001, "solar_absorptance": 0.80000000000000004, "visible_absorptance": 0.80000000000000004, "roughness": "MediumRough", "type": "EnergyMaterial", "identifier": "Generic LW Concrete"}, {"conductivity": 0.55600000000000005, "specific_heat": 1000.0, "density": 1.28, "thermal_absorptance": 0.90000000000000002, "thickness": 0.10000000000000001, "solar_absorptance": 0.69999999999999996, "visible_absorptance": 0.69999999999999996, "roughness": "Smooth", "type": "EnergyMaterial", "identifier": "Generic Ceiling Air Gap"}, {"conductivity": 0.059999999999999998, "specific_heat": 590.0, "density": 368.0, "thermal_absorptance": 0.90000000000000002, "thickness": 0.02, "solar_absorptance": 0.20000000000000001, "visible_absorptance": 0.20000000000000001, "roughness": "MediumSmooth", "type": "EnergyMaterial", "identifier": "Generic Acoustic Tile"}, {"conductivity": 1.95, "specific_heat": 900.0, "density": 2240.0, "thermal_absorptance": 0.90000000000000002, "thickness": 0.20000000000000001, "solar_absorptance": 0.80000000000000004, "visible_absorptance": 0.80000000000000004, "roughness": "MediumRough", "type": "EnergyMaterial", "identifier": "Generic HW Concrete"}, {"conductivity": 0.66700000000000004, "specific_heat": 1000.0, "density": 1.28, "thermal_absorptance": 0.90000000000000002, "thickness": 0.10000000000000001, "solar_absorptance": 0.69999999999999996, "visible_absorptance": 0.69999999999999996, "roughness": "Smooth", "type": "EnergyMaterial", "identifier": "Generic Wall Air Gap"}, {"conductivity": 0.16, "specific_heat": 1460.0, "density": 1120.0, "thermal_absorptance": 0.90000000000000002, "thickness": 0.01, "solar_absorptance": 0.65000000000000002, "visible_absorptance": 0.65000000000000002, "roughness": "MediumRough", "type": "EnergyMaterial", "identifier": "Generic Roof Membrane"}, {"conductivity": 0.16, "specific_heat": 1090.0, "density": 800.0, "thermal_absorptance": 0.90000000000000002, "thickness": 0.012699999999999999, "solar_absorptance": 0.5, "visible_absorptance": 0.5, "roughness": "MediumSmooth", "type": "EnergyMaterial", "identifier": "Generic Gypsum Board"}, {"gas_type": "Air", "thickness": 0.012699999999999999, "identifier": "Generic Window Air Gap", "type": "EnergyWindowMaterialGas"}, {"conductivity": 0.90000000000000002, "specific_heat": 790.0, "density": 1920.0, "thermal_absorptance": 0.90000000000000002, "thickness": 0.10000000000000001, "solar_absorptance": 0.65000000000000002, "visible_absorptance": 0.65000000000000002, "roughness": "MediumRough", "type": "EnergyMaterial", "identifier": "Generic Brick"}, {"visible_reflectance_back": 0.080000000000000002, "solar_reflectance": 0.070000000000000007, "visible_reflectance": 0.080000000000000002, "type": "EnergyWindowMaterialGlazing", "emissivity_back": 0.83999999999999997, "emissivity": 0.83999999999999997, "dirt_correction": 1.0, "solar_diffusing": false, "visible_transmittance": 0.88, "infrared_transmittance": 0.0, "conductivity": 1.0, "solar_reflectance_back": 0.070000000000000007, "identifier": "Generic Clear Glass", "solar_transmittance": 0.77000000000000002, "thickness": 0.0060000000000000001}, {"conductivity": 0.029999999999999999, "specific_heat": 1210.0, "density": 43.0, "thermal_absorptance": 0.90000000000000002, "thickness": 0.025000000000000001, "solar_absorptance": 0.69999999999999996, "visible_absorptance": 0.69999999999999996, "roughness": "MediumRough", "type": "EnergyMaterial", "identifier": "Generic 25mm Insulation"}, {"conductivity": 0.029999999999999999, "specific_heat": 1210.0, "density": 43.0, "thermal_absorptance": 0.90000000000000002, "thickness": 0.050000000000000003, "solar_absorptance": 0.69999999999999996, "visible_absorptance": 0.69999999999999996, "roughness": "MediumRough", "type": "EnergyMaterial", "identifier": "Generic 50mm Insulation"}, {"conductivity": 45.0, "specific_heat": 410.0, "density": 7690.0, "thermal_absorptance": 0.90000000000000002, "thickness": 0.0015, "solar_absorptance": 0.5, "visible_absorptance": 0.5, "roughness": "Smooth", "type": "EnergyMaterial", "identifier": "Generic Painted Metal"}], "air_boundary_construction": "Generic Air Boundary", "shade_construction": "Generic Shade", "roof_ceiling_set": {"ground_construction": "Generic Underground Roof", "interior_construction": "Generic Interior Ceiling", "exterior_construction": "Generic Roof", "type": "RoofCeilingConstructionSetAbridged"}, "wall_set": {"ground_construction": "Generic Underground Wall", "interior_construction": "Generic Interior Wall", "exterior_construction": "Generic Exterior Wall", "type": "WallConstructionSetAbridged"}, "door_set": {"overhead_construction": "Generic Exterior Door", "interior_glass_construction": "Generic Single Pane", "exterior_glass_construction": "Generic Double Pane", "type": "DoorConstructionSetAbridged", "interior_construction": "Generic Interior Door", "exterior_construction": "Generic Exterior Door"}, "context_construction": "Generic Context", "floor_set": {"ground_construction": "Generic Ground Slab", "interior_construction": "Generic Interior Floor", "exterior_construction": "Generic Exposed Floor", "type": "FloorConstructionSetAbridged"}, "type": "GlobalConstructionSet", "aperture_set": {"skylight_construction": "Generic Double Pane", "type": "ApertureConstructionSetAbridged", "interior_construction": "Generic Single Pane", "operable_construction": "Generic Double Pane", "window_construction": "Generic Double Pane"}}, "schedules": [], "program_types": [], "construction_sets": []}, "type": "ModelProperties", "uwg": {"grass_coverage_fraction": 0.0, "type": "ModelUWGProperties", "traffic": {"type": "TrafficParameter"}}}} \ No newline at end of file diff --git a/tests/model_test.py b/tests/model_test.py index 95f2f5f3..c068c6d1 100644 --- a/tests/model_test.py +++ b/tests/model_test.py @@ -404,7 +404,7 @@ def test_reset_room_2d_boundaries(): def test_room_2ds_pulling_methods(): - """Test the Room2d.join_room_2ds method.""" + """Test the methods that pull Room2Ds to target objects.""" model_file = './tests/json/model_for_pulling.dfjson' original_model = Model.from_file(model_file) @@ -472,6 +472,21 @@ def test_join_room_2ds(): assert second_story.exterior_aperture_area == pytest.approx(clean_ap_area, rel=1e-3) +def test_join_room_2ds_separation(): + """Test the Room2d.join_room_2ds method with a separation distance.""" + model_file = './tests/json/model_with_with_separation.dfjson' + model = Model.from_file(model_file) + + second_story = model.stories[0] + joined_room_2ds = Room2D.join_room_2ds( + second_story.room_2ds, min_separation=0.3, tolerance=model.tolerance) + assert len(joined_room_2ds) == 1 + joined_room = joined_room_2ds[0] + window_count = sum(1 for wp in joined_room.window_parameters if wp is not None) + assert window_count == 7 + assert len(joined_room.skylight_parameters) == 2 + + def test_suggested_alignment_axes(): """Test the suggested_alignment_axes method on Buildings and Stories.""" model_file = './tests/json/model_with_doors_skylights.dfjson'