@@ -118,7 +118,7 @@ namespace geode
118
118
" on HorizonsStack will be empty: top and bottom "
119
119
" horizons have not been computed, or stack is empty." );
120
120
}
121
- return { *this };
121
+ return { *this , RANGEORDER::bottom_to_top };
122
122
}
123
123
124
124
template < index_t dimension >
@@ -128,11 +128,39 @@ namespace geode
128
128
if ( !impl_->top_horizon () || !impl_->bottom_horizon () )
129
129
{
130
130
Logger::warn (
131
- " [HorizonsStack::bottom_to_top_horizons] Iteration "
131
+ " [HorizonsStack::bottom_to_top_units] Iteration "
132
+ " on HorizonsStack will be empty: top and bottom "
133
+ " horizons have not been computed, or stack is empty" );
134
+ }
135
+ return { *this , RANGEORDER::bottom_to_top };
136
+ }
137
+
138
+ template < index_t dimension >
139
+ auto HorizonsStack< dimension >::top_to_bottom_horizons() const
140
+ -> HorizonOrderedRange
141
+ {
142
+ if ( !impl_->top_horizon () || !impl_->bottom_horizon () )
143
+ {
144
+ Logger::warn (
145
+ " [HorizonsStack::top_to_bottom_horizons] Iteration "
146
+ " on HorizonsStack will be empty: top and bottom "
147
+ " horizons have not been computed, or stack is empty." );
148
+ }
149
+ return { *this , RANGEORDER::top_to_bottom };
150
+ }
151
+
152
+ template < index_t dimension >
153
+ auto HorizonsStack< dimension >::top_to_bottom_units() const
154
+ -> StratigraphicUnitOrderedRange
155
+ {
156
+ if ( !impl_->top_horizon () || !impl_->bottom_horizon () )
157
+ {
158
+ Logger::warn (
159
+ " [HorizonsStack::top_to_bottom_units] Iteration "
132
160
" on HorizonsStack will be empty: top and bottom "
133
161
" horizons have not been computed, or stack is empty" );
134
162
}
135
- return { *this };
163
+ return { *this , RANGEORDER::top_to_bottom };
136
164
}
137
165
138
166
template < index_t dimension >
@@ -206,12 +234,21 @@ namespace geode
206
234
class HorizonsStack < dimension >::HorizonOrderedRange::Impl
207
235
{
208
236
public:
209
- Impl ( const HorizonsStack< dimension >& stack ) : stack_( stack )
237
+ Impl ( const HorizonsStack< dimension >& stack, RANGEORDER range_order )
238
+ : stack_( stack ), range_order_( range_order )
210
239
{
211
240
auto bot_horizon = stack.bottom_horizon ();
212
- if ( bot_horizon && stack.top_horizon () )
241
+ auto top_horizon = stack.top_horizon ();
242
+ if ( bot_horizon && top_horizon )
213
243
{
214
- iter_ = bot_horizon.value ();
244
+ if ( range_order_ == RANGEORDER::bottom_to_top )
245
+ {
246
+ iter_ = bot_horizon.value ();
247
+ }
248
+ else if ( range_order_ == RANGEORDER::top_to_bottom )
249
+ {
250
+ iter_ = top_horizon.value ();
251
+ }
215
252
}
216
253
}
217
254
@@ -222,10 +259,23 @@ namespace geode
222
259
223
260
void operator ++()
224
261
{
225
- if ( iter_ != stack_.top_horizon ().value () )
262
+ if ( range_order_ == RANGEORDER::bottom_to_top )
263
+ {
264
+ if ( iter_ != stack_.top_horizon ().value () )
265
+ {
266
+ iter_ =
267
+ stack_.above ( stack_.above ( iter_ ).value () ).value ();
268
+ return ;
269
+ }
270
+ }
271
+ else if ( range_order_ == RANGEORDER::top_to_bottom )
226
272
{
227
- iter_ = stack_.above ( stack_.above ( iter_ ).value () ).value ();
228
- return ;
273
+ if ( iter_ != stack_.bottom_horizon ().value () )
274
+ {
275
+ iter_ =
276
+ stack_.under ( stack_.under ( iter_ ).value () ).value ();
277
+ return ;
278
+ }
229
279
}
230
280
iter_ = uuid{};
231
281
}
@@ -237,13 +287,14 @@ namespace geode
237
287
238
288
private:
239
289
const HorizonsStack< dimension >& stack_;
290
+ RANGEORDER range_order_;
240
291
uuid iter_{};
241
292
};
242
293
243
294
template < index_t dimension >
244
295
HorizonsStack< dimension >::HorizonOrderedRange::HorizonOrderedRange(
245
- const HorizonsStack& horizons_stack )
246
- : impl_( horizons_stack )
296
+ const HorizonsStack& horizons_stack, RANGEORDER bottom_to_top )
297
+ : impl_( horizons_stack, bottom_to_top )
247
298
{
248
299
}
249
300
@@ -286,12 +337,21 @@ namespace geode
286
337
class HorizonsStack < dimension >::StratigraphicUnitOrderedRange::Impl
287
338
{
288
339
public:
289
- Impl ( const HorizonsStack< dimension >& stack ) : stack_( stack )
340
+ Impl ( const HorizonsStack< dimension >& stack, RANGEORDER range_order )
341
+ : stack_( stack ), range_order_( range_order )
290
342
{
291
343
auto bot_horizon = stack.bottom_horizon ();
292
- if ( bot_horizon && stack.top_horizon () )
344
+ auto top_horizon = stack.top_horizon ();
345
+ if ( bot_horizon && top_horizon )
293
346
{
294
- iter_ = stack.under ( bot_horizon.value () ).value ();
347
+ if ( range_order_ == RANGEORDER::bottom_to_top )
348
+ {
349
+ iter_ = stack.under ( bot_horizon.value () ).value ();
350
+ }
351
+ else if ( range_order_ == RANGEORDER::top_to_bottom )
352
+ {
353
+ iter_ = stack.above ( top_horizon.value () ).value ();
354
+ }
295
355
}
296
356
}
297
357
@@ -302,10 +362,25 @@ namespace geode
302
362
303
363
void operator ++()
304
364
{
305
- if ( iter_ != stack_. above ( stack_. top_horizon (). value () ). value () )
365
+ if ( range_order_ == RANGEORDER::bottom_to_top )
306
366
{
307
- iter_ = stack_.above ( stack_.above ( iter_ ).value () ).value ();
308
- return ;
367
+ if ( iter_
368
+ != stack_.above ( stack_.top_horizon ().value () ).value () )
369
+ {
370
+ iter_ =
371
+ stack_.above ( stack_.above ( iter_ ).value () ).value ();
372
+ return ;
373
+ }
374
+ }
375
+ else if ( range_order_ == RANGEORDER::top_to_bottom )
376
+ {
377
+ if ( iter_
378
+ != stack_.under ( stack_.bottom_horizon ().value () ).value () )
379
+ {
380
+ iter_ =
381
+ stack_.under ( stack_.under ( iter_ ).value () ).value ();
382
+ return ;
383
+ }
309
384
}
310
385
iter_ = uuid{};
311
386
}
@@ -317,13 +392,15 @@ namespace geode
317
392
318
393
private:
319
394
const HorizonsStack< dimension >& stack_;
395
+ RANGEORDER range_order_;
320
396
uuid iter_{};
321
397
};
322
398
323
399
template < index_t dimension >
324
400
HorizonsStack< dimension >::StratigraphicUnitOrderedRange::
325
- StratigraphicUnitOrderedRange ( const HorizonsStack& horizons_stack )
326
- : impl_( horizons_stack )
401
+ StratigraphicUnitOrderedRange (
402
+ const HorizonsStack& horizons_stack, RANGEORDER bottom_to_top )
403
+ : impl_( horizons_stack, bottom_to_top )
327
404
{
328
405
}
329
406
0 commit comments