|
23 | 23 |
|
24 | 24 | #include <geode/geosciences/explicit/mixin/core/fault_blocks.hpp> |
25 | 25 |
|
| 26 | +#include <geode/basic/detail/count_range_elements.hpp> |
26 | 27 | #include <geode/basic/identifier_builder.hpp> |
27 | 28 | #include <geode/basic/pimpl_impl.hpp> |
28 | 29 | #include <geode/basic/range.hpp> |
@@ -58,6 +59,12 @@ namespace geode |
58 | 59 | return impl_->nb_components(); |
59 | 60 | } |
60 | 61 |
|
| 62 | + template < index_t dimension > |
| 63 | + index_t FaultBlocks< dimension >::nb_active_fault_blocks() const |
| 64 | + { |
| 65 | + return detail::count_range_elements( active_fault_blocks() ); |
| 66 | + } |
| 67 | + |
61 | 68 | template < index_t dimension > |
62 | 69 | bool FaultBlocks< dimension >::has_fault_block( const uuid& id ) const |
63 | 70 | { |
@@ -93,16 +100,23 @@ namespace geode |
93 | 100 | } |
94 | 101 |
|
95 | 102 | template < index_t dimension > |
96 | | - typename FaultBlocks< dimension >::FaultBlockRange |
97 | | - FaultBlocks< dimension >::fault_blocks() const |
| 103 | + auto FaultBlocks< dimension >::fault_blocks() const -> FaultBlockRange |
98 | 104 | { |
99 | 105 | return { *this }; |
100 | 106 | } |
101 | 107 |
|
102 | 108 | template < index_t dimension > |
103 | | - typename FaultBlocks< dimension >::ModifiableFaultBlockRange |
104 | | - FaultBlocks< dimension >::modifiable_fault_blocks( |
105 | | - FaultBlocksBuilderKey /*unused*/ ) |
| 109 | + auto FaultBlocks< dimension >::active_fault_blocks() const |
| 110 | + -> FaultBlockRange |
| 111 | + { |
| 112 | + FaultBlockRange range{ *this }; |
| 113 | + range.set_active_only(); |
| 114 | + return range; |
| 115 | + } |
| 116 | + |
| 117 | + template < index_t dimension > |
| 118 | + auto FaultBlocks< dimension >::modifiable_fault_blocks( |
| 119 | + FaultBlocksBuilderKey /*unused*/ ) -> ModifiableFaultBlockRange |
106 | 120 | { |
107 | 121 | return { *this }; |
108 | 122 | } |
@@ -156,6 +170,31 @@ namespace geode |
156 | 170 | { |
157 | 171 | return *this->current()->second; |
158 | 172 | } |
| 173 | + |
| 174 | + void set_active_only() |
| 175 | + { |
| 176 | + active_only_ = true; |
| 177 | + next_fault_block(); |
| 178 | + } |
| 179 | + |
| 180 | + void next() |
| 181 | + { |
| 182 | + this->operator++(); |
| 183 | + next_fault_block(); |
| 184 | + } |
| 185 | + |
| 186 | + private: |
| 187 | + void next_fault_block() |
| 188 | + { |
| 189 | + while( this->operator!=( *this ) |
| 190 | + && ( active_only_ && !fault_block().is_active() ) ) |
| 191 | + { |
| 192 | + this->operator++(); |
| 193 | + } |
| 194 | + } |
| 195 | + |
| 196 | + private: |
| 197 | + bool active_only_{ false }; |
159 | 198 | }; |
160 | 199 |
|
161 | 200 | template < index_t dimension > |
@@ -187,10 +226,16 @@ namespace geode |
187 | 226 | return impl_->operator!=( *impl_ ); |
188 | 227 | } |
189 | 228 |
|
| 229 | + template < index_t dimension > |
| 230 | + void FaultBlocks< dimension >::FaultBlockRangeBase::set_active_only() |
| 231 | + { |
| 232 | + impl_->set_active_only(); |
| 233 | + } |
| 234 | + |
190 | 235 | template < index_t dimension > |
191 | 236 | void FaultBlocks< dimension >::FaultBlockRangeBase::operator++() |
192 | 237 | { |
193 | | - return impl_->operator++(); |
| 238 | + return impl_->next(); |
194 | 239 | } |
195 | 240 |
|
196 | 241 | template < index_t dimension > |
|
0 commit comments