BIMNode
The BIMNode class in Geomapi represents the data and metadata of ifc data. The data itself and methods build upon Open3D TriangleMesh and IFCOPENSHELL concepts while the metadata builds upon the RDFlib framework:
http://www.open3d.org/docs/latest/tutorial/Basic/mesh.html#
https://rdflib.readthedocs.io/
The code below shows how to create a BIMNode from various inputs.
First the geomapi and external packages are imported
#IMPORT PACKAGES
from rdflib import Graph
import os
import numpy as np
#IMPORT MODULES
from context import geomapi #context import for documentation only
from geomapi.nodes import BIMNode
Jupyter environment detected. Enabling Open3D WebVisualizer.
[Open3D INFO] WebRTC GUI backend enabled.
[Open3D INFO] WebRTCWindowSystem: HTTP handshake server disabled.
BIMNode Creation
A BIMNode is constructed using the same parameters as the base Node. Please refer to Node Tutorial For more info about Node Creation
BIMNode( subject = None, # (URIRef, optional) : A subject to use as identifier for the Node.
graph = None, # (Graph, optional) : An RDF Graph to parse.
graphPath = None, # (Path, optional) : The path of an RDF Graph to parse.
name = None, # (str, optional) : A name of the Node.
path = None, # (Path, optional) : A filepath to a resource.
timestamp = None, # (str, optional) : Timestamp for the node.
resource = None, # (optional) : Resource associated with the node.
cartesianTransform = None, # (np.ndarray, optional) : The (4x4) transformation matrix.
orientedBoundingBox = None, # (o3d.geometry.OrientedBoundingBox, optional) : The oriented bounding box of the node.
convexHull = None, # (o3d.geometry.TriangleBIM, optional) : The convex hull of the node.
loadResource = False, # Load the resource at initialization?
ifcPath = None, # (Path, optional) : path to IFC file
globalId = None, # (str, optional) : IFC globalId
className = None, # (str, optional) : IFC className e.g. IfcWall, IfcBeam, IfcSlab, etc.
objectType = None # (str, optional) : IFC object type e.g. i.e. Floor:232_FL_Concrete CIP 400mm
)
Ontology link
The BIMNode has 4 new standard properties that are serialized to the graph:
python name |
predicate |
---|---|
|
|
|
|
|
|
|
|
Creation From IFC file
Since IFC files contain a large amount of elements, they cannot be loaded directly into a BIMNode.
Use the geomapi.tools.ifc_to_bim_nodes
function to load all elements into a list of BIMNodes.
import geomapi.tools as tl
bimnodes = tl.ifc_to_bim_nodes(path = r"../../..\tests\testfiles\ifc\parking.ifc", classes='IfcColumn')
print(len(bimnodes))
125
BIMNode Resource
When creating a BIMNode with a resource, it can be done either directly with the resource, or with the path to the resource. The resource can be a o3d.geometry.TriangleMesh
, trimesh.base.Trimesh
or an ifcopenshell.entity_instance
. The resource is always converted to a o3d.geometry.TriangleMesh
A resource can be a big piece of data, this is why it is not always wanted to load the whole resource at initialization. This is why the loadResource
parameter is default to False
Loading The Resource
node = BIMNode(path=r"../../..\tests\testfiles\ifc\Basic_Wall_168_WA_f2_Soilmix_600mm_956569_06v1k9ENv8DhGMCvKUuLQV.ply", loadResource=False)
print("resource before loading:",node.resource)
node.load_resource() # Use specialized node fo each type of resource.
print("resource after loading:",node.resource)
Resource not loaded, but path is defined, call `load_resource()` to access it.
Resource not loaded, but path is defined, call `load_resource()` to access it.
resource before loading: None
resource after loading: TriangleMesh with 16 points and 28 triangles.
Saving The Resource
A BIM resource can be saved to disk using the save_resource()
function.
Currently supports: .ply, .obj
node = BIMNode(path=r"../../..\tests\testfiles\ifc\Basic_Wall_168_WA_f2_Soilmix_600mm_956569_06v1k9ENv8DhGMCvKUuLQV.ply", loadResource=True)
node.save_resource(directory=r"../../../tests/testfiles/resources", extension=".ply") # Save the resource to the resourcePath
True
BIMNode Transformation
Since every nod has a cartesian transform, it can be transformed using the node.transform()
function.
The transformation also updates the convexHull
and orientedBoundingBox
.
Furthermore, if the BIMNode has a resource, that resource is also transformed.
node = BIMNode()
print(node.cartesianTransform)
transformation = np.array([[0,0,1,0],[0,1,0,0],[1,0,0,0],[0,0,0,1]])
node.transform(transformation=transformation)
print("applying transformation: (-1)")
print(node.cartesianTransform,"\n")
node = BIMNode()
rotation = np.array([90,0,0]) #eulers in degrees
node.transform(rotation=rotation)
print("applying rotation: (90,0,0)")
print(node.cartesianTransform,"\n")
node = BIMNode()
translation = np.array([1,2,3])
node.transform(translation=translation)
print("applying translation: (1,2,3)")
print(node.cartesianTransform)
[[1. 0. 0. 0.]
[0. 1. 0. 0.]
[0. 0. 1. 0.]
[0. 0. 0. 1.]]
applying transformation: (-1)
[[0. 0. 1. 0.]
[0. 1. 0. 0.]
[1. 0. 0. 0.]
[0. 0. 0. 1.]]
applying rotation: (90,0,0)
[[ 1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00]
[ 0.000000e+00 6.123234e-17 -1.000000e+00 0.000000e+00]
[ 0.000000e+00 1.000000e+00 6.123234e-17 0.000000e+00]
[ 0.000000e+00 0.000000e+00 0.000000e+00 1.000000e+00]]
applying translation: (1,2,3)
[[1. 0. 0. 1.]
[0. 1. 0. 2.]
[0. 0. 1. 3.]
[0. 0. 0. 1.]]
BIMNode Visualisation
When a BIMNode has a resource, the show()
function displays the BIM using either open3d or Trimesh, depending on the workspace.
Use the inline = True
parameter to display the Mesh using the Trimesh viewer in your jupyter notebook file. Otherwise the function opens a new python window to display the open3d viewer
node = BIMNode(path=r"../../..\tests\testfiles\ifc\Basic_Wall_168_WA_f2_Soilmix_600mm_956569_06v1k9ENv8DhGMCvKUuLQV.ply", loadResource=True)
node.show(inline=True) # The standard node has no resource to display
Further reading
Please refer to the full API documentation of the BIMNode class for more details about the functionality