From ebf5be5d96bb0f6858a776f1d3102d4dd81db3b5 Mon Sep 17 00:00:00 2001 From: Linoal <1321932+linoal@users.noreply.github.com> Date: Wed, 8 Jan 2025 22:53:19 +0900 Subject: [PATCH] =?UTF-8?q?=E9=81=B8=E6=8A=9E=E7=AF=84=E5=9B=B2=E3=81=AE?= =?UTF-8?q?=E5=A2=83=E7=95=8C=E4=B8=8A=E3=81=AB=E3=81=82=E3=82=8B=E5=9C=B0?= =?UTF-8?q?=E7=89=A9=E3=81=8C=E6=B6=88=E3=81=88=E3=82=8B=E3=81=93=E3=81=A8?= =?UTF-8?q?=E3=81=8C=E3=81=82=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/polygon_mesh/mesh_extractor.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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); }