22 DCHECK_GT(dimension_values.
NumNodes(path), 0);
24 const absl::Span<Interval> cumuls = dimension_values.
MutableCumuls(path);
25 const absl::Span<const Interval> transits = dimension_values.
Transits(path);
26 const int num_nodes = dimension_values.
NumNodes(path);
27 const Interval span = dimension_values.
Span(path);
29 if (!cumuls.back().IntersectWith(cumuls[0] + span))
return false;
30 if (!cumuls[0].IntersectWith(cumuls.back() - span))
return false;
32 Interval cumul = cumuls[0];
33 for (
int t = 0; t < num_nodes - 1; ++t) {
34 cumul.Add(transits[t]);
35 if (!cumul.IntersectWith(cumuls[t + 1]))
return false;
36 cumuls[t + 1] = cumul;
40 cumul = cumuls.back() - span;
41 for (
int t = 0; t < num_nodes; ++t) {
42 if (!cumul.IntersectWith(cumuls[t]))
return false;
43 if (cumul == cumuls[t])
break;
45 if (t == num_nodes - 1)
break;
46 cumul.Add(transits[t]);
49 cumul = cumuls.back();
50 for (
int t = num_nodes - 2; t >= 0; --t) {
51 cumul.Subtract(transits[t]);
52 if (!cumul.IntersectWith(cumuls[t]))
return false;
57 cumul = cumuls[0] + span;
58 for (
int t = num_nodes - 1; t >= 0; --t) {
59 if (!cumul.IntersectWith(cumuls[t]))
return false;
60 if (cumul == cumuls[t])
break;
63 cumul.Subtract(transits[t - 1]);