Skip to content

Commit

Permalink
Shortlist which IFC geometries may be treated as a meshlike object.
Browse files Browse the repository at this point in the history
  • Loading branch information
Moult committed Apr 2, 2023
1 parent 061922a commit 901f413
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/blenderbim/blenderbim/bim/module/geometry/operator.py
Expand Up @@ -747,7 +747,7 @@ def _execute(self, context):
obj.select_set(False)
continue

if representation.RepresentationType in ("Tessellation", "Brep"):
if tool.Geometry.is_meshlike(representation):
if element.HasOpenings:
# Mesh elements with openings must disable openings
# so that you can edit the original topology.
Expand Down Expand Up @@ -837,9 +837,8 @@ def invoke(self, context, event):

if obj.data.BIMMeshProperties.ifc_definition_id:
representation = tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
if representation.RepresentationType in (
"Tessellation",
"Brep",
if tool.Geometry.is_meshlike(
representation
) and obj.data.BIMMeshProperties.mesh_checksum != tool.Geometry.get_mesh_checksum(obj.data):
self.edited_objs.append(obj)
elif element.HasOpenings:
Expand Down
32 changes: 28 additions & 4 deletions src/blenderbim/blenderbim/tool/geometry.py
Expand Up @@ -135,13 +135,13 @@ def get_mesh_checksum(cls, mesh):
faces = mesh.polygons[:]

# Convert mesh data to bytes
data_bytes = b''
data_bytes = b""
for v in vertices:
data_bytes += struct.pack('3f', *v.co)
data_bytes += struct.pack("3f", *v.co)
for e in edges:
data_bytes += struct.pack('2i', *e.vertices)
data_bytes += struct.pack("2i", *e.vertices)
for f in faces:
data_bytes += struct.pack('%di' % len(f.vertices), *f.vertices)
data_bytes += struct.pack("%di" % len(f.vertices), *f.vertices)

# Generate hash of mesh data
hasher = hashlib.sha1()
Expand Down Expand Up @@ -261,6 +261,30 @@ def is_edited(cls, obj):
def is_mapped_representation(cls, representation):
return representation.RepresentationType == "MappedRepresentation"

@classmethod
def is_meshlike(cls, representation):
if representation.RepresentationType in (
"AdvancedBrep",
"Annotation2D",
"BoundingBox",
"Brep",
"Curve",
"Curve2D",
"Curve3D",
"FillArea",
"GeometricCurveSet",
"GeometricSet",
"Point",
"PointCloud",
"Surface",
"Surface2D",
"Surface3D",
"SurfaceModel",
"Tessellation",
):
return True
return False

@classmethod
def is_type_product(cls, element):
return element.is_a("IfcTypeProduct")
Expand Down

0 comments on commit 901f413

Please sign in to comment.