66
77
88class IfcEntity :
9- def __init__ (self , data ):
10- self .ifctype = data ['ifc_type' ]
11- self .id = data ['id' ]
12-
13- def __str__ (self ):
14- return "#" + str (self .id ) + "_" + self .ifctype
15- __repr__ = __str__
9+ def __init__ (self , data ):
10+ self .ifctype = data ["ifc_type" ]
11+ self .id = data ["id" ]
1612
13+ def __str__ (self ):
14+ return "#" + str (self .id ) + "_" + self .ifctype
1715
16+ __repr__ = __str__
1817
19- def get_cmap (n , name = 'hsv' ):
20- '''Returns a function that maps each index in 0, 1, ..., n-1 to a distinct
21- RGB color; the keyword argument name must be a standard mpl colormap name.'''
18+
19+ def get_cmap (n , name = "hsv" ):
20+ """Returns a function that maps each index in 0, 1, ..., n-1 to a distinct
21+ RGB color; the keyword argument name must be a standard mpl colormap name."""
2222 return plt .cm .get_cmap (name , n )
2323
2424
@@ -32,14 +32,14 @@ def get_cmap(n, name='hsv'):
3232types_color = {}
3333
3434for e in ents .values ():
35- for r in e [' attributes' ][1 ]:
36- G .add_edge (e ['id' ], r )
37- color_map .append (' red' )
38- ifctypes .add (e [' ifc_type' ])
39- ifctypes .add (ents [r ][' ifc_type' ])
40-
35+ for r in e [" attributes" ][1 ]:
36+ G .add_edge (e ["id" ], r )
37+ color_map .append (" red" )
38+ ifctypes .add (e [" ifc_type" ])
39+ ifctypes .add (ents [r ][" ifc_type" ])
40+
4141
42- cmap = get_cmap (len (ifctypes ),' rainbow' )
42+ cmap = get_cmap (len (ifctypes ), " rainbow" )
4343
4444colors = [cmap (i ) for i in range (len (ifctypes ))]
4545
@@ -49,14 +49,14 @@ def get_cmap(n, name='hsv'):
4949
5050i = 0
5151for eid in G .nodes ():
52- t = ents [eid ][' ifc_type' ]
53- # print(t)
54- if t in type_color_mapping .keys ():
55- cols .append (type_color_mapping [t ])
56- else :
57- type_color_mapping [t ] = colors [i ]
58- i = i + 1
59- cols .append (type_color_mapping [t ])
52+ t = ents [eid ][" ifc_type" ]
53+ # print(t)
54+ if t in type_color_mapping .keys ():
55+ cols .append (type_color_mapping [t ])
56+ else :
57+ type_color_mapping [t ] = colors [i ]
58+ i = i + 1
59+ cols .append (type_color_mapping [t ])
6060
6161
6262# k controls the distance between the nodes and varies between 0 and 1
@@ -70,27 +70,23 @@ def get_cmap(n, name='hsv'):
7070
7171c_map = [cmap (i ) for i in range (len (nodes ))]
7272
73- nc = nx .draw_networkx_nodes (G , pos ,nodelist = nodes , node_color = cols ,node_size = 200 )
73+ nc = nx .draw_networkx_nodes (G , pos , nodelist = nodes , node_color = cols , node_size = 200 )
7474
7575# edges
76- elarge = [(u , v ) for (u , v , d ) in G .edges (data = True ) ]
77- nx .draw_networkx_edges (G , pos ,edgelist = elarge , width = 1 )
76+ elarge = [(u , v ) for (u , v , d ) in G .edges (data = True )]
77+ nx .draw_networkx_edges (G , pos , edgelist = elarge , width = 1 )
7878
7979nx .draw_networkx_labels (G , pos , font_size = 8 , font_family = "sans-serif" )
8080
8181
82- red_patch = mpatches .Patch (color = ' red' , label = ' The red data' )
83- blue_patch = mpatches .Patch (color = ' blue' , label = ' The blue data' )
82+ red_patch = mpatches .Patch (color = " red" , label = " The red data" )
83+ blue_patch = mpatches .Patch (color = " blue" , label = " The blue data" )
8484
8585patches = []
86- for k ,v in type_color_mapping .items ():
87- patches .append (mpatches .Patch (color = v , label = k ))
86+ for k , v in type_color_mapping .items ():
87+ patches .append (mpatches .Patch (color = v , label = k ))
8888
8989
90- plt .legend (handles = patches ,fontsize = 8 )
90+ plt .legend (handles = patches , fontsize = 8 )
9191plt .axis ("off" )
9292plt .show ()
93-
94-
95-
96-
0 commit comments