This paper proposes a method to analyze the geometry and semantic information of 2D vector floor plans, and reconstruct the corresponding 3D building models automatically. First, the Shape-opening graph (SOG) is introduced to recognize Structural Components (SCs) and describe the relationships between SCs and openings which are architectural components separating spaces. A priority principle algorithm is developed to replace openings with wall equivalent lines for the purpose of later loop searching. Then, we present an odd-even-based edge breaking algorithm to preprocess wall lines in order to search loops directly and exactly. After that, all the interior-space contours, which are in fact rooms or aisles, and exterior boundary contour can be obtained. With the hierarchical component tree presented, the topological relations of the whole building can be obtained. Finally, 3D models can be generated after extruding loops to the wall height and cutting openings from the walls. A drawing with several floor plans can also be reconstructed to multi-floor building after aligning their dimensions. Moreover, the intermediate result after analyzing the 2D floor plan can be the input of other architectural software to generate 3D models.