mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 22:22:26 +00:00
Fix regressions in mapped native swept disk handling
This commit is contained in:
@@ -494,7 +494,7 @@ class IfcImporter:
|
|||||||
|
|
||||||
rep = representation
|
rep = representation
|
||||||
while True:
|
while True:
|
||||||
if rep.Items and rep.Items[0].is_a("IfcMappedItem"):
|
if len(rep.Items) == 1 and rep.Items[0].is_a("IfcMappedItem"):
|
||||||
rep_matrix = ifcopenshell.util.placement.get_mappeditem_transformation(rep.Items[0])
|
rep_matrix = ifcopenshell.util.placement.get_mappeditem_transformation(rep.Items[0])
|
||||||
if not np.allclose(rep_matrix, np.eye(4)):
|
if not np.allclose(rep_matrix, np.eye(4)):
|
||||||
matrix = rep_matrix @ matrix
|
matrix = rep_matrix @ matrix
|
||||||
@@ -547,7 +547,7 @@ class IfcImporter:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def is_native_swept_disk_solid(self, element, representation):
|
def is_native_swept_disk_solid(self, element, representation):
|
||||||
items = representation.Items or [] # Be forgiving of invalid IFCs because Revit :(
|
items = [i["item"] for i in ifcopenshell.util.representation.resolve_items(representation)]
|
||||||
if len(items) == 1 and items[0].is_a("IfcSweptDiskSolid"):
|
if len(items) == 1 and items[0].is_a("IfcSweptDiskSolid"):
|
||||||
if tool.Blender.Modifier.is_railing(element):
|
if tool.Blender.Modifier.is_railing(element):
|
||||||
return False
|
return False
|
||||||
@@ -563,6 +563,7 @@ class IfcImporter:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def is_native_faceted_brep(self, representation):
|
def is_native_faceted_brep(self, representation):
|
||||||
|
# TODO handle mapped items
|
||||||
for i in representation.Items:
|
for i in representation.Items:
|
||||||
if i.is_a() != "IfcFacetedBrep":
|
if i.is_a() != "IfcFacetedBrep":
|
||||||
return False
|
return False
|
||||||
@@ -1316,12 +1317,17 @@ class IfcImporter:
|
|||||||
curve.resolution_u = 2
|
curve.resolution_u = 2
|
||||||
polyline = curve.splines.new("POLY")
|
polyline = curve.splines.new("POLY")
|
||||||
|
|
||||||
for item in native_data["representation"].Items:
|
for item_data in ifcopenshell.util.representation.resolve_items(native_data["representation"]):
|
||||||
|
item = item_data["item"]
|
||||||
|
matrix = item_data["matrix"]
|
||||||
|
matrix[0][3] *= self.unit_scale
|
||||||
|
matrix[1][3] *= self.unit_scale
|
||||||
|
matrix[2][3] *= self.unit_scale
|
||||||
# TODO: support inner radius, start param, and end param
|
# TODO: support inner radius, start param, and end param
|
||||||
geometry = self.create_generic_shape(item.Directrix)
|
geometry = self.create_generic_shape(item.Directrix)
|
||||||
e = geometry.edges
|
e = geometry.edges
|
||||||
v = geometry.verts
|
v = geometry.verts
|
||||||
vertices = [[v[i], v[i + 1], v[i + 2], 1] for i in range(0, len(v), 3)]
|
vertices = [list(matrix @ [v[i], v[i + 1], v[i + 2], 1]) for i in range(0, len(v), 3)]
|
||||||
edges = [[e[i], e[i + 1]] for i in range(0, len(e), 2)]
|
edges = [[e[i], e[i + 1]] for i in range(0, len(e), 2)]
|
||||||
v2 = None
|
v2 = None
|
||||||
for edge in edges:
|
for edge in edges:
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
|
||||||
|
|
||||||
@@ -67,6 +68,21 @@ def get_representation(element, context, subcontext=None, target_view=None):
|
|||||||
|
|
||||||
|
|
||||||
def resolve_representation(representation):
|
def resolve_representation(representation):
|
||||||
if representation.Items and representation.Items[0].is_a("IfcMappedItem"):
|
if len(representation.Items) == 1 and representation.Items[0].is_a("IfcMappedItem"):
|
||||||
return resolve_representation(representation.Items[0].MappingSource.MappedRepresentation)
|
return resolve_representation(representation.Items[0].MappingSource.MappedRepresentation)
|
||||||
return representation
|
return representation
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_items(representation, matrix=None):
|
||||||
|
if matrix is None:
|
||||||
|
matrix = np.eye(4)
|
||||||
|
results = []
|
||||||
|
for item in representation.Items or []: # Be forgiving of invalid IFCs because Revit :(
|
||||||
|
if item.is_a("IfcMappedItem"):
|
||||||
|
rep_matrix = ifcopenshell.util.placement.get_mappeditem_transformation(item)
|
||||||
|
if not np.allclose(rep_matrix, np.eye(4)):
|
||||||
|
rep_matrix = rep_matrix @ matrix.copy()
|
||||||
|
results.extend(resolve_items(item.MappingSource.MappedRepresentation, rep_matrix))
|
||||||
|
else:
|
||||||
|
results.append({"matrix": matrix.copy(), "item": item})
|
||||||
|
return results
|
||||||
|
|||||||
Reference in New Issue
Block a user