Skip to content

Commit 1127475

Browse files
chriswmackeyChris Mackey
authored andcommitted
fix(colorobj): Ensure that Color Faces can work with ShadeMesh
1 parent db5f2f8 commit 1127475

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

honeybee_display/colorobj.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,7 @@ def color_face_to_vis_set(
166166
# loop through the faces and create the text labels
167167
for face_prop, f_geo in zip(color_face.attributes, color_face.flat_geometry):
168168
if face_prop != 'N/A':
169-
cent_pt = f_geo.center if f_geo.is_convex else \
170-
f_geo.pole_of_inaccessibility(p_tol)
171-
cent_pt = cent_pt.move(f_geo.normal * offset_from_base)
172-
base_plane = Plane(f_geo.normal, cent_pt)
173-
if base_plane.y.z < 0: # base plane pointing downwards; rotate it
174-
base_plane = base_plane.rotate(base_plane.n, math.pi, base_plane.o)
169+
# compute the text height
175170
if txt_height is None: # auto-calculate default text height
176171
txt_len = len(face_prop) if len(face_prop) > 10 else 10
177172
dims = [
@@ -185,12 +180,23 @@ def color_face_to_vis_set(
185180
if txt_h < tolerance:
186181
continue
187182
txt_h = max_txt_h if txt_h > max_txt_h else txt_h
188-
# move base plane origin a little to avoid overlaps of adjacent labels
189-
if base_plane.n.x != 0:
190-
m_vec = base_plane.y if base_plane.n.x < 0 else -base_plane.y
191-
else:
192-
m_vec = base_plane.y if base_plane.n.z < 0 else -base_plane.y
193-
base_plane = base_plane.move(m_vec * txt_h)
183+
# get the base plane of the geometry
184+
if isinstance(f_geo, Face3D):
185+
cent_pt = f_geo.center if f_geo.is_convex else \
186+
f_geo.pole_of_inaccessibility(p_tol)
187+
cent_pt = cent_pt.move(f_geo.normal * offset_from_base)
188+
base_plane = Plane(f_geo.normal, cent_pt)
189+
if base_plane.y.z < 0: # base plane pointing downwards; rotate it
190+
base_plane = base_plane.rotate(
191+
base_plane.n, math.pi, base_plane.o)
192+
# move base plane a little to avoid overlaps of adjacent labels
193+
if base_plane.n.x != 0:
194+
m_vec = base_plane.y if base_plane.n.x < 0 else -base_plane.y
195+
else:
196+
m_vec = base_plane.y if base_plane.n.z < 0 else -base_plane.y
197+
base_plane = base_plane.move(m_vec * txt_h)
198+
else: #it's a Mesh3D
199+
base_plane = Plane(Vector3D(0, 0, 1), f_geo.center)
194200
# create the text label
195201
label = DisplayText3D(
196202
face_prop, base_plane, txt_h, font=font,
@@ -238,8 +244,8 @@ def _room_wireframe(rooms):
238244
for seg in sh_geo.boundary_segments:
239245
wireframe.append(DisplayLineSegment3D(seg, line_width=1))
240246
if sh_geo.has_holes:
241-
for hole in sh_geo.holes:
242-
for seg in sh_geo.boundary_segments:
247+
for hole in sh_geo.hole_segments:
248+
for seg in hole:
243249
wireframe.append(DisplayLineSegment3D(seg, line_width=1))
244250
con_geo = ContextGeometry('Wireframe', wireframe)
245251
return con_geo
@@ -250,13 +256,17 @@ def _face_wireframe(faces):
250256
wireframe = []
251257
for face in faces:
252258
lw = 2 if isinstance(face, Face) else 1
253-
face3d = face.geometry
254-
for seg in face3d.boundary_segments:
255-
wireframe.append(DisplayLineSegment3D(seg, line_width=lw))
256-
if face3d.has_holes:
257-
for hole in face3d.holes:
258-
for seg in face3d.boundary_segments:
259-
wireframe.append(DisplayLineSegment3D(seg, line_width=lw))
259+
f_geo = face.geometry
260+
if isinstance(f_geo, Face3D):
261+
for seg in f_geo.boundary_segments:
262+
wireframe.append(DisplayLineSegment3D(seg, line_width=lw))
263+
if f_geo.has_holes:
264+
for hole in f_geo.hole_segments:
265+
for seg in hole:
266+
wireframe.append(DisplayLineSegment3D(seg, line_width=lw))
267+
else: # it's a Mesh3D
268+
for seg in f_geo.edges:
269+
wireframe.append(DisplayLineSegment3D(seg, line_width=lw))
260270
con_geo = ContextGeometry('Wireframe', wireframe)
261271
return con_geo
262272

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.57.9
2+
honeybee-core>=1.57.10

0 commit comments

Comments
 (0)