honeybee-core 1.64.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. honeybee/__init__.py +23 -0
  2. honeybee/__main__.py +4 -0
  3. honeybee/_base.py +331 -0
  4. honeybee/_basewithshade.py +310 -0
  5. honeybee/_lockable.py +99 -0
  6. honeybee/altnumber.py +47 -0
  7. honeybee/aperture.py +997 -0
  8. honeybee/boundarycondition.py +358 -0
  9. honeybee/checkdup.py +173 -0
  10. honeybee/cli/__init__.py +118 -0
  11. honeybee/cli/compare.py +132 -0
  12. honeybee/cli/create.py +265 -0
  13. honeybee/cli/edit.py +559 -0
  14. honeybee/cli/lib.py +103 -0
  15. honeybee/cli/setconfig.py +43 -0
  16. honeybee/cli/validate.py +224 -0
  17. honeybee/colorobj.py +363 -0
  18. honeybee/config.json +5 -0
  19. honeybee/config.py +347 -0
  20. honeybee/dictutil.py +54 -0
  21. honeybee/door.py +746 -0
  22. honeybee/extensionutil.py +208 -0
  23. honeybee/face.py +2360 -0
  24. honeybee/facetype.py +153 -0
  25. honeybee/logutil.py +79 -0
  26. honeybee/model.py +4272 -0
  27. honeybee/orientation.py +132 -0
  28. honeybee/properties.py +845 -0
  29. honeybee/room.py +3485 -0
  30. honeybee/search.py +107 -0
  31. honeybee/shade.py +514 -0
  32. honeybee/shademesh.py +362 -0
  33. honeybee/typing.py +498 -0
  34. honeybee/units.py +88 -0
  35. honeybee/writer/__init__.py +7 -0
  36. honeybee/writer/aperture.py +6 -0
  37. honeybee/writer/door.py +6 -0
  38. honeybee/writer/face.py +6 -0
  39. honeybee/writer/model.py +6 -0
  40. honeybee/writer/room.py +6 -0
  41. honeybee/writer/shade.py +6 -0
  42. honeybee/writer/shademesh.py +6 -0
  43. honeybee_core-1.64.12.dist-info/METADATA +94 -0
  44. honeybee_core-1.64.12.dist-info/RECORD +48 -0
  45. honeybee_core-1.64.12.dist-info/WHEEL +5 -0
  46. honeybee_core-1.64.12.dist-info/entry_points.txt +2 -0
  47. honeybee_core-1.64.12.dist-info/licenses/LICENSE +661 -0
  48. honeybee_core-1.64.12.dist-info/top_level.txt +1 -0
honeybee/door.py ADDED
@@ -0,0 +1,746 @@
1
+ # coding: utf-8
2
+ """Honeybee Door."""
3
+ from __future__ import division
4
+ import math
5
+ import re
6
+
7
+ from ladybug_geometry.geometry2d import Vector2D
8
+ from ladybug_geometry.geometry3d import Point3D, Face3D
9
+ from ladybug.color import Color
10
+
11
+ from ._basewithshade import _BaseWithShade
12
+ from .typing import clean_string
13
+ from .search import get_attr_nested
14
+ from .properties import DoorProperties
15
+ from .boundarycondition import boundary_conditions, Outdoors, Surface
16
+ from .shade import Shade
17
+ import honeybee.writer.door as writer
18
+
19
+
20
+ class Door(_BaseWithShade):
21
+ """A single planar Door in a Face.
22
+
23
+ Args:
24
+ identifier: Text string for a unique Door ID. Must be < 100 characters and
25
+ not contain any spaces or special characters.
26
+ geometry: A ladybug-geometry Face3D.
27
+ boundary_condition: Boundary condition object (Outdoors, Surface, etc.).
28
+ Default: Outdoors.
29
+ is_glass: Boolean to note whether this object is a glass door as opposed
30
+ to an opaque door. Default: False.
31
+
32
+ Properties:
33
+ * identifier
34
+ * display_name
35
+ * boundary_condition
36
+ * is_glass
37
+ * indoor_shades
38
+ * outdoor_shades
39
+ * parent
40
+ * top_level_parent
41
+ * has_parent
42
+ * geometry
43
+ * vertices
44
+ * upper_left_vertices
45
+ * triangulated_mesh3d
46
+ * normal
47
+ * center
48
+ * area
49
+ * perimeter
50
+ * min
51
+ * max
52
+ * tilt
53
+ * altitude
54
+ * azimuth
55
+ * is_exterior
56
+ * type_color
57
+ * bc_color
58
+ * user_data
59
+ """
60
+ __slots__ = ('_geometry', '_parent', '_boundary_condition', '_is_glass')
61
+ TYPE_COLORS = {
62
+ False: Color(160, 150, 100),
63
+ True: Color(128, 204, 255, 100)
64
+ }
65
+ BC_COLORS = {
66
+ 'Outdoors': Color(128, 204, 255),
67
+ 'Surface': Color(0, 190, 0)
68
+ }
69
+
70
+ def __init__(self, identifier, geometry, boundary_condition=None, is_glass=False):
71
+ """A single planar Door in a Face."""
72
+ _BaseWithShade.__init__(self, identifier) # process the identifier
73
+
74
+ # process the geometry
75
+ assert isinstance(geometry, Face3D), \
76
+ 'Expected ladybug_geometry Face3D. Got {}'.format(type(geometry))
77
+ self._geometry = geometry
78
+ self._parent = None # _parent will be set when the Face is added to a Face
79
+
80
+ # process the boundary condition and type
81
+ self.boundary_condition = boundary_condition or boundary_conditions.outdoors
82
+ self.is_glass = is_glass
83
+
84
+ # initialize properties for extensions
85
+ self._properties = DoorProperties(self)
86
+
87
+ @classmethod
88
+ def from_dict(cls, data):
89
+ """Initialize an Door from a dictionary.
90
+
91
+ Args:
92
+ data: A dictionary representation of an Door object.
93
+ """
94
+ try:
95
+ # check the type of dictionary
96
+ assert data['type'] == 'Door', 'Expected Door dictionary. ' \
97
+ 'Got {}.'.format(data['type'])
98
+
99
+ # serialize the door
100
+ is_glass = data['is_glass'] if 'is_glass' in data else False
101
+ if data['boundary_condition']['type'] == 'Outdoors':
102
+ boundary_condition = Outdoors.from_dict(data['boundary_condition'])
103
+ elif data['boundary_condition']['type'] == 'Surface':
104
+ boundary_condition = Surface.from_dict(data['boundary_condition'], True)
105
+ else:
106
+ raise ValueError(
107
+ 'Boundary condition "{}" is not supported for Door.'.format(
108
+ data['boundary_condition']['type']))
109
+ door = cls(data['identifier'], Face3D.from_dict(data['geometry']),
110
+ boundary_condition, is_glass)
111
+ if 'display_name' in data and data['display_name'] is not None:
112
+ door.display_name = data['display_name']
113
+ if 'user_data' in data and data['user_data'] is not None:
114
+ door.user_data = data['user_data']
115
+ door._recover_shades_from_dict(data)
116
+
117
+ # assign extension properties
118
+ if data['properties']['type'] == 'DoorProperties':
119
+ door.properties._load_extension_attr_from_dict(data['properties'])
120
+ return door
121
+ except Exception as e:
122
+ cls._from_dict_error_message(data, e)
123
+
124
+ @classmethod
125
+ def from_vertices(cls, identifier, vertices, boundary_condition=None,
126
+ is_glass=False):
127
+ """Create a Door from vertices with each vertex as an iterable of 3 floats.
128
+
129
+ Args:
130
+ identifier: Text string for a unique Door ID. Must be < 100 characters and
131
+ not contain any spaces or special characters.
132
+ vertices: A flattened list of 3 or more vertices as (x, y, z).
133
+ boundary_condition: Boundary condition object (eg. Outdoors, Surface).
134
+ Default: Outdoors.
135
+ is_glass: Boolean to note whether this object is a glass door as opposed
136
+ to an opaque door. Default: False.
137
+ """
138
+ geometry = Face3D(tuple(Point3D(*v) for v in vertices))
139
+ return cls(identifier, geometry, boundary_condition, is_glass)
140
+
141
+ @property
142
+ def boundary_condition(self):
143
+ """Get or set the boundary condition of this door."""
144
+ return self._boundary_condition
145
+
146
+ @boundary_condition.setter
147
+ def boundary_condition(self, value):
148
+ if not isinstance(value, Outdoors):
149
+ if isinstance(value, Surface):
150
+ assert len(value.boundary_condition_objects) == 3, 'Surface boundary ' \
151
+ 'condition for Door must have 3 boundary_condition_objects.'
152
+ else:
153
+ raise ValueError('Door only supports Outdoor or Surface boundary '
154
+ 'condition. Got {}'.format(type(value)))
155
+ self._boundary_condition = value
156
+
157
+ @property
158
+ def is_glass(self):
159
+ """Get or set a boolean to note whether this object is a glass door."""
160
+ return self._is_glass
161
+
162
+ @is_glass.setter
163
+ def is_glass(self, value):
164
+ try:
165
+ self._is_glass = bool(value)
166
+ except TypeError:
167
+ raise TypeError(
168
+ 'Expected boolean for Door.is_glass. Got {}.'.format(value))
169
+
170
+ @property
171
+ def parent(self):
172
+ """Get the parent Face if assigned. None if not assigned."""
173
+ return self._parent
174
+
175
+ @property
176
+ def top_level_parent(self):
177
+ """Get the top-level parent object if assigned.
178
+
179
+ This will be a Room if there is a parent Face that has a parent Room and
180
+ will be a Face if the parent Face is orphaned. Will be None if no parent
181
+ is assigned.
182
+ """
183
+ if self.has_parent:
184
+ if self._parent.has_parent:
185
+ return self._parent._parent
186
+ return self._parent
187
+ return None
188
+
189
+ @property
190
+ def has_parent(self):
191
+ """Get a boolean noting whether this Door has a parent Face."""
192
+ return self._parent is not None
193
+
194
+ @property
195
+ def geometry(self):
196
+ """Get a ladybug_geometry Face3D object representing the door."""
197
+ return self._geometry
198
+
199
+ @property
200
+ def vertices(self):
201
+ """Get a list of vertices for the door (in counter-clockwise order)."""
202
+ return self._geometry.vertices
203
+
204
+ @property
205
+ def upper_left_vertices(self):
206
+ """Get a list of vertices starting from the upper-left corner.
207
+
208
+ This property should be used when exporting to EnergyPlus / OpenStudio.
209
+ """
210
+ return self._geometry.upper_left_counter_clockwise_vertices
211
+
212
+ @property
213
+ def triangulated_mesh3d(self):
214
+ """Get a ladybug_geometry Mesh3D of the door geometry composed of triangles.
215
+
216
+ In EnergyPlus / OpenStudio workflows, this property is used to subdivide
217
+ the door when it has more than 4 vertices. This is necessary since
218
+ EnergyPlus cannot accept sub-faces with more than 4 vertices.
219
+ """
220
+ return self._geometry.triangulated_mesh3d
221
+
222
+ @property
223
+ def normal(self):
224
+ """Get a ladybug_geometry Vector3D for the direction the door is pointing.
225
+ """
226
+ return self._geometry.normal
227
+
228
+ @property
229
+ def center(self):
230
+ """Get a ladybug_geometry Point3D for the center of the door.
231
+
232
+ Note that this is the center of the bounding rectangle around this geometry
233
+ and not the area centroid.
234
+ """
235
+ return self._geometry.center
236
+
237
+ @property
238
+ def area(self):
239
+ """Get the area of the door."""
240
+ return self._geometry.area
241
+
242
+ @property
243
+ def perimeter(self):
244
+ """Get the perimeter of the door."""
245
+ return self._geometry.perimeter
246
+
247
+ @property
248
+ def min(self):
249
+ """Get a Point3D for the minimum of the bounding box around the object."""
250
+ return self._min_with_shades(self._geometry)
251
+
252
+ @property
253
+ def max(self):
254
+ """Get a Point3D for the maximum of the bounding box around the object."""
255
+ return self._max_with_shades(self._geometry)
256
+
257
+ @property
258
+ def tilt(self):
259
+ """Get the tilt of the geometry between 0 (up) and 180 (down)."""
260
+ return math.degrees(self._geometry.tilt)
261
+
262
+ @property
263
+ def altitude(self):
264
+ """Get the altitude of the geometry between +90 (up) and -90 (down)."""
265
+ return math.degrees(self._geometry.altitude)
266
+
267
+ @property
268
+ def azimuth(self):
269
+ """Get the azimuth of the geometry, between 0 and 360.
270
+
271
+ Given Y-axis as North, 0 = North, 90 = East, 180 = South, 270 = West
272
+ This will be zero if the Face3D is perfectly horizontal.
273
+ """
274
+ return math.degrees(self._geometry.azimuth)
275
+
276
+ @property
277
+ def is_exterior(self):
278
+ """Get a boolean for whether this object has an Outdoors boundary condition.
279
+ """
280
+ return isinstance(self.boundary_condition, Outdoors)
281
+
282
+ @property
283
+ def gbxml_type(self):
284
+ """Get text for the type of object this is in gbXML schema."""
285
+ return 'NonSlidingDoor'
286
+
287
+ @property
288
+ def energyplus_type(self):
289
+ """Get text for the type of object this is in IDF schema."""
290
+ return 'GlassDoor' if self.is_glass else 'Door'
291
+
292
+ @property
293
+ def type_color(self):
294
+ """Get a Color to be used in visualizations by type."""
295
+ return self.TYPE_COLORS[self.is_glass]
296
+
297
+ @property
298
+ def bc_color(self):
299
+ """Get a Color to be used in visualizations by boundary condition."""
300
+ return self.BC_COLORS[self.boundary_condition.name]
301
+
302
+ def horizontal_orientation(self, north_vector=Vector2D(0, 1)):
303
+ """Get a number between 0 and 360 for the orientation of the door in degrees.
304
+
305
+ 0 = North, 90 = East, 180 = South, 270 = West
306
+
307
+ Args:
308
+ north_vector: A ladybug_geometry Vector2D for the north direction.
309
+ Default is the Y-axis (0, 1).
310
+ """
311
+ return math.degrees(
312
+ north_vector.angle_clockwise(Vector2D(self.normal.x, self.normal.y)))
313
+
314
+ def cardinal_direction(self, north_vector=Vector2D(0, 1), angle_tolerance=1):
315
+ """Get text description for the cardinal direction that the door is pointing.
316
+
317
+ Will be one of the following: ('North', 'NorthEast', 'East', 'SouthEast',
318
+ 'South', 'SouthWest', 'West', 'NorthWest', 'Up', 'Down').
319
+
320
+ Args:
321
+ north_vector: A ladybug_geometry Vector2D for the north direction.
322
+ Default is the Y-axis (0, 1).
323
+ angle_tolerance: The angle tolerance in degrees used to determine if
324
+ the geometry is perfectly Up or Down. (Default: 1).
325
+ """
326
+ tilt = self.tilt
327
+ if tilt < angle_tolerance:
328
+ return 'Up'
329
+ elif tilt > 180 - angle_tolerance:
330
+ return 'Down'
331
+ orient = self.horizontal_orientation(north_vector)
332
+ orient_text = ('North', 'NorthEast', 'East', 'SouthEast', 'South',
333
+ 'SouthWest', 'West', 'NorthWest')
334
+ angles = (22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, 337.5)
335
+ for i, ang in enumerate(angles):
336
+ if orient < ang:
337
+ return orient_text[i]
338
+ return orient_text[0]
339
+
340
+ def cardinal_abbrev(self, north_vector=Vector2D(0, 1), angle_tolerance=1):
341
+ """Get text abbreviation for the cardinal direction that the door is pointing.
342
+
343
+ Will be one of the following: ('N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW',
344
+ 'Up', 'Down').
345
+
346
+ Args:
347
+ north_vector: A ladybug_geometry Vector2D for the north direction.
348
+ Default is the Y-axis (0, 1).
349
+ angle_tolerance: The angle tolerance in degrees used to determine if
350
+ the door is perfectly Up or Down. (Default: 1).
351
+ """
352
+ tilt = self.tilt
353
+ if tilt < angle_tolerance:
354
+ return 'Up'
355
+ elif tilt > 180 - angle_tolerance:
356
+ return 'Down'
357
+ orient = self.horizontal_orientation(north_vector)
358
+ orient_text = ('N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW')
359
+ angles = (22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, 337.5)
360
+ for i, ang in enumerate(angles):
361
+ if orient < ang:
362
+ return orient_text[i]
363
+ return orient_text[0]
364
+
365
+ def add_prefix(self, prefix):
366
+ """Change the identifier of this object and child objects by inserting a prefix.
367
+
368
+ This is particularly useful in workflows where you duplicate and edit
369
+ a starting object and then want to combine it with the original object
370
+ into one Model (like making a model of repeated rooms) since all objects
371
+ within a Model must have unique identifiers.
372
+
373
+ Args:
374
+ prefix: Text that will be inserted at the start of this object's
375
+ (and child objects') identifier and display_name. It is recommended
376
+ that this prefix be short to avoid maxing out the 100 allowable
377
+ characters for honeybee identifiers.
378
+ """
379
+ self._identifier = clean_string('{}_{}'.format(prefix, self.identifier))
380
+ self.display_name = '{}_{}'.format(prefix, self.display_name)
381
+ self.properties.add_prefix(prefix)
382
+ self._add_prefix_shades(prefix)
383
+ if isinstance(self._boundary_condition, Surface):
384
+ new_bc_objs = (clean_string('{}_{}'.format(prefix, adj_name)) for adj_name
385
+ in self._boundary_condition._boundary_condition_objects)
386
+ self._boundary_condition = Surface(new_bc_objs, True)
387
+
388
+ def rename_by_attribute(
389
+ self,
390
+ format_str='{parent.parent.display_name} - {energyplus_type} - {cardinal_direction}'
391
+ ):
392
+ """Set the display name of this Door using a format string with attributes.
393
+
394
+ Args:
395
+ format_str: Text string for the pattern with which the Door will be
396
+ renamed. Any property on this class may be used (eg. energyplus_type)
397
+ and each property should be put in curly brackets. Nested
398
+ properties can be specified by using "." to denote nesting levels
399
+ (eg. properties.energy.construction.display_name). Functions that
400
+ return string outputs can also be passed here as long as these
401
+ functions defaults specified for all arguments.
402
+ """
403
+ matches = re.findall(r'{([^}]*)}', format_str)
404
+ attributes = [get_attr_nested(self, m, decimal_count=2) for m in matches]
405
+ for attr_name, attr_val in zip(matches, attributes):
406
+ format_str = format_str.replace('{{{}}}'.format(attr_name), attr_val)
407
+ self.display_name = format_str
408
+ return format_str
409
+
410
+ def set_adjacency(self, other_door):
411
+ """Set this door to be adjacent to another (and vice versa).
412
+
413
+ Note that this method does not verify whether the other_door geometry is
414
+ co-planar or compatible with this one so it is recommended that a test
415
+ be performed before using this method in order to verify these criteria.
416
+ The Face3D.is_centered_adjacent() or the Face3D.is_geometrically_equivalent()
417
+ methods are both suitable for this purpose.
418
+
419
+ Args:
420
+ other_door: Another Door object to be set adjacent to this one.
421
+ """
422
+ assert isinstance(other_door, Door), \
423
+ 'Expected Door. Got {}.'.format(type(other_door))
424
+ assert other_door.is_glass is self.is_glass, \
425
+ 'Adjacent doors must have matching is_glass properties.'
426
+ self._boundary_condition = boundary_conditions.surface(other_door, True)
427
+ other_door._boundary_condition = boundary_conditions.surface(self, True)
428
+
429
+ def overhang(self, depth, angle=0, indoor=False, tolerance=0.01, base_name=None):
430
+ """Add a single overhang for this Door. Can represent entryway awnings.
431
+
432
+ Args:
433
+ depth: A number for the overhang depth.
434
+ angle: A number for the for an angle to rotate the overhang in degrees.
435
+ Positive numbers indicate a downward rotation while negative numbers
436
+ indicate an upward rotation. Default is 0 for no rotation.
437
+ indoor: Boolean for whether the overhang should be generated facing the
438
+ opposite direction of the aperture normal (typically meaning
439
+ indoor geometry). Default: False.
440
+ tolerance: An optional value to return None if the overhang has a length less
441
+ than the tolerance. Default: 0.01, suitable for objects in meters.
442
+ base_name: Optional base name for the shade objects. If None, the default
443
+ is InOverhang or OutOverhang depending on whether indoor is True.
444
+
445
+ Returns:
446
+ A list of the new Shade objects that have been generated.
447
+ """
448
+ # get a name for the shade
449
+ if base_name is None:
450
+ base_name = 'InOverhang' if indoor else 'OutOverhang'
451
+ shd_name_base = '{}_' + str(base_name) + '{}'
452
+
453
+ # create the shade geometry
454
+ angle = math.radians(angle)
455
+ dr_geo = self.geometry if indoor is False else self.geometry.flip()
456
+ shade_faces = dr_geo.contour_fins_by_number(
457
+ 1, depth, 0, angle, Vector2D(0, 1), False, tolerance)
458
+
459
+ # create the Shade objects
460
+ overhang = []
461
+ for i, shade_geo in enumerate(shade_faces):
462
+ overhang.append(Shade(shd_name_base.format(self.identifier, i), shade_geo))
463
+ if indoor:
464
+ self.add_indoor_shades(overhang)
465
+ else:
466
+ self.add_outdoor_shades(overhang)
467
+ return overhang
468
+
469
+ def move(self, moving_vec):
470
+ """Move this Door along a vector.
471
+
472
+ Args:
473
+ moving_vec: A ladybug_geometry Vector3D with the direction and distance
474
+ to move the face.
475
+ """
476
+ self._geometry = self.geometry.move(moving_vec)
477
+ self.move_shades(moving_vec)
478
+ self.properties.move(moving_vec)
479
+ self._reset_parent_geometry()
480
+
481
+ def rotate(self, axis, angle, origin):
482
+ """Rotate this Door by a certain angle around an axis and origin.
483
+
484
+ Args:
485
+ axis: A ladybug_geometry Vector3D axis representing the axis of rotation.
486
+ angle: An angle for rotation in degrees.
487
+ origin: A ladybug_geometry Point3D for the origin around which the
488
+ object will be rotated.
489
+ """
490
+ self._geometry = self.geometry.rotate(axis, math.radians(angle), origin)
491
+ self.rotate_shades(axis, angle, origin)
492
+ self.properties.rotate(axis, angle, origin)
493
+ self._reset_parent_geometry()
494
+
495
+ def rotate_xy(self, angle, origin):
496
+ """Rotate this Door counterclockwise in the world XY plane by a certain angle.
497
+
498
+ Args:
499
+ angle: An angle in degrees.
500
+ origin: A ladybug_geometry Point3D for the origin around which the
501
+ object will be rotated.
502
+ """
503
+ self._geometry = self.geometry.rotate_xy(math.radians(angle), origin)
504
+ self.rotate_xy_shades(angle, origin)
505
+ self.properties.rotate_xy(angle, origin)
506
+ self._reset_parent_geometry()
507
+
508
+ def reflect(self, plane):
509
+ """Reflect this Door across a plane.
510
+
511
+ Args:
512
+ plane: A ladybug_geometry Plane across which the object will
513
+ be reflected.
514
+ """
515
+ self._geometry = self.geometry.reflect(plane.n, plane.o)
516
+ self.reflect_shades(plane)
517
+ self.properties.reflect(plane)
518
+ self._reset_parent_geometry()
519
+
520
+ def scale(self, factor, origin=None):
521
+ """Scale this Door by a factor from an origin point.
522
+
523
+ Args:
524
+ factor: A number representing how much the object should be scaled.
525
+ origin: A ladybug_geometry Point3D representing the origin from which
526
+ to scale. If None, it will be scaled from the World origin (0, 0, 0).
527
+ """
528
+ self._geometry = self.geometry.scale(factor, origin)
529
+ self.scale_shades(factor, origin)
530
+ self.properties.scale(factor, origin)
531
+ self._reset_parent_geometry()
532
+
533
+ def remove_colinear_vertices(self, tolerance=0.01):
534
+ """Remove all colinear and duplicate vertices from this object's geometry.
535
+
536
+ Note that this does not affect any assigned Shades.
537
+
538
+ Args:
539
+ tolerance: The minimum distance between a vertex and the boundary segments
540
+ at which point the vertex is considered colinear. Default: 0.01,
541
+ suitable for objects in meters.
542
+ """
543
+ try:
544
+ self._geometry = self.geometry.remove_colinear_vertices(tolerance)
545
+ except AssertionError as e: # usually a sliver face of some kind
546
+ raise ValueError(
547
+ 'Door "{}" is invalid with dimensions less than the '
548
+ 'tolerance.\n{}'.format(self.full_id, e))
549
+
550
+ def is_geo_equivalent(self, door, tolerance=0.01):
551
+ """Get a boolean for whether this object is geometrically equivalent to another.
552
+
553
+ The total number of vertices and the ordering of these vertices can be
554
+ different but the geometries must share the same center point and be
555
+ next to one another to within the tolerance.
556
+
557
+ Args:
558
+ door: Another Door for which geometric equivalency will be tested.
559
+ tolerance: The minimum difference between the coordinate values of two
560
+ vertices at which they can be considered geometrically equivalent.
561
+
562
+ Returns:
563
+ True if geometrically equivalent. False if not geometrically equivalent.
564
+ """
565
+ meta_1 = (self.display_name, self.is_glass, self.boundary_condition)
566
+ meta_2 = (door.display_name, door.is_glass, door.boundary_condition)
567
+ if meta_1 != meta_2:
568
+ return False
569
+ if abs(self.area - door.area) > tolerance * self.area:
570
+ return False
571
+ if not self.geometry.is_centered_adjacent(door.geometry, tolerance):
572
+ return False
573
+ if not self._are_shades_equivalent(door, tolerance):
574
+ return False
575
+ return True
576
+
577
+ def check_planar(self, tolerance=0.01, raise_exception=True, detailed=False):
578
+ """Check whether all of the Door's vertices lie within the same plane.
579
+
580
+ Args:
581
+ tolerance: The minimum distance between a given vertex and a the
582
+ object's plane at which the vertex is said to lie in the plane.
583
+ Default: 0.01, suitable for objects in meters.
584
+ raise_exception: Boolean to note whether an ValueError should be
585
+ raised if a vertex does not lie within the object's plane.
586
+ detailed: Boolean for whether the returned object is a detailed list of
587
+ dicts with error info or a string with a message. (Default: False).
588
+
589
+ Returns:
590
+ A string with the message or a list with a dictionary if detailed is True.
591
+ """
592
+ try:
593
+ self.geometry.check_planar(tolerance, raise_exception=True)
594
+ except ValueError as e:
595
+ msg = 'Door "{}" is not planar.\n{}'.format(self.full_id, e)
596
+ full_msg = self._validation_message(
597
+ msg, raise_exception, detailed, '000101',
598
+ error_type='Non-Planar Geometry')
599
+ if detailed: # add the out-of-plane points to helper_geometry
600
+ help_pts = [
601
+ p.to_dict() for p in self.geometry.non_planar_vertices(tolerance)
602
+ ]
603
+ full_msg[0]['helper_geometry'] = help_pts
604
+ return full_msg
605
+ return [] if detailed else ''
606
+
607
+ def check_self_intersecting(self, tolerance=0.01, raise_exception=True,
608
+ detailed=False):
609
+ """Check whether the edges of the Door intersect one another (like a bowtie).
610
+
611
+ Note that objects that have duplicate vertices will not be considered
612
+ self-intersecting and are valid in honeybee.
613
+
614
+ Args:
615
+ tolerance: The minimum difference between the coordinate values of two
616
+ vertices at which they can be considered equivalent. Default: 0.01,
617
+ suitable for objects in meters.
618
+ raise_exception: If True, a ValueError will be raised if the object
619
+ intersects with itself. Default: True.
620
+ detailed: Boolean for whether the returned object is a detailed list of
621
+ dicts with error info or a string with a message. (Default: False).
622
+
623
+ Returns:
624
+ A string with the message or a list with a dictionary if detailed is True.
625
+ """
626
+ if self.geometry.is_self_intersecting:
627
+ msg = 'Door "{}" has self-intersecting edges.'.format(self.full_id)
628
+ try: # see if it is self-intersecting because of a duplicate vertex
629
+ new_geo = self.geometry.remove_duplicate_vertices(tolerance)
630
+ if not new_geo.is_self_intersecting:
631
+ return [] if detailed else '' # valid with removed dup vertex
632
+ except AssertionError:
633
+ return [] if detailed else '' # degenerate geometry
634
+ full_msg = self._validation_message(
635
+ msg, raise_exception, detailed, '000102',
636
+ error_type='Self-Intersecting Geometry')
637
+ if detailed: # add the self-intersection points to helper_geometry
638
+ help_pts = [p.to_dict() for p in self.geometry.self_intersection_points]
639
+ full_msg[0]['helper_geometry'] = help_pts
640
+ return full_msg
641
+ return [] if detailed else ''
642
+
643
+ def check_degenerate(self, tolerance=0.01, raise_exception=True, detailed=False):
644
+ """Check whether the Door is degenerate with effectively zero area.
645
+
646
+ Note that, while the Door may have an area larger than the tolerance,
647
+ removing colinear vertices within the tolerance would create a geometry
648
+ smaller than the tolerance.
649
+
650
+ Args:
651
+ tolerance: The minimum difference between the coordinate values of two
652
+ vertices at which they can be considered equivalent. Default: 0.01,
653
+ suitable for objects in meters.
654
+ raise_exception: If True, a ValueError will be raised if the object
655
+ intersects with itself. Default: True.
656
+ detailed: Boolean for whether the returned object is a detailed list of
657
+ dicts with error info or a string with a message. (Default: False).
658
+
659
+ Returns:
660
+ A string with the message or a list with a dictionary if detailed is True.
661
+ """
662
+ msg = 'Door "{}" is degenerate and should be deleted.'.format(
663
+ self.full_id)
664
+ try: # see if it is self-intersecting because of a duplicate vertex
665
+ new_geo = self.geometry.remove_colinear_vertices(tolerance)
666
+ if new_geo.area > tolerance:
667
+ return [] if detailed else '' # valid
668
+ except AssertionError:
669
+ pass # degenerate subface; treat it as degenerate
670
+ full_msg = self._validation_message(
671
+ msg, raise_exception, detailed, '000103',
672
+ error_type='Zero-Area Geometry')
673
+ return full_msg
674
+ return [] if detailed else ''
675
+
676
+ def display_dict(self):
677
+ """Get a list of DisplayFace3D dictionaries for visualizing the object."""
678
+ base = [self._display_face(self.geometry, self.type_color)]
679
+ for shd in self.shades:
680
+ base.extend(shd.display_dict())
681
+ return base
682
+
683
+ @property
684
+ def to(self):
685
+ """Door writer object.
686
+
687
+ Use this method to access Writer class to write the door in different formats.
688
+
689
+ Usage:
690
+
691
+ .. code-block:: python
692
+
693
+ door.to.idf(door) -> idf string.
694
+ door.to.radiance(door) -> Radiance string.
695
+ """
696
+ return writer
697
+
698
+ def to_dict(self, abridged=False, included_prop=None, include_plane=True):
699
+ """Return Door as a dictionary.
700
+
701
+ Args:
702
+ abridged: Boolean to note whether the extension properties of the
703
+ object (ie. materials, constructions) should be included in detail
704
+ (False) or just referenced by identifier (True). (Default: False).
705
+ included_prop: List of properties to filter keys that must be included in
706
+ output dictionary. For example ['energy'] will include 'energy' key if
707
+ available in properties to_dict. By default all the keys will be
708
+ included. To exclude all the keys from extensions use an empty list.
709
+ include_plane: Boolean to note wether the plane of the Face3D should be
710
+ included in the output. This can preserve the orientation of the
711
+ X/Y axes of the plane but is not required and can be removed to
712
+ keep the dictionary smaller. (Default: True).
713
+ """
714
+ base = {'type': 'Door'}
715
+ base['identifier'] = self.identifier
716
+ base['display_name'] = self.display_name
717
+ base['properties'] = self.properties.to_dict(abridged, included_prop)
718
+ enforce_upper_left = True if 'energy' in base['properties'] else False
719
+ base['geometry'] = self._geometry.to_dict(include_plane, enforce_upper_left)
720
+ base['is_glass'] = self.is_glass
721
+ if isinstance(self.boundary_condition, Outdoors) and \
722
+ 'energy' in base['properties']:
723
+ base['boundary_condition'] = self.boundary_condition.to_dict(full=True)
724
+ else:
725
+ base['boundary_condition'] = self.boundary_condition.to_dict()
726
+ self._add_shades_to_dict(base, abridged, included_prop, include_plane)
727
+ if self.user_data is not None:
728
+ base['user_data'] = self.user_data
729
+ return base
730
+
731
+ def _reset_parent_geometry(self):
732
+ """Reset parent punched_geometry in the case that the object is transformed."""
733
+ if self.has_parent:
734
+ self._parent._punched_geometry = None
735
+
736
+ def __copy__(self):
737
+ new_door = Door(self.identifier, self.geometry, self.boundary_condition,
738
+ self.is_glass)
739
+ new_door._display_name = self._display_name
740
+ new_door._user_data = None if self.user_data is None else self.user_data.copy()
741
+ self._duplicate_child_shades(new_door)
742
+ new_door._properties._duplicate_extension_attr(self._properties)
743
+ return new_door
744
+
745
+ def __repr__(self):
746
+ return 'Door: %s' % self.display_name