|
26 | 26 | import blenderbim.core.type |
27 | 27 | from math import pi |
28 | 28 | from mathutils import Vector, Matrix |
29 | | -from shapely import Polygon |
| 29 | +from shapely import Polygon, MultiPolygon |
30 | 30 |
|
31 | 31 |
|
32 | 32 | class GenerateSpace(bpy.types.Operator, tool.Ifc.Operator): |
@@ -231,6 +231,8 @@ def _execute(self, context): |
231 | 231 |
|
232 | 232 | union = shapely.ops.unary_union(polys).buffer(converted_tolerance, cap_style=2, join_style=2) |
233 | 233 |
|
| 234 | + union = self.get_purged_inner_holes_poly(union_geom = union, min_area = self.get_converted_tolerance(tolerance = 3)) |
| 235 | + |
234 | 236 | for i, linear_ring in enumerate(union.interiors): |
235 | 237 | poly = Polygon(linear_ring) |
236 | 238 | poly = poly.buffer(converted_tolerance, single_sided=True, cap_style=2, join_style=2) |
@@ -261,7 +263,7 @@ def get_boundary_elements(self, selected_objects): |
261 | 263 | boundary_elements = [] |
262 | 264 | for obj in selected_objects: |
263 | 265 | subelement = tool.Ifc.get_entity(obj) |
264 | | - if subelement.is_a("IfcWall"): |
| 266 | + if subelement.is_a("IfcWall") or subelement.is_a("IfcColumn"): |
265 | 267 | boundary_elements.append(subelement) |
266 | 268 | return boundary_elements |
267 | 269 |
|
@@ -304,6 +306,29 @@ def get_converted_tolerance(self, tolerance): |
304 | 306 | ) |
305 | 307 | return tolerance |
306 | 308 |
|
| 309 | + def get_purged_inner_holes_poly(self, union_geom, min_area): |
| 310 | + interiors_list = [] |
| 311 | + |
| 312 | + if union_geom.geom_type == "MultiPolygon": |
| 313 | + for poly in union_geom.geoms: |
| 314 | + interiors_list = self.get_poly_valid_interior_list(poly = poly, min_area = min_area, interiors_list = interiors_list) |
| 315 | + |
| 316 | + new_poly = Polygon(poly.exterior.coords, holes = interiors_list) |
| 317 | + |
| 318 | + if union_geom.geom_type == "Polygon": |
| 319 | + interiors_list = self.get_poly_valid_interior_list(poly = union_geom, min_area = min_area, interiors_list = interiors_list) |
| 320 | + new_poly = Polygon(union_geom.exterior.coords, holes = interiors_list) |
| 321 | + |
| 322 | + return new_poly |
| 323 | + |
| 324 | + def get_poly_valid_interior_list(self, poly, min_area, interiors_list): |
| 325 | + for interior in poly.interiors: |
| 326 | + p = Polygon(interior) |
| 327 | + if p.area >= min_area: |
| 328 | + interiors_list.append(interior) |
| 329 | + return interiors_list |
| 330 | + |
| 331 | + |
307 | 332 | def get_bmesh_from_polygon(self, poly, mat, h): |
308 | 333 | bm = bmesh.new() |
309 | 334 | bm.verts.index_update() |
|
0 commit comments