In recent years, terrestrial laser scanners have been introduced to enable efficient as-built modeling. Since heating, ventilating, and air conditioning facilities often include many pipes and ducts packed into small spaces, it is difficult to manually determine optimal scanner placements that can capture their surfaces with high accuracy and quality and with few occlusions. To solve this problem, we propose an optimal scan planning method based on mathematical programming that uses a coarse 3D model obtained from structure-from-motion as prior knowledge of the objects to be scanned. Integer programming enables us to identify optimal scanner locations that maximize scan coverage while satisfying general scan constraints. The proposed method can outperform experienced operators in terms of scan coverage and modeling accuracy. In addition, we extend our original method to address additional objectives and constraints encountered in practice, such as ensuring full scan coverage, minimizing travel time, and guaranteeing point cloud registration. We also confirm our methods effectiveness via computer simulations.