mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Fix importing IfcPolylines always assuming they're closed
Resolved issue during import in #6259 but doesn't completely resolves the issue.
This commit is contained in:
@@ -497,19 +497,24 @@ class Model(bonsai.core.tool.Model):
|
|||||||
offset = len(cls.vertices)
|
offset = len(cls.vertices)
|
||||||
|
|
||||||
if curve.is_a("IfcPolyline"):
|
if curve.is_a("IfcPolyline"):
|
||||||
total_points = len(curve.Points)
|
curve_points: tuple[ifcopenshell.entity_instance, ...] = curve.Points
|
||||||
last_index = len(curve.Points) - 1
|
# Polyline must have 2 points to be valid.
|
||||||
for i, point in enumerate(curve.Points):
|
is_closed = np.allclose(curve_points[0].Coordinates, curve_points[-1].Coordinates)
|
||||||
if i == last_index:
|
|
||||||
continue
|
points_to_add = curve_points[:-1] if is_closed else curve_points
|
||||||
|
for point in points_to_add:
|
||||||
global_point = position @ Vector(cls.convert_unit_to_si(point.Coordinates)).to_3d()
|
global_point = position @ Vector(cls.convert_unit_to_si(point.Coordinates)).to_3d()
|
||||||
cls.vertices.append(global_point)
|
cls.vertices.append(global_point)
|
||||||
cls.edges.extend([(i, i + 1) for i in range(offset, len(cls.vertices))])
|
|
||||||
cls.edges[-1] = (len(cls.vertices) - 1, offset) # Close the loop
|
cls.edges.extend([(i, i + 1) for i in range(offset, len(cls.vertices) - 1)])
|
||||||
|
if is_closed:
|
||||||
|
cls.edges[-1] = (len(cls.vertices) - 1, offset) # Close the loop
|
||||||
|
|
||||||
elif curve.is_a("IfcCompositeCurve"):
|
elif curve.is_a("IfcCompositeCurve"):
|
||||||
# This is a first pass incomplete implementation only for simple polylines, and misses many details.
|
# This is a first pass incomplete implementation only for simple polylines, and misses many details.
|
||||||
for segment in curve.Segments:
|
for segment in curve.Segments:
|
||||||
cls.convert_curve_to_mesh(obj, position, segment.ParentCurve)
|
cls.convert_curve_to_mesh(obj, position, segment.ParentCurve)
|
||||||
|
|
||||||
elif curve.is_a("IfcIndexedPolyCurve"):
|
elif curve.is_a("IfcIndexedPolyCurve"):
|
||||||
for local_point in curve.Points.CoordList:
|
for local_point in curve.Points.CoordList:
|
||||||
global_point = position @ Vector(cls.convert_unit_to_si(local_point)).to_3d()
|
global_point = position @ Vector(cls.convert_unit_to_si(local_point)).to_3d()
|
||||||
|
|||||||
Reference in New Issue
Block a user