topologicpy icon indicating copy to clipboard operation
topologicpy copied to clipboard

Problem when converting an IFC model into a topology graph representing geometric information

Open hliuci opened this issue 1 year ago • 4 comments

Hi, I am trying to convert an IFC model into a topology graph representing its geometric information. I tried Graph.ByIFCPath but it returned the element/relationship entities and attached attributes instead of geoemtric information like vertex, edge, face, etc. in the graph. Then I used The codes below.

topo = Topology.ByIFCPath(IFC_FILE_PATH)
graph = Graph.ByTopology(topo)

But I got an error of Graph.ByTopology - Error: The input topology is not a valid topology. Returning None.. I found that the input of Graph.ByTopology is topologic_core.Topology, while the output of Topology.ByIFCPath is The created list of topologies according to the documentation. How to bridge this gap between the input and output to create a topology graph of the IFC model? Or are there other ways for the conversion? Thanks!

hliuci avatar Oct 02 '24 02:10 hliuci

You simply do the following:

from topologicpy.Topology import Topology
from topologicpy.Cluster import Cluster
from topologicpy.Graph import Graph

topo_list = Topology.ByIFCPath(IFC_FILE_PATH)
cluster = Cluster.ByTopologies(topo_list)
graph = Graph.ByTopology(cluster)

wassimj avatar Oct 02 '24 03:10 wassimj

@wassimj Thanks for reply! I have used the codes to generate the graph. But it seems to miss information.

from topologicpy.Topology import Topology
from topologicpy.Cluster import Cluster
from topologicpy.Graph import Graph
import ifcopenshell.geom

IFC_FILE_PATH = 'Cubes.ifc'

topo_list = Topology.ByIFCPath(IFC_FILE_PATH)
cluster = Cluster.ByTopologies(topo_list)
graph = Graph.ByTopology(cluster)

edges = Graph.Edges(graph)
nodes = Graph.Vertices(graph)
print(f"The number of edges in the graph is: {len(edges)}")
print(f"The number of nodes in the graph is: {len(nodes)}")

The output is 2 edges and 35 nodes, which seems not reflecting the model's topology. I also exported the graph to JSON and found it shows like below:

"vertices": {
        "Vertex_0000": {
            "category": 0,
            "x": 6.357035,
            "y": 0.985815,
            "z": 1.838366
        },
        "Vertex_0001": {
            "category": 0,
            "x": 4.572035,
            "y": 3.390591,
            "z": 1.7
        },
......

And the visualization is like this: image

I wonder what the output from ByTopology would contain and be like? I didn't find the geometric information about vertex, edge, face, etc. and which elements they belong to. Here are the simple Cubes model and the JSON output.

hliuci avatar Oct 02 '24 05:10 hliuci

You should read the documentation on Graph.ByTopology to find out how to create relationships between the Cell, and its faces. Graph.ByTopology creates a dual graph not a primary graph. Please clarify what kind of graph you are trying to create. Please post a picture of the topologies themselves. It seems there are a group of cells with one cellcomplex

wassimj avatar Oct 02 '24 06:10 wassimj

Thanks for your advice. I will further read the documentation. Actually I don't have a particular graph form in mind now, just wonder what the graph representation of geometric and spatial information (e.g., coordinates, (shared)faces) looks like.

You should read the documentation on Graph.ByTopology to find out how to create relationships between the Cell, and its faces. Graph.ByTopology creates a dual graph not a primary graph. Please clarify what kind of graph you are trying to create. Please post a picture of the topologies themselves. It seems there are a group of cells with one cellcomplex

hliuci avatar Oct 02 '24 11:10 hliuci

Please feel free to book a time with me to get advice using http://jabiw.ycbm.me For now, I am closing this as this is not an issue with the software, but a request for help.

wassimj avatar Nov 16 '24 07:11 wassimj