In this paper we present algorithms to extract the boundary representation of orthogonal polygons and polyhedra, either manifold or pseudomanifold. The algorithms we develop reconstruct not only the polygons of the boundaries but also the hole-face inclusion relationship. Our algorithms have a simple input so they can be used to convert many different kinds of models to B-Rep. In the 2D case, the input is the set of vertices, and in the 3D case, some small additional information must be supplied for every vertex. All proposed algorithms run in O(n log n) time and use O(n) space, where n is the number of vertices of the input. Moreover, we explain how to use our proposal to extract the boundary from the well-known voxel and octree models as well as from three vertex-based models found in the related literature: the neighbourhood, the EVM, and the weighted vertex list models.