@@ -166,12 +166,7 @@ def color_face_to_vis_set(
166
166
# loop through the faces and create the text labels
167
167
for face_prop , f_geo in zip (color_face .attributes , color_face .flat_geometry ):
168
168
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
175
170
if txt_height is None : # auto-calculate default text height
176
171
txt_len = len (face_prop ) if len (face_prop ) > 10 else 10
177
172
dims = [
@@ -185,12 +180,23 @@ def color_face_to_vis_set(
185
180
if txt_h < tolerance :
186
181
continue
187
182
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 )
194
200
# create the text label
195
201
label = DisplayText3D (
196
202
face_prop , base_plane , txt_h , font = font ,
@@ -238,8 +244,8 @@ def _room_wireframe(rooms):
238
244
for seg in sh_geo .boundary_segments :
239
245
wireframe .append (DisplayLineSegment3D (seg , line_width = 1 ))
240
246
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 :
243
249
wireframe .append (DisplayLineSegment3D (seg , line_width = 1 ))
244
250
con_geo = ContextGeometry ('Wireframe' , wireframe )
245
251
return con_geo
@@ -250,13 +256,17 @@ def _face_wireframe(faces):
250
256
wireframe = []
251
257
for face in faces :
252
258
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 ))
260
270
con_geo = ContextGeometry ('Wireframe' , wireframe )
261
271
return con_geo
262
272
0 commit comments