A Spatial Reasoning Framework Based on Non-Manifold Topology

Non-Manifold Topology (NMT) has been previously proven to be an appropriate representation of interconnected architectural and spatial structures. This paper further explores the suitability of NMT for spatial reasoning purposes. A literature survey is done to identify the necessary components of a spatial reasoning framework, and an adaptation of such framework based on NMT is presented. This paper also describes the implementation of an NMT-based spatial reasoning framework, its integration into the Topologic software library which the authors develop, as well as the implementation challenges. Finally, a pathfinding study case on an NMT model, which has been generated from a Building Information Modelling (BIM) structure, is presented and analysed.


INTRODUCTION
The concept of architectural space is essential in building design, representation, and reasoning (Ching 2014).It has been argued that before the fabrication models are produced, buildings are typically perceived as a set of interconnected spaces (Curtis 1996).Seen from this perspective, spatial reasoning provides information about the relationship among the spaces, the spatial information attached to every individual space, as well as with the objects and individuals occupying or surrounding the spaces.Such information can be used as feedback to improve the building design, as well as to provide live information to the user of the building e.g. in the presence of a hazardous situation.
Building design and analysis workflows have traditionally used the concept of manifold topology, which centres around the idea of the boundaries of a three-dimensional entity separating the interior from the exterior.In contrast to this, Non-Manifold Topology (NMT) offers a formal and consistent topological framework which allows mixed-dimensional entities and junctions on the boundaries.This, therefore, allows internal subdivisions of a space separated by internal boundaries.As a consequence, the adjacency information among the spaces as well as other entities is explicitly stored in the building model and spatial queries can be conveniently performed.While NMT is commonly considered as defects in current practice, it has been shown that it can better represent the concept of interconnected spaces and support spatial as well as topological queries (Aish and Pratap 2013;Jabi et al. 2017).There have been precedents in the use of NMT for spatial reasoning.For example, spatial reasoning on NMT has been used to perform social sustainability analysis on vernacu-lar courtyard houses and tall buildings (Al-Jokhadar 2018).
Due to the inherent support for spatial queries, it is hypothesised that the use of NMT in spatial reasoning will enhance the current building design and analysis workflows.It is therefore crucial to devise a spatial reasoning framework that is built on top of the concept of NMT.This paper seeks to build a foundation to meet this aim and presents two objectives.Firstly, a review will be conducted on academic papers as well as software libraries on spatial information typically used in the architectural design processes, as well as existing spatial reasoning frameworks and algorithms.Secondly, a spatial reasoning framework based on the concept of NMT will be established from the review and presented with a study case.

NON-MANIFOLD TOPOLOGY
The NMT framework presents a formal and consistent relationship among the multi-dimensional constituent entities.The authors' earlier work (Chatzivasileiadi, Wardhana, et al. 2018) identified eight entities, namely (sorted in descending order based on the dimensional complexity) Cluster, CellComplex, Cell, Shell, Face, Wire, Edge, and Vertex.The hierarchy of these entities is shown in Figure 1.It is possible to navigate from one entity to another with higher or lower level of dimensionality.Boolean operations can be used to modify NMT models, and the resulting model will retain the non-manifold property.
The authors have developed a software library called Topologic on the basis of NMT to facilitate the design and analysis of architectural models (Aish et al. 2018;Jabi et al. 2018).This library is implemented with a multi-layer architecture.The core package, written in C++, contains topological classes and functionalities, including navigation queries.A higher-level layer is written on the .NET platform on top of the core package and it serves as plugins to host applications, including Dynamo (Figure 2) and Grasshopper.These plugins wrap the classes and functionalities in the core package, as well as provide two-way mechanisms to convert an entity between the geometric representations in the host applications and the topological representations in the library.In an earlier publication (Chatzivasileiadi, Lannon, et al. 2018), the authors have presented workflows to use this library in building performance and structural analyses.

LITERATURE REVIEW
In order to design a spatial reasoning framework, a review on existing spatial data models and spatial reasoning frameworks is presented in this paper.Spatial data in this context refer to the located data related to every specific entity (Laurini and Thompson 1992).These data do not only refer to the location and orientation of the entity, but also non-location semantic data, such as the name and intended use of a room, as well as the number of occupants.Each of these data models and spatial reasoning frameworks may have seen considerable development, therefore it is beyond the scope of this paper to present a detailed literature review.

Spatial Data Models
This paper reviews four common data models and file formats from Building Information Modelling (BIM), Computer-Aided Design (CAD), and Geographical Information Systems (GIS), namely the Industry Foundation Classes (IFC) (buildingSMART International Ltd  (Gröger and Plümer 2012).These data models are analysed for their support for three categories of data, namely the semantic attributes that can be attached to a spatial entity; the explicit topological relationships between two connected entities, either directly or indirectly; and the implicit topological relationships between two disjoint entities.

IFC.
The IFC is an open data model which is specifically designed to facilitate interoperability and collaboration between the different teams in a BIM project.It was first conceptualised by a consortium which was initiated by Autodesk in 1994, and it is now maintained by buildingSMART.The IFC schema provides geometric, topological, and applicationspecific attributes.As part of being an integrated federated 3D model, IFC supports domain-specific attributes.These attributes are related to the building controls, plumbing and fire protection, structural elements, structural activities, heating, ventilating, and air-conditioning (HVAC), electrical, architectural, and construction management.
IFC supports explicit topological relationships between two entities of a boundary representation of an object under the IfcTopologicalRepresentation-Item superclass, which immediately consists of Ifc-ConnectedFaceSet, IfcEdge, IfcFace, IfcFaceBound, Ifc-Path, IfcVertex, and IfcLoop.In IFC4, the implicit topological relationships can be categorised into 6, namely Assignment, Association, Connection, Declaration, Decomposition, and Definition.Out of these 6 categories, the Connection and Decomposition relationships are relevant for spatial reasoning.
CityGML.CityGML is the international standard for the 3D representation of an urban model, with support for geometric, topological, and semantic attributes.It has seen applications such as in disaster handling, emergency responses, pathfinding, as well as energy analysis.In terms of semantic attributes, CityGML provides pre-defined object types which are categorised into one of the thematic modules, namely core (whose attributes inherited by other object types), relief, building, bridge, tunnel, transportation, water body, vegetation, city furniture, land use, groups, and generic (used for further extensions).
The topology of the objects is described by the explicit, hierarchical connectivity between the geometric objects.While surfaces need to be planar and 2-manifold, CityGML offers some support for non-manifold topology in the form of Cell Complex.This feature enables modelling of a wall shared by two spaces.Two other yet related spatial relationships are the relativeToTerrain and rela-tiveToWater attributes, which respectively describe the position of an object relative to the ground surface or the water surface.The relativeToTerrain attribute allows five values, namely entirelyAboveTerrain, substantiallyAboveTerrain, substantiallyAbove-AndBelowTerrain, substantiallyBelowTerrain, and en-tirelyBelowTerrain.The relativeToWater attribute has similar values, replacing the keyword Terrain with Wa-terSurface.In addition, it has the temporarilyAbove-AndBelowWaterSurface to represent objects affected by water tides.

GBXML.
GBXML is an XML schema that was designed to support data transfer in a BIM for further analysis.It has seen primary use for energy analysis, therefore the semantic attributes support this application, including variables related to heating, cooling, lighting, and space occupancy.GBXML also provides explicit 3D topological relationship between the geometric entities in the form of a Campus, Building, Space, Surface, PolyLoop, and CartesianPoint.However, there does not seem to be support for implicit relationship among the entities.
X3D. X3D is a standard to represent 3D computer graphics scenes and objects.This file format is a successor of the Virtual Reality Modeling Language (VRML), and provides classes and attributes to support a wide array of application domains, including scientific visualisation, CAD and architecture, GIS, animation, 3D printing and 3D scanning, as well as Augmented/Virtual/Mixed Reality applications.While the classes and attributes provided in the standard are mostly for geometric, topological, and visualization purposes, X3D provides Metadata classes to store custom attributes.Some further mechanisms have been proposed to extend its capabilities to support semantic data exchange.For example, X3D can be paired with the Resource Description Framework (RDF) to provide scene-independent ontology (Pittarello and De Faveri 2006).

Spatial Reasoning Frameworks
Numerous spatial reasoning frameworks have been proposed in the past and used in various applications.This section reviews spatial frameworks widely used in Architecture, as well as in other areas including computer games and Geographical Information Systems (GIS).Identified groups of frameworks include the Region Connection Calculus (RCC) (Randell, Cui, and Cohn 1992), directional reasoning calculus (Frank 1992), space syntax (Hillier et al. 1976  Room Lighting Reasoning.Room lighting information can be used to determine the behaviour of a virtual agent.In stealth computer games, for example, an agent may prefer to move along the shaded areas to reduce her/his visibility and provide protection from the opponents (Smith 2006).
Sound propagation.The purpose of sound propagation simulation is to determine how acoustic waves travel in a virtual environment, thus providing realistic audio experience in Computer Graphics applications.A polygon soup (i.e. a set of unordered polygons) remains commonly used in the latest tech-niques (Raghuvanshi and Snyder 2018).Similar to the lighting information, sound propagation can also be used for reasoning purposes for an agent's decision making (Smith 2006).

A NON-MANIFOLD TOPOLOGY-BASED SPATIAL REASONING FRAMEWORKS
Based on the review presented in the previous section, one disadvantage that is commonly shared by existing representation is the use of 2D representations, either in the form of images or surfaces, although they can be positioned in a 3D environment.It can therefore be argued that there is a lack of representation of space in spatial reasoning mechanisms.
Based on this finding, this research presents a unified NMT-based spatial reasoning framework.The benefit is mutual: not only does this research extend the capability of the NMT framework, but also the capabilities of these spatial reasoning mechanisms will be enhanced by the spatial coverage and hierarchical consistency that NMT offers.
Figure 5 shows an NMT-based spatial reasoning framework.On top of the NMT kernel, the Semantic Knowledge provide a mechanism to attach domainindependent semantic data to a topology, offering flexibility to multiple application domains.The spatial reasoning framework layer uses both the topological entities as well as the spatial knowledge to perform spatial analysis.Finally, the host applications (which, in the case of Topologic, are currently Dynamo and Grasshopper) provide a means for visualisation and interaction purposes.
At the moment, Topologic provides partial support towards this framework, in particular with its Dictionary, Graph (as the generalisation of dual graph), and Pathfinding features.These, along with the implementation challenges will be thoroughly discussed in this section.More features will be implemented and tested as future works.

Dictionary
The Dictionary system allows fully customisable semantic spatial attributes which are attached to the individual topological entities.It is applicationindependent, thus offering flexibility for utilisation in various applications.In this system, each topology is related to a hash map, which is a structure mapping unique keys to the values.Each of the key is a string, whereas currently the values can be an integer, a real number (a floating point), or a string.Support for other types of values, including a pointer to another entity, will be added in the future.A Dictionary can be attached to a topology using Topology.SetDictionary method, and queried from a topology using the Topology.Dictionary property.There is also partial support for Dictionary preservation across multiple operations, which keeps the Dictionaries of constituent topologies survive until the end of a workflow.

Graph
The Graph class in Topologic is implemented as an adjacency list, where in every vertex is mapped to a set of vertices it is connected to.This adjacency list is augmented with another list of edges, which describes the connecting topology between every pair of vertices.The Graph class contains a dual graph construction method from any type of topology, modifiers and queries related to the vertices and the edges, methods to perform pathfinding, and visualisation methods via conversion into the host geometries.
A dual graph can be generated from any kind of topology, taking into account aperture structures, such as windows and doors, in their presence.It should be noted that Topologic offers flexibility for an Aperture to be of any topological type, and can equally be attached to any kind of topology.The construction procedure is detailed in Table 1.It is also possible to get the topology of a dual graph as a cluster, containing a set of edges and vertices.
For pathfinding purposes, Topologic provides three methods, namely Graph.ShortestPath, which is based on the Dijkstra's algorithm (Dijkstra 1959); Graph.Path, which is based on greedy search; and Graph.AllPaths, which exhaustively searches for all possible paths between a pair of vertices, with an optional time-limit.By default, these methods minimises the number of visited vertices.However, it is possible to minimise another criterion by specifying the vertex or edge key in the Dictionary.

Implementation Challenges
Two implementation challenges are identified, and they will be addressed as future work.The first one is related to the preservation of the dictionaries in the entire workflow.This is particularly challenging when the workflow involves Boolean operations, which may introduce new topological entities, and remove parts of the input entities.In these cases, there needs to be an intelligent rule to decide how the dictionaries survive, evolve, or are passed to the new entities.The second challenge is related to adapting the existing spatial framework into the mixeddimensional NMT.A number of frameworks, for example the Space Syntax, were originally designed for a rasterised 2D floor plans.There have been some modified frameworks to deal with 3D structures, for example the 3D isovist algorithm (Suleiman, Joliveau, and Favier 2013) and mixed-dimensional RCC (Izadi, Stock, and Guesgen 2017).However, to the best of the authors' knowledge, the state-of-the-art pathfinding systems either use the topologically 1D dual graph (Boguslawski and Gold 2016), or the topologically 2D navigation mesh (van Toll et al. 2018).A more in-depth review and investigation will be needed in these areas.

STUDY CASE
Topological models have been used to perform pathfinding and navigation in the interior of a building, for example to assist the occupants when finding the way to a different part of the building, and for fire evacuation purposes (Jamali, Abdul Rahman, and Boguslawski 2016).The presented study case shows how to perform pathfinding on an NMT model.Three steps are involved in the workflow.Firstly, a BIM model is converted into a Topologic entity in Dynamo.Secondly, a dual graph is derived from the Topologic entity.Thirdly, pathfinding is performed on the generated dual graph.This workflow runs on Revit 2020, Dynamo 2.3.0 (developmental build) and Topologic 0.8.5, using the Sample Architectural Project BIM model which is packaged with Autodesk Revit (Figure 6(a)).

Converting a BIM Model into a Non-Manifold Topology Model
In this step, the interior room spaces of the house are extracted from the BIM model as Dynamo solids.Topologic identifies these solids and converts them into topological cells.It should be noted that because the walls of the house are also modelled as solids, there are gaps with varying thickness separating these room spaces.Due to these gaps, it is not possible to group the cells into a CellComplex.Instead, they are grouped as a cluster, which is shown (as Dynamo solids) in Figure 6(b).

Deriving a Dual Graph from the NMT Model
This step begins by generating dual graphs from the individual cells.This results in small graphs in which the vertices at the centroids of the cells connected to vertices at the centroids of their respective bounding faces.While in an otherwise CellComplex-based Table 1 Dual graph construction rule model the graph would have just contained a single connected component, in this case, the smaller graphs are disjoint from each other due to the gaps between the cells.Therefore, a face matching procedure needs to be performed.
To match the shared faces of two adjacent cells, the following rule is used: two faces are considered neighbours if and only if: 1.They are parallel (in other words, the angle between their normal vectors should approximately be 0°or 180°within a small tolerance); 2. Their centroids must not coincide each other (so as to prevent zero-length edges), but under a maximum value (with this model, the value of 500 unit is used); and, 3. The perpendicular projection of one of the two faces onto the other one is entirely located within the other face.
Once every pair of neighbouring faces is identified, the vertices at their centroids are connected into edges, and merged with the previously generated small graphs inside the room cells to yield the final graph, as shown in Figure 6(c).Here, the spheres represent the vertices of the final graph, while the black lines correspond to the edges.

Pathfinding on the Dual Graph
Once the dual graph is generated, pathfinding can then be performed between any pair of rooms in the building.Figure 6(d) shows an example of finding a path between two extreme points, from the green sphere to the blue sphere, across the two storeys of the house, passing the white spheres on the bounding faces (walls).This path can then be used to guide a virtual agent which move between the green and blue spheres, for example in an evacuation scenario.

CONCLUSIONS AND FUTURE WORK
The NMT structure possesses a potential for utilisation as the foundation of a spatial reasoning framework.The inherent support for multi-dimensional entities and adjacency queries will be particularly beneficial in this purpose.As part of the implementation of a spatial reasoning framework, the Topologic library provides a Dictionary system as well as the Graph class, which includes pathfinding measures.The identified challenges include retaining the Dictionary system in a workflow involving Boolean oper- ations, as well as adapting existing spatial reasoning frameworks for a multi-dimensional entity.
Other forms of spatial reasoning frameworks will be integrated to Topologic.Further ahead, there is a potential for the creation of a Spatial Query Language (SQL) based on NMT, for example by extending from the SPARQL query language (Prud'hommeaux and Seaborne 2008), to simplify the formulation of spatial queries, as well as to enhance the spatial query capabilities of the framework.The concept of spatial reasoning can be used in other related areas.As an example, for digital fabrication, a rule-based system can be deployed on the conceptual zero-thickness skeleton of a building to intelligently place and trim solid building components, as well as to decide where to or not to deposit materials.Non-manifold cells with no adjacency may require a different way to handle compared to another cell which is heavily connected, and this can be conveniently determined in an NMT model.
Figure 1The class hierarchy of the Non-Manifold Topology entities Figure 2 Topologic running in Dynamo ), dual graph (Boguslawski and Gold 2016), pathfinding(van Toll et al. 2018), room lighting reasoning(Smith  2006), and sound propagation(Raghuvanshi and Snyder 2018).Region ConnectionCalculus.Region Connection Calculus (RCC) provides a formal topological connection between two entities called regions.Its RCC-8 variant describes 8 fundamental relationships, namely Disconnected (DC), Externally Connected (EC), Equal (EQ), Partially Overlapping (PO), Tangential Proper Part (TPP), Tangential Proper Part Inverse (TPPi), Non-Tangential Proper Part (NTPP), and Non-Tangential Proper Part Inverse (NTPPi).These relationships are shown in Figure 3. Directional Reasoning Calculus.Two models have been defined by Frank (1992) regarding directional reasoning in 2D space: the cone-based model and the projection-based model.The first one assumes that, given a point, a direction relation between two arbitrary points on a 2D space can be represented by one of nine directions: East (E), West (W), South (S), North (N), North East (NE), North West (NW), South East (SE), South West (SW), and Identical (O) for the direction of the other point (Nam, S and Kim, I. 2015).The projection-based model produces four directional partitions, e.g.north-west, north-east, south-east and southwest.An example of the two models is shown in Figure 4. Regarding 3D space and in the context of building information modeling, a pointbased approximation, such as the centre of mass, is normally used.However, this rough approximation often results in unexpected results considering the user's intuition (Borrmann and Beetz 2010).A few directional reasoning calculi exist for the 3D space and some examples are the Rectangle Algebra (Balbiani et al. 1999) and the Cardinal Direction Calculus (CDC) (Goyal & Egenhofer 1997; Zhang et al. 2009).
Figure 3 The 8 configurations in Region Connection Calculus Figure 5 A spatial reasoning framework based on Non-Manifold Topology Figure 6 The pathfinding study case.(a) The original Sample Architectural Project BIM model in Revit.(b) The NMT cells, generated from the interior spaces of the BIM model, as shown in Dynamo.(c) The dual graph derived from the NMT model.(d) The shortest path between two vertices at different locations in the building.