diff --git a/src/polygon_mesh/mesh_extractor.cpp b/src/polygon_mesh/mesh_extractor.cpp index 83d8e768..01791659 100644 --- a/src/polygon_mesh/mesh_extractor.cpp +++ b/src/polygon_mesh/mesh_extractor.cpp @@ -30,19 +30,36 @@ namespace { if (extent.contains(city_obj)) return false; } - return true; } + /// extentsの幅と奥行きの長さを multiplier 倍にします。 + std::vector extendExtents(const std::vector& src_extents, float multiplier) { + auto result = std::vector(); + + for (const auto& src_extent : src_extents) { + const auto center = src_extent.centerPoint(); + const auto prev_min = src_extent.min; + const auto prev_max = src_extent.max; + auto next_min = center + (prev_min - center) * multiplier; + auto next_max = center + (prev_max - center) * multiplier; + result.emplace_back(next_min, next_max); + } + return result; + } + void extractInner( Model& out_model, const CityModel& city_model, const MeshExtractOptions& options, - const std::vector& extents) { + const std::vector& extents_before_adjust) { if (options.max_lod < options.min_lod) throw std::logic_error("Invalid LOD range."); const auto geo_reference = geometry::GeoReference(options.coordinate_zone_id, options.reference_point, options.unit_scale, options.mesh_axes); + // 範囲の境界上にある地物を取り逃さないように、範囲を少し広げます。 + auto extents = extendExtents(extents_before_adjust, 1.2f); + // rootNode として LODノード を作ります。 for (unsigned lod = options.min_lod; lod <= options.max_lod; lod++) { auto lod_node = Node("LOD" + std::to_string(lod)); @@ -188,7 +205,6 @@ namespace plateau::polygonMesh { const MeshExtractOptions& options, const std::vector& extents) { - extractInner(out_model, city_model, options, extents); }