fairyfly-core 0.2.8__py3-none-any.whl → 0.2.10__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.
fairyfly/model.py CHANGED
@@ -606,6 +606,27 @@ class Model(_Base):
606
606
  for i in reversed(i_to_remove):
607
607
  self._shapes.pop(i)
608
608
 
609
+ def remove_duplicate_vertices(self, tolerance=None):
610
+ """Remove any duplicate vertices from the model.
611
+
612
+ Any degenerate shapes found while removing duplicate vertices will be
613
+ automatically removed from the model.
614
+
615
+ Args:
616
+ tolerance: The minimum distance between a vertex and the boundary segments
617
+ at which point the vertex is considered distinct. If None, the
618
+ Model's tolerance will be used. (Default: None).
619
+ """
620
+ tolerance = self.tolerance if tolerance is None else tolerance
621
+ i_to_remove = []
622
+ for i, shape in enumerate(self._shapes):
623
+ try:
624
+ shape.remove_duplicate_vertices(tolerance)
625
+ except ValueError: # degenerate shape found!
626
+ i_to_remove.append(i)
627
+ for i in reversed(i_to_remove):
628
+ self._shapes.pop(i)
629
+
609
630
  def check_all(self, raise_exception=True, detailed=False, all_ext_checks=False):
610
631
  """Check all of the aspects of the Model for validation errors.
611
632
 
fairyfly/shape.py CHANGED
@@ -247,6 +247,21 @@ class Shape(_Base):
247
247
  self._geometry = self.geometry.scale(factor, origin)
248
248
  self.properties.scale(factor, origin)
249
249
 
250
+ def remove_duplicate_vertices(self, tolerance=0.01):
251
+ """Remove all duplicate vertices from this object's geometry.
252
+
253
+ Args:
254
+ tolerance: The minimum distance between a vertex and the boundary segments
255
+ at which point the vertex is considered duplicate. Default: 0.01,
256
+ suitable for objects in millimeters.
257
+ """
258
+ try:
259
+ self._geometry = self.geometry.remove_duplicate_vertices(tolerance)
260
+ except AssertionError as e: # usually a sliver face of some kind
261
+ raise ValueError(
262
+ 'Shape "{}" is invalid with dimensions less than the '
263
+ 'tolerance.\n{}'.format(self.full_id, e))
264
+
250
265
  def remove_colinear_vertices(self, tolerance=0.01):
251
266
  """Remove all colinear and duplicate vertices from this object's geometry.
252
267
 
@@ -469,6 +484,20 @@ class Shape(_Base):
469
484
  pts_2d = tuple(master_plane.xyz_to_xy(pt) for pt in hole)
470
485
  polygon_2ds.append(Polygon2D(pts_2d))
471
486
 
487
+ # snap all polygons together
488
+ polygon_2ds = Polygon2D.snap_polygons(polygon_2ds, tol)
489
+
490
+ # remove colinear and degenerate geometry
491
+ i_to_remove = []
492
+ for i, poly in enumerate(polygon_2ds):
493
+ try:
494
+ poly.remove_colinear_vertices(tol)
495
+ except ValueError: # degenerate shape found!
496
+ i_to_remove.append(i)
497
+ for i in reversed(i_to_remove):
498
+ polygon_2ds.pop(i)
499
+ is_holes.pop(i)
500
+
472
501
  # intersect the Room2D polygons within the 2D space
473
502
  int_poly = Polygon2D.intersect_polygon_segments(polygon_2ds, tol)
474
503
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fairyfly-core
3
- Version: 0.2.8
3
+ Version: 0.2.10
4
4
  Summary: A library to represent construction detail geometry for environmental simulation.
5
5
  Home-page: https://github.com/ladybug-tools/fairyfly-core
6
6
  Author: Ladybug Tools
@@ -10,10 +10,10 @@ fairyfly/config.py,sha256=VfQ-vRX-q1CLja4xFMGVte-FpdFStdMXj98WKpmMOFA,10633
10
10
  fairyfly/dictutil.py,sha256=nVwoWG4FsoV9nYjQxI3jBxVeZcdy2TQd1FKhEquVLR8,1469
11
11
  fairyfly/extensionutil.py,sha256=5MQV0gZBc6_vfbVr4j8l_8JslMsj4bBbsZ4yqZ2VPG4,2716
12
12
  fairyfly/logutil.py,sha256=Urxl0U14-qffIt6NiGLT6pV-796oAGUvnnf2ypj1j9Q,2564
13
- fairyfly/model.py,sha256=R3BXbVgICTM-5K0O1HAnyODqDYrOXXQjZpkT73PGMos,46274
13
+ fairyfly/model.py,sha256=PL8mQRcgRQ8bBn2rl1XfXYJsGciqAo_EwbxsSe2vUq0,47161
14
14
  fairyfly/properties.py,sha256=uGBA8YY0Sr_dp3NUCAx-XvXhctoBBwDlqsCiyNU_TTo,21402
15
15
  fairyfly/search.py,sha256=-DapYpzfX3nwZx1eF2elcmYG7vxitsvAiv_e3TGlTJ0,4806
16
- fairyfly/shape.py,sha256=UaG-CWt2w_h513MpY3sIdr6XNCyQUk6VaI2lTHrQ_94,22314
16
+ fairyfly/shape.py,sha256=5Fp5DYlvFL3BPaopGNpNqKSjBeMQHGI-JEa6ksmZcqc,23505
17
17
  fairyfly/typing.py,sha256=1djGuUI0Ui-96EjBKPKw6rrMF7dPUq97q24Pg6NNfTM,7219
18
18
  fairyfly/units.py,sha256=wM3TEAF_ir8VWHFJYSbAKYrLU7VHzBGTtRTw6Tbh4Aw,3216
19
19
  fairyfly/cli/__init__.py,sha256=1qvLWWmJtYVDdTTQHVtoCNTMKyeAq_VWZ4tp-ap-Ajk,3187
@@ -22,9 +22,9 @@ fairyfly/writer/__init__.py,sha256=D4FdE2LUVCMvfud3qL2UquH1uCz3EGlKOEMgstMjtXc,2
22
22
  fairyfly/writer/boundary.py,sha256=skpfcFyxWLvjTSStbCh5f4wehSHeI-eKMgoeSCzvO7Q,190
23
23
  fairyfly/writer/model.py,sha256=6Y15NVGCjmYcBdimxyQWnE8AAhQAJi6A7QfMi4P49M4,181
24
24
  fairyfly/writer/shape.py,sha256=pMlLbk3WkrNPbNvowDQ_JFgNkhHNOlqL52TMZKB7zKo,181
25
- fairyfly_core-0.2.8.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
26
- fairyfly_core-0.2.8.dist-info/METADATA,sha256=m4J4gL2Hb3I_WIUrjmkAhVvN8aUWbsG9PWe_eQ8C6hI,3291
27
- fairyfly_core-0.2.8.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
28
- fairyfly_core-0.2.8.dist-info/entry_points.txt,sha256=KM3hAPV0ivux3CUx1-pDT0BL1WSUFt2jmT4i_MFbdzc,47
29
- fairyfly_core-0.2.8.dist-info/top_level.txt,sha256=8ZUsvZOSB3g5enmv1R0vxJilNeW8Uft5KrTL0rUNj7k,9
30
- fairyfly_core-0.2.8.dist-info/RECORD,,
25
+ fairyfly_core-0.2.10.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
26
+ fairyfly_core-0.2.10.dist-info/METADATA,sha256=m0uZyPLtkGR7Hf-jaEGvC4jdrQkpb386dl7vx4GGmrc,3292
27
+ fairyfly_core-0.2.10.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
28
+ fairyfly_core-0.2.10.dist-info/entry_points.txt,sha256=KM3hAPV0ivux3CUx1-pDT0BL1WSUFt2jmT4i_MFbdzc,47
29
+ fairyfly_core-0.2.10.dist-info/top_level.txt,sha256=8ZUsvZOSB3g5enmv1R0vxJilNeW8Uft5KrTL0rUNj7k,9
30
+ fairyfly_core-0.2.10.dist-info/RECORD,,