@@ -118,7 +118,7 @@ namespace geode
118118 " on HorizonsStack will be empty: top and bottom "
119119 " horizons have not been computed, or stack is empty." );
120120 }
121- return { *this };
121+ return { *this , RANGEORDER ::bottom_to_top };
122122 }
123123
124124 template < index_t dimension >
@@ -128,11 +128,39 @@ namespace geode
128128 if ( !impl_->top_horizon () || !impl_->bottom_horizon () )
129129 {
130130 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 "
132160 " on HorizonsStack will be empty: top and bottom "
133161 " horizons have not been computed, or stack is empty" );
134162 }
135- return { *this };
163+ return { *this , RANGEORDER ::top_to_bottom };
136164 }
137165
138166 template < index_t dimension >
@@ -206,12 +234,21 @@ namespace geode
206234 class HorizonsStack < dimension >::HorizonOrderedRange::Impl
207235 {
208236 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 )
210239 {
211240 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 )
213243 {
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+ }
215252 }
216253 }
217254
@@ -222,10 +259,23 @@ namespace geode
222259
223260 void operator ++()
224261 {
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 )
226272 {
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+ }
229279 }
230280 iter_ = uuid{};
231281 }
@@ -237,13 +287,14 @@ namespace geode
237287
238288 private:
239289 const HorizonsStack< dimension >& stack_;
290+ RANGEORDER range_order_;
240291 uuid iter_{};
241292 };
242293
243294 template < index_t dimension >
244295 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 )
247298 {
248299 }
249300
@@ -286,12 +337,21 @@ namespace geode
286337 class HorizonsStack < dimension >::StratigraphicUnitOrderedRange::Impl
287338 {
288339 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 )
290342 {
291343 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 )
293346 {
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+ }
295355 }
296356 }
297357
@@ -302,10 +362,25 @@ namespace geode
302362
303363 void operator ++()
304364 {
305- if ( iter_ != stack_. above ( stack_. top_horizon (). value () ). value () )
365+ if ( range_order_ == RANGEORDER ::bottom_to_top )
306366 {
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+ }
309384 }
310385 iter_ = uuid{};
311386 }
@@ -317,13 +392,15 @@ namespace geode
317392
318393 private:
319394 const HorizonsStack< dimension >& stack_;
395+ RANGEORDER range_order_;
320396 uuid iter_{};
321397 };
322398
323399 template < index_t dimension >
324400 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 )
327404 {
328405 }
329406
0 commit comments