Interactive algorithm for generating accurate as-built plans by building owners

Mass Customization systems in architecture have yet to adequately address the problem of capturing physical context, a fundamental aspect of dealing with building renovation, which has limited their scope of application. Previous research has demonstrated that existing methods of capturing as-built plans of rooms by non-expert users do not produce sufficiently accurate results for digital fabrication. The present paper reports on research into the development of an algorithm for semi-automated survey of convex or non-convex rooms by building owners. The improved workflow is tested by expert and non-expert users in a to-be renovated building and the results are compared with existing methods of survey.


INTRODUCTION
As computational design becomes common in architectural practice, alternate modes of production, such as Mass Customization (MC) (Davis, 1987), rose as viable models for architecture and the building industry (Kolarevic and Duarte, 2019). By reconciling seemingly contradictory goals, personalization and mass production, the mass-customized construction paradigm inflates new life into the century old idea of industrialized architecture (Kieran and Timberlake, 2003). Underpinning these efforts is the notion that building owners want houses customized to their needs. In fact, MC allows distribution of control between the actors in the construction process, shifting part of the production and design control to the building owner as late in the process as possible.
This paper is part of an ongoing research with the purpose of developing a disassemble-able and mass customizable construction system of partition walls for building renovation by building owners. This design-to-production system will generate drawings for fabrication, instructions for assembly, and cost estimation. Therefore, it is necessary to develop the construction system, the generative process for digital design and fabrication and a graphical user interface for building owners to interact. We have developed a partition wall construction system (Brandão, Paio and Antunes, 2018). The current paper reports on a part of the development of the interface for the parametric design system. The interface must allow a generic user to manipulate the parametric model and generate solutions for the intended space. To generate a design solution for building renovation, the shape of the space boundaries needs to be input to the design system. In previous research (Brandao et al., 2016), the definition of the boundaries was circumvented by requiring the user to input dimensions of the wall to be designed, height, width and length. This process is not ideal, as it makes assumptions on the boundary conditions: that the wall will span two existing walls and will go from the floor up to the ceiling; that the angles of the wall to the existing walls are close to perpendicular; that the levelness of the floor, walls and ceiling is within a specified tolerance. Also, as the number of generated walls increases, the complexity of the interfaces of the walls with the space boundaries grows, therefore complicating the planning process for the building owner. Ideally, the building owner should be able to survey the space to be partitioned, input this to the model and design the partition wall.
There has been a significant development in automatic methods of generating as-built BIM (AB-BIM), some of which has focused on data collected with mobile phones. Nonetheless, these examples are still limited to small objects or require cloud backends for point-cloud processing (Pătrăucean et al., 2015). Alternatively, several existing applications approach the problem of generating as-built floor plans using semi-automated methods involving user interaction, phone sensors and camera. The generated parametric 2D models are an approximation and require the user to introduce wall lengths into the model on a second step. In a previous study (Brandao and Paio, 2019), we have shown that the resultant plans are only sufficiently accurate if the room plan is an ortho-polygon, which is frequently not the case with old buildings in historic neighbourhoods. In these instances, the results are always indeterminate as there is no way to control the internal angles directly, by inputting angular dimensions, or indirectly by using diagonals. Furthermore, users and experts have some difficulties in understanding application's workflows. Nonetheless, these methods require simple inputs from the users which makes them an appealing option for mass customizable construction systems for non-experts. So, is there a way to improve these semi-automated methods to make them accurate for any non-convex simple polygon? Archi-tects and other building industry experts have long been doing manual surveys and dealing with imprecision in the design and construction stages in building renovation. The hypothesis is that their processes can be captured in a digital workflow that users can execute in their contexts with enough accuracy for digital fabrication (Figure 1). ). This workflow is a part of a larger framework that implements the masscustomization construction system of partition walls for building renovation, reframing AEC stakeholders' roles. Requiring a survey stage for designing and a survey stage for digital fabrication (Figure 2).

METHODS
To overcome the challenges mentioned above, a design inclusive research methodology was adopted (Horvath, 2007), since the focus here is not algorithmic efficiency but the usability of the workflow in practice and the accuracy of the outcomes. The adopted research methodology encompassed the following stages: (1) A review of manual methods of survey used IN design and construction, the reasoning involved in defining the necessary triangulations and circumventing the clutter in these spaces; (2) Evaluation of the adaptability of existing algorithms of triangulation of simple polygons to determine their adaptability to an interactive survey workflow performed by non-expert users; (3) Development of the algorithm based on the findings of the previous steps; (4) Usability testing (Molich and Dumas, 2008) of the proposed workflow and algorithm in practice by non-expert users and expert users; (5) Comparing the user generated plans with Terrestrial Laser Scans of the selected spaces.

AS-BUILT SURVEYS IN PRACTICE
Manual as-built surveys are used in building renovation mostly on the project stage by architects but also on the construction phase for offsite fabrication of building components by carpenters, window installers, etc. The analysis was based on several handdrawn surveys by practicing architects with experience in building renovation, including the first author, and interviews regarding their reasoning for selecting diagonals.
We observed several strategies involved in determining if diagonals are needed and which ones to take: (1) Take all possible diagonals, (2) Try to infer parallelism and non-orthogonality by observation of visual cues such as parallel lines in tiles, (3) Fan triangulation (4) Sketch, measure and draw onsite with the computer. The experts that use the first strategy claimed this was meant to avoid repeated visits to the site. They stated that site measurement is an error prone process and taking more measurements would reduce the error. When back at the office, they try to find the diagonal that minimizes nonorthogonality based on the assumption that buildings are mostly orthogonal. The second strategy can be used in conjunction with the others as a trigger to determine if diagonals are needed. If a deviation in distances between two apparently parallel walls above a certain threshold is verified, at least two internal angles are not orthogonal, and diagonals are required. While it is theoretically possible to use this strategy to deduce which room corners might be non-orthogonal, we haven't found any experts that use it in that way. We observed some experts using fan triangulation, the third strategy, in rooms with more than 4 sides. The fourth strategy has several similarities with the workflow used by non-expert mobile applications. Experts that use this strategy first sketch the plan, next measure all sides of the room, then using a laptop they draw a polyline with all measured sides. If the polyline closes, the room is orthogonal and no further steps are needed, else, they take diagonal measurements. The decision on which diagonals to take is highly contextual, influenced by the previously referred site observation and rules of thumb such as longer measurements reduce the angular errors caused by measurement imprecision. Experts using this strategy then engage in a process of elimination taking diagonals until the polygon is closed.
Strategy 1 is simple to implement algorithmically but quickly becomes tedious in practice as the number of room sides increases. Furthermore, to fully define an n-sided non-orthogonal polygon only n-3 diagonals are needed. Also, room clutter, columns or other construction elements might prevent some diagonals to be taken. This prevents the use of linear algorithms, such as fan triangulation or ear clipping (ElGindy, Everett and Toussaint, 1993). Thus, strategy 3 is not always possible to implement in practice. Strategy 2 is highly subjective, dependent on user measuring and observation skills. Strategy 4 is the most promising one and could be adapted to existing application workflows. Using strategy 4, the researchers explored room survey tactics in practice. A particularly promising procedure was to measure the longest diagonals first, a sort of divide and conquer algorithm. As rooms tend to be mostly orthogonal, the longest diagonal would be a quick way of reducing the search of non-orthogonal angles by eliminating parts of the polygonal chain. A possible approach would be to recursively subdivide the polygon, similarly to the monotone polygon triangulation algorithm, but the existence of some inaccessible corners makes this an ineffective strategy. In fact, most polygon triangulation algorithms are developed with the aim of dividing the polygon in non-intersecting triangles which is an unwarranted limitation in this instance as the purpose is to close the polygon.
It should be expected that the measurements taken on the field to deviate from the real dimensions of the room. Likely, this variation is random and dependent on a number of factors, including, but not limited to: user measuring skills, distance to the corners, spatial perception, existence of obstacles, wall finishes (colour and reflectance), selected measuring tool. Thus, any survey strategy that seeks to reduce the space to a polygon will be an approximation which might cause fitting errors if building components are prefabricated based on it. A simple solution is to replicate the building design and construction workflow, introducing a first survey stage of the plan for design and a second survey stage of the sections for production.

ALGORITHMICS
Based on the previous described observations and reasoning we developed an algorithm that takes the following inputs from the user: (1) a closed polyline P with similar topology to the surveyed space; (2) the length of each side of the room; (3) requested diagonals. The algorithm works under the hypothesis that the user is capable of understanding the overall topology of the room and differentiating a convex angle from a concave one. What the user cannot do is to accurately directly measure these angles. Thus, the provided polygon is an approximation or a sketch of the actual room geometry. This logic follows closely the architect's manual surveying method. Consequently, the algorithm does not allow: a convex angle to turn into a concave one; that a side length is zero or negative; or that the sum of any two consecutive edges is equal to or smaller than their diagonal. The objective is to redraw the closed polyline P by scaling each side of the supplied topology by the user provided dimension. If the polygon is closed within tolerance, the provided polygon's angles are correct, else diagonals are needed. When a user provides a topology that already displays nonorthogonal angles is safe to assume that the user is aware that some angles are non-orthogonal. It is also safe to assume that the provided non-ortho angle is not accurate, since the user does not have tools to measure non-ortho angles on site, unless the polygon is closed within tolerance. Thus, the algorithm requests valid diagonals of the user provided polygon in the following order: (1) diagonals P n − 1 to P n + 1 of non-orthogonal corners P n with ∠ < 180°,ordered by angular dimension in ascending order; (2) the longest diagonals. With each user provided diagonal the algorithm attempts to close the polygon using the following processes: • The provided diagonal from P i to P j closes one or both of the polygonal chains, ij or ji. • The provided diagonal forms one of the following triangles: a triangle with two consecutive edges of the polygon, a triangle with a diagonal and a polygon edge, a diagonal with two other diagonals.
We reorder the diagonals to be requested in the following ways: • If a to be requested diagonal does not contribute to triangulate more corners, we remove it from the processing list. • If a 101 pattern is found (Figure 3), a nontriangulated corner followed and preceded by triangulated corners, one diagonal that closes the 0 corner (non-triangulated corner) is requested next. The 101 Pattern can also reuse diagonals that have been previously provided by the user but did not contribute to triangulate any corner. If a 101 pattern is found, let k be the index of the center of the pattern in P , search for a diagonal that goes from P k − n to P k +m. k −n must be either a fixed corner or a nonfixed corner that immediately follows a fixed corner in the CW direction, conversely k + m must fit the same condition in the CCW direction. If the diagonal has already been provided, use it, else request it next.
No further diagonals are needed if there are three or two angles to triangulate, whatever their location in the polygon, we name these situations 000 Pattern and 00 Pattern. If a 000 Pattern is found, there are only two solutions for the internal angle of the middle corner. As we assume the user provided topology to be correct in terms of left or right turns in the corners, we just maintain the observed turn (Figure 4). Let the three non-fixed corners found in the polygonal chain be P i, P j and P n, the polygon can be closed by finding the correct intersection of the polygonal chain from P i to P j with the polygonal chain from P n to P j. If a 00 Pattern is found, let i be the index of the first undefined corner and j the index of the second one, both angles can be determined by rotating the ij polygonal chain to meet the ji chain. In both instances, these functions close the polygon.
This algorithm was implemented in C# and tested and deployed as a grasshopper plugin for testing.

USABILITY TESTING
To test the validity of the developed algorithm and workflow in practice we conducted usability testing in two rooms in two to-be renovated buildings with a group of non-expert and expert users ( Figure 5). The user produced plans were compared to the Terrestrial Laser Scan (TLS) of each respective room. Room 1 is situated in a 4-building complex located in the historic centre of Braga in the North of Portugal. Room 2 is located in one building within the UNESCO protected historic centre of Porto. All buildings are typical XIX townhouses, with stone façades and party walls, wooden floors and roofs, located in a narrow plot. The 4-building complex has 78 rooms, excluding staircases and balconies, 71% of which have more than 4 sides and 81% of the rooms have at least one internal angle that is +-2 degrees than 90 or 270 degrees. In the Porto building all rooms are above the 2degree threshold albeit by a small margin, but only 3 out of 11 have more than 4 sides. Both rooms were selected for the challenges they place to survey, namely: higher geometric complexity, clutter and challenging wall finishes. In Room 1 all internal angles are non-orthogonal by over +-5 degrees and is representative of the typical situations found in the first group of buildings while Room 2 should be a limit case that might impose some challenges to our algorithmic and workflow approach.
The TLS data was obtained in two separate campaigns performed with a FARO FOCUS S120 station, a Leica GPS 1200 GNSS station and a Leica 1203 TCRP total station. The first campaign comprised the 4 buildings interiors, backyards, street and backyard façades. The survey took 3 days and produced a point-cloud composed of 258 scans grouped in 23 clusters. The second campaign comprised the building interiors and neighbouring streets. The survey took 1 day and produced a point-cloud composed of 113 scans grouped in 6 clusters. A typical interior scan took 2 minutes to complete while an exterior one took 8 minutes. The surveys of Room 1 and 2 were completed with 3 and 8 scans respectively. The point clouds were aligned in SCENE. Horizontal sections of the rooms, at the heights of 50cm and 150cm of the floor, were exported in DXF format. The sections were used to draw 2D plans for comparison with the user designed plans.

Usability testing protocol
A group of 5 non-expert users and 5 expert users surveyed Room 1 and 3 non-experts and 6 expert users surveyed Room 2, in line with usability testing for an iterative development process (Molich and Dumas, 2008). We strived for an equally distributed sample of female and male users and experts of several age groups. The age of participants ranged from 16 to 68 years old. There were 5 female and 6 male ex-perts, and 5 male and 4 female users. All the participants were asked to complete the following tasks: (1) Draw the room plan on paper, (2) Watch a presentation with best measuring practices, (3) Draw the room plan with an application then measure the room sides, (4) Watch a different presentation with best measuring practices, (5) Measure the room and input the side dimensions to our algorithm, (6) Measure the request diagonals. The provided distance meter was a Leica D2, which has sum, subtraction and max/min measurement functions. A brief explanation of the functions was provided to all users and experts before the start of the experiment.

PERFORMANCE EVALUATION
User and expert results are summarized in Table 1. The standard deviation (SD) was computed in comparison to the horizontal section of the TLS point cloud at the height of 1,50m in both rooms. With a few exceptions, mainly to circumvent obstacles, most users took the measurements around this height. In fact, in both rooms the walls are tilted from the base to the top in some instances up to 3 cm. The SD values shown in Table 1 are computed with the measurement taken in the second round of measurements, which were provided by the participants onsite to the algorithm to calculate the needed diagonals. All users and experts were able to sketch a plan of the room by hand, except for User1 in Room 2, while most had difficulties understanding the workflows of the mobile application, as we previously reported. The users requested assistance while the experts were able to overcome their difficulties. User1 in Room2 was only able to complete the sketch of the room, using the provided application camera workflow, after having been provided with explanation that the workflow involved pointing the camera at the room corners and clicking an on-screen button to add the corner. After that point, the user completed the plan without any further input and was able to say how many sides the room had but was still not able to draw the room plan.
As can be seen in table 2, users improved signif-

Figure 6
Comparison of non-expert user and expert user plans with a simplified horizontal section of the reference terrestrial laser scan point cloud of Room 1 Table 1 Summary of users and experts' profiles and respective standard deviation (SD) of measurements Table 2 Global and per round measurement accuracy in wall lengths and diagonals in both rooms icantly from the first round of room measurements to the second one. Expert measurements do also improve, albeit by a smaller margin. The only exception to this trend was Expert 2 in Room 1 which displayed shaking anxiety causing tremors on the right arm during the second measurement round. Diagonal measurements were significantly better for non-expert users in both instances. We attribute this to the use of the laser distance meter feature of max/min measurement. While most non-expert users choose to use the feature only a few experts did.
To determine the viability of using the user produced plans for planning the subdivision of the space and the production of partitions walls with digital fabrication, a possible subdivision of Room 1 was considered and applied to each of the user's plans. The space is divided in three spaces. A corridor that connects the interior door to the exterior door and serves a room with an en suite bathroom. To design the subdivision the following rules where used: (1) divide the space with a wall parallel to the exiting wall with an offset of 1.42m; and, (2) divide the larger space with a wall parallel to the interior partition wall with an offset of 1,8m. The first rule places the wall between the interior window and door on one side and next to the exterior door on the other. The latter rule creates a bathroom for a bathtub, with 1,80x0,8m standard dimensions, a toilet, a wash basin and a bidet. Onsite, the parallelism of the last wall should ideally be maintained, because of the bathtub, while the corridor wall might rotate. Table 3 presents the fitting of the generated walls to the TLS plan. Most of the walls would fit onsite within the tolerance +/-3cm of our construction system.

DISCUSSION AND CONCLUSION
The present article reports on research carried out to develop an algorithm for semi-automated survey of convex or non-convex rooms by building owners. Measuring angular dimensions directly in practice is difficult. Experienced surveyors circumvent this problem by using triangulations between the room internal corners, subdividing the room polygonal shape into triangles. This problem is similar to the classical art gallery problem (Berg, 2008), albeit with a significant difference, the actual geometry of the polygon is undefined a priori, consequently triangulations are a means to define the polygon, i.e. close it. The initial inputs are a topologically accurate closed polygon, with the correct number of sides, and the lengths of the sides. We present an algorithm that seeks to close the polygon by wisely requesting the user to input diagonal dimensions sequentially. Starting in a user selected corner, the algorithm prompts the user to select one of the suggested but valid diagonals to measure. The provided measurement is then used to fix related vertices of the polygon, with the goal of achieving polygonal chain closure. This is an iterative process, until the polygon is closed within a specified tolerance.
Our workflow accuracy is dependent on user measurement precision. User testing results indicate that no particular experience is needed other than adequate instructions on measurement protocol to achieve sufficient geometrical accuracy for the design stage in non-orthogonal rooms using our algorithm. Usability testing demonstrated this is a valid approach in practice and that all users were able to produce a plan which is significantly similar to the existing room. Nonetheless, Room2 results indicate Table 3 Fitting of the walls generated over the user and expert plans to the TLS plan. In bold the walls that fit the tolerance of our previously developed digitally fabricated construction system of partition walls.
that when small angular differences to orthogonality are present the impact of measurement imprecision can make our approach less effective than existing applications methods in terms of overall angular standard deviation. This is a result of our deterministic approach for finding the internal angles of each corner using triangulations. The advantage is that given a set of measurements, angle turns, and user provided diagonals, our algorithm always produces the same polygon internal angles, while existing methods outcomes are dependent on the order of the introduction of side dimensions. This aspect of the performance of the algorithm can be improved by increasing the closing tolerance or using the second survey stage for fabrication. The space subdivision experiment shows that improvements are still needed for user produced as-built plans to have an adequate precision to be used as a basis for digital fabrication.
The presented algorithm can be easily integrated in more traditional contexts by architects or other building professionals as a low-key solution to assist the building survey stage for building renovation. Reducing the need for repeated visits to the site for measurement checking, allowing the plan design stage to take place onsite.
This algorithm demonstrates a possible way of generating as built plans parametrically to integrate in mass-customization workflows for building renovation with simple inputs from users. It is not as precise as TLS systems but can be cost effective alternative to increase accuracy in as-built surveys.
Future work will focus on implementing the workflow into a functional application in which users may survey, plan and generate partition walls for specific building renovation contexts. Furthermore, we will investigate the application of the surveying workflow to the section of the space at wall position after the wall is planned.

ACKNOLEDGEMENTS
This work is supported by an ISTA merit scholarship granted for the development of the first author PhD project and by national funds through Fundação para a Ciência e a Tecnologia (FCT) with reference UID/-Multi/04466/2019.