mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 13:46:54 +00:00
See #4241. Only use shapely to repolygonise if IfcOpenShell returns unclosed paths. Hollow cuts typically are closed paths.
This commit is contained in:
@@ -966,17 +966,21 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
# alone (e.g. dangles, cuts, invalids). See #3421.
|
# alone (e.g. dangles, cuts, invalids). See #3421.
|
||||||
line_strings = []
|
line_strings = []
|
||||||
old_paths = []
|
old_paths = []
|
||||||
|
has_open_paths = False
|
||||||
for path in el.findall("{http://www.w3.org/2000/svg}path"):
|
for path in el.findall("{http://www.w3.org/2000/svg}path"):
|
||||||
for subpath in path.attrib["d"].split("M")[1:]:
|
for subpath in path.attrib["d"].split("M")[1:]:
|
||||||
subpath = "M" + subpath.strip()
|
subpath = "M" + subpath.strip()
|
||||||
coords = [[round(float(o), 1) for o in co[1:].split(",")] for co in subpath.split()]
|
coords = [[round(float(o), 1) for o in co[1:].split(",")] for co in subpath.split()]
|
||||||
|
if coords[0] != coords[-1]:
|
||||||
|
has_open_paths = True
|
||||||
line_strings.append(shapely.LineString(coords))
|
line_strings.append(shapely.LineString(coords))
|
||||||
old_paths.append(path)
|
old_paths.append(path)
|
||||||
unioned_line_strings = shapely.union_all(shapely.GeometryCollection(line_strings))
|
|
||||||
if hasattr(unioned_line_strings, "geoms"):
|
results = []
|
||||||
results = shapely.polygonize_full(unioned_line_strings.geoms)
|
if has_open_paths:
|
||||||
else:
|
unioned_line_strings = shapely.union_all(shapely.GeometryCollection(line_strings))
|
||||||
results = []
|
if hasattr(unioned_line_strings, "geoms"):
|
||||||
|
results = shapely.polygonize_full(unioned_line_strings.geoms)
|
||||||
|
|
||||||
# If we succeeded in generating new path geometry, remove all the
|
# If we succeeded in generating new path geometry, remove all the
|
||||||
# old paths and add new ones.
|
# old paths and add new ones.
|
||||||
|
|||||||
Reference in New Issue
Block a user