mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
Support export of point clouds to IFC
This commit is contained in:
@@ -698,13 +698,21 @@ class IfcParser():
|
|||||||
return results
|
return results
|
||||||
for product in self.selected_products + self.type_products:
|
for product in self.selected_products + self.type_products:
|
||||||
obj = product['raw']
|
obj = product['raw']
|
||||||
if obj.data is None or obj.data.name in results:
|
if self.is_point_cloud(obj):
|
||||||
|
results['Model/Body/MODEL_VIEW/{}'.format(obj.name)] = self.get_representation(
|
||||||
|
obj.point_cloud_visualizer, obj, 'Model', 'Body', 'MODEL_VIEW')
|
||||||
|
continue
|
||||||
|
elif obj.data is None or obj.data.name in results:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.append_default_representation(obj, results)
|
self.append_default_representation(obj, results)
|
||||||
self.append_representation_per_context(obj, results)
|
self.append_representation_per_context(obj, results)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
def is_point_cloud(self, obj):
|
||||||
|
return hasattr(obj, 'point_cloud_visualizer') \
|
||||||
|
and obj.point_cloud_visualizer.uuid
|
||||||
|
|
||||||
def append_default_representation(self, obj, results):
|
def append_default_representation(self, obj, results):
|
||||||
if not self.is_mesh_context_sensitive(obj.data.name):
|
if not self.is_mesh_context_sensitive(obj.data.name):
|
||||||
results['Model/Body/MODEL_VIEW/{}'.format(obj.data.name)] = self.get_representation(
|
results['Model/Body/MODEL_VIEW/{}'.format(obj.data.name)] = self.get_representation(
|
||||||
@@ -735,6 +743,7 @@ class IfcParser():
|
|||||||
'is_wireframe': mesh.BIMMeshProperties.is_wireframe if hasattr(mesh, 'BIMMeshProperties') else False,
|
'is_wireframe': mesh.BIMMeshProperties.is_wireframe if hasattr(mesh, 'BIMMeshProperties') else False,
|
||||||
'is_swept_solid': mesh.BIMMeshProperties.is_swept_solid if hasattr(mesh, 'BIMMeshProperties') else False,
|
'is_swept_solid': mesh.BIMMeshProperties.is_swept_solid if hasattr(mesh, 'BIMMeshProperties') else False,
|
||||||
'is_generated': is_generated,
|
'is_generated': is_generated,
|
||||||
|
'is_point_cloud': self.is_point_cloud(obj),
|
||||||
'attributes': {'Name': mesh.name}
|
'attributes': {'Name': mesh.name}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -870,6 +879,8 @@ class IfcParser():
|
|||||||
|
|
||||||
def get_object_representation_names(self, obj):
|
def get_object_representation_names(self, obj):
|
||||||
names = []
|
names = []
|
||||||
|
if self.is_point_cloud(obj):
|
||||||
|
names.append('Model/Body/MODEL_VIEW/{}'.format(obj.name))
|
||||||
if obj.data is None:
|
if obj.data is None:
|
||||||
return names
|
return names
|
||||||
if not self.is_mesh_context_sensitive(obj.data.name):
|
if not self.is_mesh_context_sensitive(obj.data.name):
|
||||||
@@ -1594,7 +1605,7 @@ class IfcExporter():
|
|||||||
return self.file.createIfcShapeRepresentation(
|
return self.file.createIfcShapeRepresentation(
|
||||||
shape_representation.ContextOfItems,
|
shape_representation.ContextOfItems,
|
||||||
shape_representation.RepresentationIdentifier,
|
shape_representation.RepresentationIdentifier,
|
||||||
shape_representation.RepresentationType,
|
'MappedRepresentation',
|
||||||
[mapped_item])
|
[mapped_item])
|
||||||
|
|
||||||
def calculate_quantities(self, qto_name, obj):
|
def calculate_quantities(self, qto_name, obj):
|
||||||
@@ -1661,6 +1672,9 @@ class IfcExporter():
|
|||||||
elif representation['is_swept_solid']:
|
elif representation['is_swept_solid']:
|
||||||
return self.file.createIfcRepresentationMap(self.origin,
|
return self.file.createIfcRepresentationMap(self.origin,
|
||||||
self.create_swept_solid_representation(representation))
|
self.create_swept_solid_representation(representation))
|
||||||
|
elif representation['is_point_cloud']:
|
||||||
|
return self.file.createIfcRepresentationMap(self.origin,
|
||||||
|
self.create_point_cloud_representation(representation))
|
||||||
return self.file.createIfcRepresentationMap(self.origin,
|
return self.file.createIfcRepresentationMap(self.origin,
|
||||||
self.create_solid_representation(representation))
|
self.create_solid_representation(representation))
|
||||||
|
|
||||||
@@ -1929,6 +1943,17 @@ class IfcExporter():
|
|||||||
del edges[i]
|
del edges[i]
|
||||||
return polyLine
|
return polyLine
|
||||||
|
|
||||||
|
def create_point_cloud_representation(self, representation):
|
||||||
|
import space_view3d_point_cloud_visualizer as pcv
|
||||||
|
if representation['raw'].uuid not in pcv.PCVManager.cache:
|
||||||
|
return
|
||||||
|
return self.file.createIfcShapeRepresentation(
|
||||||
|
self.ifc_rep_context[representation['context']][representation['subcontext']][
|
||||||
|
representation['target_view']]['ifc'],
|
||||||
|
representation['subcontext'], 'PointCloud',
|
||||||
|
[self.file.createIfcCartesianPointList3D(
|
||||||
|
pcv.PCVManager.cache[representation['raw'].uuid]['points'].tolist())])
|
||||||
|
|
||||||
def create_solid_representation(self, representation):
|
def create_solid_representation(self, representation):
|
||||||
mesh = representation['raw']
|
mesh = representation['raw']
|
||||||
self.create_vertices(mesh.vertices)
|
self.create_vertices(mesh.vertices)
|
||||||
|
|||||||
Reference in New Issue
Block a user