From 76bbe65510f07692f89f7ed0d84903c507331307 Mon Sep 17 00:00:00 2001 From: MelchiorSchuh Date: Thu, 4 Sep 2025 14:32:07 +0200 Subject: [PATCH 1/2] fix(HorizonsStack): Modified function "above" to get if a component is generally above another, and added "directly_above" function --- .../core/stratigraphic_relationships.hpp | 3 +++ .../core/stratigraphic_relationships.cpp | 22 ++++++++++++++++++- tests/implicit/test-horizons-stack.cpp | 10 +++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/include/geode/geosciences/implicit/mixin/core/stratigraphic_relationships.hpp b/include/geode/geosciences/implicit/mixin/core/stratigraphic_relationships.hpp index 3f0268b..63cd089 100644 --- a/include/geode/geosciences/implicit/mixin/core/stratigraphic_relationships.hpp +++ b/include/geode/geosciences/implicit/mixin/core/stratigraphic_relationships.hpp @@ -59,6 +59,9 @@ namespace geode [[nodiscard]] bool is_above( const uuid& above, const uuid& under ) const; + [[nodiscard]] bool is_directly_above( + const uuid& above, const uuid& under ) const; + [[nodiscard]] std::optional< uuid > above( const uuid& element ) const; [[nodiscard]] std::optional< uuid > under( const uuid& element ) const; diff --git a/src/geode/geosciences/implicit/mixin/core/stratigraphic_relationships.cpp b/src/geode/geosciences/implicit/mixin/core/stratigraphic_relationships.cpp index c1303e1..f71bd8f 100644 --- a/src/geode/geosciences/implicit/mixin/core/stratigraphic_relationships.cpp +++ b/src/geode/geosciences/implicit/mixin/core/stratigraphic_relationships.cpp @@ -54,7 +54,21 @@ namespace geode initialize_relation_attributes(); } - bool is_above( const uuid& above, const uuid& under ) const + bool is_above( const uuid& above_id, const uuid& under_id ) const + { + auto current = under_id; + while( const auto directly_above = this->above( current ) ) + { + if( directly_above.value() == above_id ) + { + return true; + } + current = directly_above.value(); + } + return false; + } + + bool is_directly_above( const uuid& above, const uuid& under ) const { const auto edge_id = relation_edge( above, under ); if( !edge_id ) @@ -285,6 +299,12 @@ namespace geode return impl_->is_above( above, under ); } + bool StratigraphicRelationships::is_directly_above( + const uuid& above, const uuid& under ) const + { + return impl_->is_directly_above( above, under ); + } + std::optional< uuid > StratigraphicRelationships::above( const uuid& element ) const { diff --git a/tests/implicit/test-horizons-stack.cpp b/tests/implicit/test-horizons-stack.cpp index 3fa7022..d255957 100644 --- a/tests/implicit/test-horizons-stack.cpp +++ b/tests/implicit/test-horizons-stack.cpp @@ -97,6 +97,13 @@ void test_horizons_stack() OPENGEODE_EXCEPTION( horizons_stack.nb_stratigraphic_units() == 5, "[Test] Horizons Stack should have 5 Stratigraphic Units after " "repair." ); + const auto bottom_horizon = horizons_stack.bottom_horizon(); + OPENGEODE_EXCEPTION( + bottom_horizon, "[Test] There should be a bottom horizon" ); + const auto bottom_unit_id = horizons_stack.under( bottom_horizon.value() ); + OPENGEODE_EXCEPTION( bottom_unit_id, + "[Test] There should be a stratigraphic unit under the " + "bottom horizon" ); for( const auto& horizon : horizons_stack.horizons() ) { const auto& horizon_id = horizon.id(); @@ -104,6 +111,9 @@ void test_horizons_stack() "[Test] Horizon should have a unit above." ); OPENGEODE_EXCEPTION( horizons_stack.under( horizon_id ), "[Test] Horizon should have a unit under." ); + OPENGEODE_EXCEPTION( + horizons_stack.is_above( horizon_id, bottom_unit_id.value() ), + "[Test] Horizon should be above the bottom unit." ); } const auto stack_path = absl::StrCat( "test_HorizonStack.", From 3a1af9f891ed4163d7bb9a697cbe8c1c0fd5cdb4 Mon Sep 17 00:00:00 2001 From: MelchiorSchuh <26920036+MelchiorSchuh@users.noreply.github.com> Date: Thu, 4 Sep 2025 12:33:02 +0000 Subject: [PATCH 2/2] Apply prepare changes --- commitlint.config.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 commitlint.config.js diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..3a29484 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,16 @@ +export default { + extends: ["@commitlint/config-angular"], + rules: { + "scope-empty": [2, "never"], + "subject-empty": [2, "never"], + "subject-max-length": [0], + "body-leading-blank": [0], + "footer-leading-blank": [0], + "header-max-length": [0], + "scope-case": [0], + "subject-case": [0], + "subject-full-stop": [0], + "type-case": [0], + "type-empty": [0], + }, +}