mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
ShapeBuilder.polyline - skip creating segments if they are not needed
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -258,11 +258,7 @@ class FilledOpeningGenerator:
|
|||||||
unioned_boundaries = shapely.union_all(shapely.GeometryCollection(boundary_lines))
|
unioned_boundaries = shapely.union_all(shapely.GeometryCollection(boundary_lines))
|
||||||
closed_polygons = shapely.polygonize(boundary_lines)
|
closed_polygons = shapely.polygonize(boundary_lines)
|
||||||
polygon = max(closed_polygons.geoms, key=lambda polygon: polygon.area)
|
polygon = max(closed_polygons.geoms, key=lambda polygon: polygon.area)
|
||||||
|
|
||||||
if tool.Ifc.get_schema() == "IFC2X3":
|
|
||||||
return shape_builder.polyline(list(polygon.exterior.coords))
|
return shape_builder.polyline(list(polygon.exterior.coords))
|
||||||
points = tool.Ifc.get().createIfcCartesianPointList2D(list(polygon.exterior.coords))
|
|
||||||
return tool.Ifc.get().createIfcIndexedPolyCurve(points)
|
|
||||||
|
|
||||||
extrusion = shape_builder.extrude(
|
extrusion = shape_builder.extrude(
|
||||||
get_curve_2d_from_3d(profile),
|
get_curve_2d_from_3d(profile),
|
||||||
|
|||||||
@@ -42,6 +42,28 @@ class ShapeBuilder:
|
|||||||
if arc_points and self.file.schema == "IFC2X3":
|
if arc_points and self.file.schema == "IFC2X3":
|
||||||
raise Exception("Arcs are not supported for IFC2X3.")
|
raise Exception("Arcs are not supported for IFC2X3.")
|
||||||
|
|
||||||
|
if position_offset:
|
||||||
|
points = [Vector(p) + position_offset for p in points]
|
||||||
|
|
||||||
|
if self.file.schema == "IFC2X3":
|
||||||
|
points = [self.file.createIfcCartesianPoint(p) for p in points]
|
||||||
|
if closed:
|
||||||
|
points.append(points[0])
|
||||||
|
ifc_curve = self.file.createIfcPolyline(Points=points)
|
||||||
|
return ifc_curve
|
||||||
|
|
||||||
|
dimensions = len(points[0])
|
||||||
|
if dimensions == 2:
|
||||||
|
ifc_points = self.file.createIfcCartesianPointList2D(points)
|
||||||
|
elif dimensions == 3:
|
||||||
|
ifc_points = self.file.createIfcCartesianPointList3D(points)
|
||||||
|
|
||||||
|
if not closed and not arc_points:
|
||||||
|
ifc_curve = self.file.createIfcIndexedPolyCurve(Points=ifc_points)
|
||||||
|
return ifc_curve
|
||||||
|
|
||||||
|
# if curve is closed or we have arc points
|
||||||
|
# then we do need to create segments
|
||||||
segments = []
|
segments = []
|
||||||
cur_i = 0
|
cur_i = 0
|
||||||
while cur_i < len(points) - 1:
|
while cur_i < len(points) - 1:
|
||||||
@@ -55,18 +77,6 @@ class ShapeBuilder:
|
|||||||
|
|
||||||
if closed:
|
if closed:
|
||||||
segments.append((len(points), 1))
|
segments.append((len(points), 1))
|
||||||
if position_offset:
|
|
||||||
points = [Vector(p) + position_offset for p in points]
|
|
||||||
|
|
||||||
if self.file.schema == "IFC2X3":
|
|
||||||
points = [self.file.createIfcCartesianPoint(p) for p in points]
|
|
||||||
ifc_curve = self.file.createIfcPolyline(Points=points)
|
|
||||||
else:
|
|
||||||
dimensions = len(points[0])
|
|
||||||
if dimensions == 2:
|
|
||||||
ifc_points = self.file.createIfcCartesianPointList2D(points)
|
|
||||||
elif dimensions == 3:
|
|
||||||
ifc_points = self.file.createIfcCartesianPointList3D(points)
|
|
||||||
|
|
||||||
ifc_segments = []
|
ifc_segments = []
|
||||||
# because IfcLineIndex support 2+ points
|
# because IfcLineIndex support 2+ points
|
||||||
|
|||||||
Reference in New Issue
Block a user