See #3421. Fix bug where some projection fills wouldn't polygonize correctly in shapely due to numerical tolerance.

This commit is contained in:
Dion Moult
2023-07-14 17:29:30 +10:00
parent a1faf4fe08
commit efd3ef1a89
@@ -23,6 +23,7 @@ import json
import time import time
import bmesh import bmesh
import shutil import shutil
import hashlib
import shapely import shapely
import subprocess import subprocess
import webbrowser import webbrowser
@@ -365,7 +366,6 @@ class CreateDrawing(bpy.types.Operator):
return svg_path return svg_path
def generate_linework(self, context): def generate_linework(self, context):
global ifcopenshell
if not ifcopenshell.util.element.get_pset(self.drawing, "EPset_Drawing", "HasLinework"): if not ifcopenshell.util.element.get_pset(self.drawing, "EPset_Drawing", "HasLinework"):
return return
svg_path = self.get_svg_path(cache_type="linework") svg_path = self.get_svg_path(cache_type="linework")
@@ -395,10 +395,6 @@ class CreateDrawing(bpy.types.Operator):
} }
cached_linework -= edited_guids cached_linework -= edited_guids
# This is a work in progress. See #1153 and #1564.
import hashlib
import ifcopenshell.draw
files = {context.scene.BIMProperties.ifc_file: tool.Ifc.get()} files = {context.scene.BIMProperties.ifc_file: tool.Ifc.get()}
for ifc_path, ifc in files.items(): for ifc_path, ifc in files.items():
@@ -569,7 +565,7 @@ class CreateDrawing(bpy.types.Operator):
for projection in projections: for projection in projections:
boundary_lines = [] boundary_lines = []
for path in projection.findall("./{http://www.w3.org/2000/svg}path"): for path in projection.findall("./{http://www.w3.org/2000/svg}path"):
start, end = [co[1:].split(",") for co in path.attrib["d"].split()] start, end = [[round(float(o), 1) for o in co[1:].split(",")] for co in path.attrib["d"].split()]
boundary_lines.append(shapely.LineString([start, end])) boundary_lines.append(shapely.LineString([start, end]))
unioned_boundaries = shapely.union_all(shapely.GeometryCollection(boundary_lines)) unioned_boundaries = shapely.union_all(shapely.GeometryCollection(boundary_lines))
closed_polygons = shapely.polygonize(unioned_boundaries.geoms) closed_polygons = shapely.polygonize(unioned_boundaries.geoms)