Skip to content

Commit db5f2f8

Browse files
chriswmackeyChris Mackey
authored andcommitted
fix(shademesh): Add extension methods for ShadeMesh
1 parent b8237d9 commit db5f2f8

File tree

9 files changed

+63
-10
lines changed

9 files changed

+63
-10
lines changed

honeybee_display/_extend_honeybee.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from honeybee.aperture import Aperture
77
from honeybee.door import Door
88
from honeybee.shade import Shade
9+
from honeybee.shademesh import ShadeMesh
910
from honeybee.colorobj import ColorRoom, ColorFace
1011

1112
# import the extension functions
@@ -15,6 +16,7 @@
1516
from .aperture import aperture_to_vis_set
1617
from .door import door_to_vis_set
1718
from .shade import shade_to_vis_set
19+
from .shademesh import shade_mesh_to_vis_set
1820
from .colorobj import color_room_to_vis_set, color_face_to_vis_set
1921

2022
# inject the methods onto the classes
@@ -25,6 +27,7 @@
2527
Aperture.to_vis_set = aperture_to_vis_set
2628
Door.to_vis_set = door_to_vis_set
2729
Shade.to_vis_set = shade_to_vis_set
30+
ShadeMesh.to_vis_set = shade_mesh_to_vis_set
2831
ColorRoom.to_vis_set = color_room_to_vis_set
2932
ColorFace.to_vis_set = color_face_to_vis_set
3033

honeybee_display/aperture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def aperture_to_vis_set(aperture, color_by='type'):
77
"""Translate a Honeybee Aperture to a VisualizationSet.
88
99
Args:
10-
model: A Honeybee Aperture object to be converted to a VisualizationSet.
10+
aperture: A Honeybee Aperture object to be converted to a VisualizationSet.
1111
color_by: Text for the property that dictates the colors of the Aperture
1212
geometry. (Default: type). Choose from the following:
1313

honeybee_display/door.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def door_to_vis_set(door, color_by='type'):
77
"""Translate a Honeybee Door to a VisualizationSet.
88
99
Args:
10-
model: A Honeybee Door object to be converted to a VisualizationSet.
10+
door: A Honeybee Door object to be converted to a VisualizationSet.
1111
color_by: Text for the property that dictates the colors of the Door
1212
geometry. (Default: type). Choose from the following:
1313

honeybee_display/face.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def face_to_vis_set(face, color_by='type'):
77
"""Translate a Honeybee Face to a VisualizationSet.
88
99
Args:
10-
model: A Honeybee Face object to be converted to a VisualizationSet.
10+
face: A Honeybee Face object to be converted to a VisualizationSet.
1111
color_by: Text for the property that dictates the colors of the Face
1212
geometry. (Default: type). Choose from the following:
1313

honeybee_display/model.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import json
44

5-
from ladybug_geometry.geometry3d import Point3D
5+
from ladybug_geometry.geometry3d import Point3D, Face3D
66
from ladybug.datatype.generic import GenericType
77
from ladybug.color import Color
88
from ladybug_display.geometry3d import DisplayPoint3D, DisplayLineSegment3D, \
@@ -171,6 +171,12 @@ def model_to_vis_set(
171171
type_dict['Outdoor Shade'].append(shd.geometry)
172172
for shd in model.indoor_shades:
173173
type_dict['Indoor Shade'].append(shd.geometry)
174+
# add all of the shade meshes to the dictionary
175+
for shd in model.shade_meshes:
176+
if shd.is_detached:
177+
type_dict['Context Shade'].append(shd.geometry)
178+
else:
179+
type_dict['Outdoor Shade'].append(shd.geometry)
174180
elif color_by == 'boundary_condition':
175181
type_dict = {
176182
'Outdoors': [], 'Surface': [], 'Ground': [], 'Adiabatic': [], 'Other': []}
@@ -209,6 +215,9 @@ def model_to_vis_set(
209215
# add all shades to the dictionary
210216
for shd in model.shades:
211217
type_dict['Other'].append(shd.geometry)
218+
# add all of the shade meshes to the dictionary
219+
for shd in model.shade_meshes:
220+
type_dict['Other'].append(shd.geometry)
212221
elif color_by == 'none':
213222
type_dict = {}
214223
else: # unrecognized property for coloring
@@ -221,12 +230,16 @@ def model_to_vis_set(
221230
if len(geometries) != 0:
222231
col = TYPE_COLORS[geo_id] if color_by == 'type' else BC_COLORS[geo_id]
223232
if use_mesh:
224-
dis_geos = [DisplayMesh3D(f.triangulated_mesh3d, color=col)
225-
for f in geometries]
233+
dis_geos = []
234+
for f in geometries:
235+
c_geo = f.triangulated_mesh3d if isinstance(f, Face3D) else f
236+
dis_geos.append(DisplayMesh3D(c_geo, color=col))
226237
else:
227238
dis_geos = []
228239
for geo in geometries:
229-
dis_geos.append(DisplayFace3D(geo, col))
240+
c_geo = DisplayFace3D(geo, color=col) if isinstance(geo, Face3D) \
241+
else DisplayMesh3D(geo, color=col)
242+
dis_geos.append(c_geo)
230243
con_geo = ContextGeometry(geo_id.replace(' ', '_'), dis_geos)
231244
if hide_color_by:
232245
con_geo.hidden = True
@@ -447,6 +460,10 @@ def _process_wireframe(face3d, wireframe, line_width=1):
447460
for shd in model.outdoor_shades:
448461
lw = 2 if shd.is_detached else 1
449462
_process_wireframe(shd.geometry, wireframe, lw)
463+
for shd_m in model.shade_meshes:
464+
lw = 2 if shd_m.is_detached else 1
465+
for seg in shd_m.geometry.edges:
466+
wireframe.append(DisplayLineSegment3D(seg, line_width=lw))
450467

451468
# build the VisualizationSet and return it
452469
if len(wireframe) == 0:

honeybee_display/room.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def room_to_vis_set(room, color_by='type'):
88
"""Translate a Honeybee Room to a VisualizationSet.
99
1010
Args:
11-
model: A Honeybee Room object to be converted to a VisualizationSet.
11+
room: A Honeybee Room object to be converted to a VisualizationSet.
1212
color_by: Text for the property that dictates the colors of the Room
1313
geometry. (Default: type). Choose from the following:
1414

honeybee_display/shade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def shade_to_vis_set(shade, color_by='type'):
77
"""Translate a Honeybee Shade to a VisualizationSet.
88
99
Args:
10-
model: A Honeybee Shade object to be converted to a VisualizationSet.
10+
shade: A Honeybee Shade object to be converted to a VisualizationSet.
1111
color_by: Text for the property that dictates the colors of the Shade
1212
geometry. (Default: type). Choose from the following:
1313

honeybee_display/shademesh.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Method to translate a ShadeMesh to a VisualizationSet."""
2+
from ladybug_display.geometry3d import DisplayMesh3D
3+
from ladybug_display.visualization import VisualizationSet, ContextGeometry
4+
5+
6+
7+
def shade_mesh_to_vis_set(shade, color_by='type'):
8+
"""Translate a Honeybee ShadeMesh to a VisualizationSet.
9+
10+
Args:
11+
shade: A Honeybee ShadeMesh object to be converted to a VisualizationSet.
12+
color_by: Text for the property that dictates the colors of the Shade
13+
geometry. (Default: type). Choose from the following:
14+
15+
* type
16+
* boundary_condition
17+
18+
Returns:
19+
A VisualizationSet object that represents the ShadeMesh with a
20+
single ContextGeometry.
21+
"""
22+
# get the basic properties for geometry conversion
23+
color_by_attr = 'type_color' if color_by.lower() == 'type' else 'bc_color'
24+
d_mod = 'SurfaceWithEdges'
25+
# convert all geometry into DisplayFace3D
26+
a_col = getattr(shade, color_by_attr)
27+
dis_geos = [DisplayMesh3D(shade.geometry, a_col, d_mod)]
28+
# build the VisualizationSet and ContextGeometry
29+
con_geo = ContextGeometry(shade.identifier, dis_geos)
30+
con_geo.display_name = shade.display_name
31+
vis_set = VisualizationSet(shade.identifier, [con_geo])
32+
vis_set.display_name = shade.display_name
33+
return vis_set

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
ladybug-display>=0.7.2
2-
honeybee-core>=1.56.18
2+
honeybee-core>=1.57.9

0 commit comments

Comments
 (0)