Openings such as windows and doors are essential components of architectural wall surfaces. It is still a challenge to reconstruct them robustly from unstructured 3D point clouds because of occlusions, noises and non-uniformly distributed points. Current research primarily focuses on meliorating the robustness of detection and pays little attention to the geometric correctness. To improve the reconstruction quality, assumptions on the opening layout are usually applied as rules to support the reconstruction algorithm. The commonly used assumptions, such as the strict grid and symmetry pattern, however, are not suitable in many cases. In this paper, we propose a novel approach, named an inference machine, to identify and use flexible rules in wall opening modelling. Our method first detects and models openings through a data-driven method and then refines the opening boundaries by global and flexible rules. The key is to identify the global flexible rules from the detected openings, composed by various combinations of alignments. As our method is oblivious of the type of architectural layout, it can be applied to both interior wall surfaces and exterior building facades. We demonstrate the flexibility of our approach in both outdoor and indoor scenes with a variety of opening layouts. The qualitative and quantitative evaluation results indicate the potential of the approach to be a general method in opening detection and modelling. However, this data-driven method suffers from the existence of occlusions and non-planar wall surfaces.