## 3 Methodology
### Building Components Extraction and Wall Segment Restoration
The translucent yellow area is the intersection area of the oriented bounding boxes. Figure 5: Wall surface extraction and restoration process. the topological relationships of indoor wall segments are analyzed according to the spatial location of wall segments and ceilings. Algorithm 1 introduces the specific process. ```
Input: Wall segment raster: \(\mathbf{W_{all}}\)  Guide line (The outline of a free-space evidence raster): \(\mathbf{G}\)  Wall segment search radius: \(\mathbf{r_{w}}\)  Connection search radius: \(\mathbf{r_{c}}\)  Ceiling: \(\mathbf{C}\) Output: Topological relations of wall segment: \(\mathbf{T_{boundary}}\) (1) \(\mathbf{W}=\text{getDisjointLines}\) (\(\mathbf{W_{all}}\)); // Get disjoint wall segments in all wall segments (2) for each \(\mathbf{w}\in\mathbf{W}\) (3) [\(\mathbf{P_{center}}\), \(\mathbf{P_{end}}\)] = getMidPixelandEndPixel (\(\mathbf{w}\)); (4) \(\mathbf{e}=\text{getForwardDirection}\) (\(\mathbf{P_{center}}\), \(\mathbf{P_{end}}\)); // Construct the forward direction from \(\mathbf{P_{center}}\) to \(\mathbf{P_{end}}\) (5) \(\mathbf{P}=\text{searchClosestPixel}\) (\(\mathbf{P_{end}}\), \(\mathbf{G}\), \(\mathbf{r_{w}}\)); // Search for the nearest pixel in \(\mathbf{G}\) to \(\mathbf{P_{end}}\) within the radius \(\mathbf{r_{w}}\) (6) if (\(\mathbf{P}==\varnothing\)) \(\mathbf{W_{indoor}}\).push_back(\(\mathbf{w}\)); (8) continue; (9) end if \(\mathbf{w_{target}}\leftarrow\varnothing\) (11) while (\((\mathbf{w_{target}}=\varnothing\)) && (\(\mathbf{w_{target}}!=\mathbf{w}\))) (12) // Obtain pixels located around \(\mathbf{P}\) with an angle of less than 90 degrees with \(\mathbf{e}\) from \(\mathbf{G}\) (13) \(\mathbf{P_{temp}}=\text{getForwardPixel}(\mathbf{G},\mathbf{e},\mathbf{P})\); (14) \(\mathbf{e}=\text{getForwardDirection}\) (\(\mathbf{P},\mathbf{P_{temp}}\)); // Get the forward direction from \(\mathbf{P}\) to \(\mathbf{P_{temp}}\) (15) \(\mathbf{P}\leftarrow\mathbf{P_{temp}}\); (16) \(w_{target}=\text{searchWallSegment}\) (\(\mathbf{P},\mathbf{r_{w}}\)); // Search for wall segments around \(\mathbf{P}\) within a radius of \(\mathbf{r_{w}}\) (17) endwhile (18) \(\mathbf{T_{boundary}}\).push_back ([\(\mathbf{w}\), \(\mathbf{w_{target}}\)]); (19) endfor (20) for each \(\mathbf{w}\in\mathbf{W_{indoor}}\) (21) \(\mathbf{c}=\text{getCiling}\) (\(\mathbf{w}\), \(\mathbf{C}\)); // Get the ceiling associated with the wall segment (22) \(\mathbf{P_{indoor}}=\text{getEndPixel}\) (\(\mathbf{w}\)); // Get the endpoint of the wall (23) // Get the wall segment that is closest to the \(\mathbf{P_{indoor}}\) and has the same or adjacent ceiling as \(\mathbf{w}\). (24) \(\mathbf{w_{target}}=\text{getWallSegments}\) (\(\mathbf{r_{c}}\), \(\mathbf{P_{indoor}}\), \(\mathbf{c}\), \(\mathbf{w}\), \(\mathbf{W_{all}}\)); (25) \(\mathbf{T_{boundary}}\).push_back ([\(\mathbf{w}\), \(\mathbf{w_{target}}\)]); (26) endfor
```  
**Algorithm 1** Wall segment topology analysis  
After obtaining the topological relationships between the disjoint wall segments, we determine whether the wall segments in the \(\mathbf{T_{boundary}}\) are parallel to each other based on the angle threshold \(\theta_{b}\). For non-parallel wall segments, three potential connection schemes are given, i.e., intersecting, orthogonal and directly connected, as shown in Figure 5(a). For parallel wall segments, if the distance between the wall segments is less than the distance threshold \(d\), the wall segments are combined; if the distance between the wall segments is greater than the distance threshold \(d\), two potential connection schemes are given, i.e., orthogonal and directly connected., as shown in Figure 5(b). Figure 6 divides the local XOY plane into different cells by real and potential wall segments. These cells can be given different labels according to their location: indoor \"\(l_{int}\)\" and outdoor \"\(l_{ext}\)\". The connection scheme is finally determined by the common edge between the indoor and outdoor cells. The labeling process of the cells can be solved similar to an energy minimization problem [41].