From 67d446a376bb3df399619b36ca3b2eeeadfc623c Mon Sep 17 00:00:00 2001 From: Francois Bonneau Date: Mon, 18 Aug 2025 17:11:20 +0200 Subject: [PATCH 1/4] feat(BoundingBox): add n_volume computation --- include/geode/geometry/bounding_box.hpp | 2 ++ src/geode/geometry/bounding_box.cpp | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/geode/geometry/bounding_box.hpp b/include/geode/geometry/bounding_box.hpp index a3e4fb564..651ffee14 100644 --- a/include/geode/geometry/bounding_box.hpp +++ b/include/geode/geometry/bounding_box.hpp @@ -115,6 +115,8 @@ namespace geode [[nodiscard]] std::tuple< local_index_t, double > largest_length() const; + [[nodiscard]] double n_volume() const; + [[nodiscard]] std::string string() const; private: diff --git a/src/geode/geometry/bounding_box.cpp b/src/geode/geometry/bounding_box.cpp index eba8fe22e..ba544725b 100644 --- a/src/geode/geometry/bounding_box.cpp +++ b/src/geode/geometry/bounding_box.cpp @@ -345,8 +345,8 @@ namespace geode // Test direction of triangle normal. const auto triangle_normal = edges[0].cross( edges[1] ); if( !bbox_projection( triangle_normal ) - .contains( Point1D{ { triangle_normal.dot( - Vector3D{ vertices[0].get() } ) } } ) ) + .contains( Point1D{ { triangle_normal.dot( + Vector3D{ vertices[0].get() } ) } } ) ) { return false; } @@ -508,6 +508,17 @@ namespace geode return -inner_distance; } + template < index_t dimension > + double BoundingBox< dimension >::n_volume() const + { + double volume{ 1.0 }; + for( const auto c : geode::LRange{ dimension } ) + { + volume *= ( max_.value( c ) - min_.value( c ) ); + } + return volume; + } + template < index_t dimension > std::string BoundingBox< dimension >::string() const { From b52dbce1f2d804de6099bc02f0ccfabe6419ab98 Mon Sep 17 00:00:00 2001 From: francoisbonneau <24669995+francoisbonneau@users.noreply.github.com> Date: Mon, 18 Aug 2025 15:14:02 +0000 Subject: [PATCH 2/4] Apply prepare changes --- src/geode/geometry/bounding_box.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/geode/geometry/bounding_box.cpp b/src/geode/geometry/bounding_box.cpp index ba544725b..b32f74824 100644 --- a/src/geode/geometry/bounding_box.cpp +++ b/src/geode/geometry/bounding_box.cpp @@ -345,8 +345,8 @@ namespace geode // Test direction of triangle normal. const auto triangle_normal = edges[0].cross( edges[1] ); if( !bbox_projection( triangle_normal ) - .contains( Point1D{ { triangle_normal.dot( - Vector3D{ vertices[0].get() } ) } } ) ) + .contains( Point1D{ { triangle_normal.dot( + Vector3D{ vertices[0].get() } ) } } ) ) { return false; } From 32ebfb5ce2c9f54897324609afbd1bde52c7c965 Mon Sep 17 00:00:00 2001 From: Francois Bonneau Date: Tue, 19 Aug 2025 16:57:21 +0200 Subject: [PATCH 3/4] pa suggestion --- src/geode/geometry/bounding_box.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/geode/geometry/bounding_box.cpp b/src/geode/geometry/bounding_box.cpp index b32f74824..b8293e687 100644 --- a/src/geode/geometry/bounding_box.cpp +++ b/src/geode/geometry/bounding_box.cpp @@ -512,9 +512,10 @@ namespace geode double BoundingBox< dimension >::n_volume() const { double volume{ 1.0 }; + const auto box_extent = diagonal(); for( const auto c : geode::LRange{ dimension } ) { - volume *= ( max_.value( c ) - min_.value( c ) ); + volume *= ( box_extent.value(c) ); } return volume; } From 4aa8ab42b4c6660c79176c0f1b6be26d44de6bb9 Mon Sep 17 00:00:00 2001 From: francoisbonneau <24669995+francoisbonneau@users.noreply.github.com> Date: Tue, 19 Aug 2025 14:57:56 +0000 Subject: [PATCH 4/4] Apply prepare changes --- src/geode/geometry/bounding_box.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geode/geometry/bounding_box.cpp b/src/geode/geometry/bounding_box.cpp index b8293e687..85ed00985 100644 --- a/src/geode/geometry/bounding_box.cpp +++ b/src/geode/geometry/bounding_box.cpp @@ -515,7 +515,7 @@ namespace geode const auto box_extent = diagonal(); for( const auto c : geode::LRange{ dimension } ) { - volume *= ( box_extent.value(c) ); + volume *= ( box_extent.value( c ) ); } return volume; }