6
6
7
7
8
8
class 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" ]
16
12
13
+ def __str__ (self ):
14
+ return "#" + str (self .id ) + "_" + self .ifctype
17
15
16
+ __repr__ = __str__
18
17
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."""
22
22
return plt .cm .get_cmap (name , n )
23
23
24
24
@@ -32,14 +32,14 @@ def get_cmap(n, name='hsv'):
32
32
types_color = {}
33
33
34
34
for 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
+
41
41
42
- cmap = get_cmap (len (ifctypes ),' rainbow' )
42
+ cmap = get_cmap (len (ifctypes ), " rainbow" )
43
43
44
44
colors = [cmap (i ) for i in range (len (ifctypes ))]
45
45
@@ -49,14 +49,14 @@ def get_cmap(n, name='hsv'):
49
49
50
50
i = 0
51
51
for 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 ])
60
60
61
61
62
62
# k controls the distance between the nodes and varies between 0 and 1
@@ -70,27 +70,23 @@ def get_cmap(n, name='hsv'):
70
70
71
71
c_map = [cmap (i ) for i in range (len (nodes ))]
72
72
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 )
74
74
75
75
# 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 )
78
78
79
79
nx .draw_networkx_labels (G , pos , font_size = 8 , font_family = "sans-serif" )
80
80
81
81
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" )
84
84
85
85
patches = []
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 ))
88
88
89
89
90
- plt .legend (handles = patches ,fontsize = 8 )
90
+ plt .legend (handles = patches , fontsize = 8 )
91
91
plt .axis ("off" )
92
92
plt .show ()
93
-
94
-
95
-
96
-
0 commit comments