53 #ifndef vtk_m_worklet_contourtree_augmented_process_contourtree_inc_piecewise_linear_function_h
54 #define vtk_m_worklet_contourtree_augmented_process_contourtree_inc_piecewise_linear_function_h
64 namespace contourtree_augmented
66 namespace process_contourtree_inc
73 inline bool operator()(
const std::pair<T, T>& s1,
const std::pair<T, T>& s2)
const
75 return s1.second > s2.second;
89 auto it = std::find_if_not(
90 samples.begin(),
samples.end(), [sx](std::pair<T, T> s) { return sx > s.first; });
91 samples.insert(it, std::pair<T, T>(sx, sy));
102 auto end = std::find_if_not(
103 samples.begin(),
samples.end(), [px](std::pair<T, T> s) { return px > s.first; });
106 std::cerr <<
"WARNING!" << std::endl;
111 auto begin = end - 1;
112 T t = (px - begin->first) / (end->first - begin->first);
113 return (1 - t) * begin->second + t * end->second;
120 std::vector<std::pair<T, T>> new_samples;
122 auto it2 = other.
samples.begin();
126 if (it1->first < it2->first)
128 new_samples.emplace_back(it1->first, it1->second + other(it1->first));
131 else if (it2->first < it1->first)
133 new_samples.emplace_back(it2->first, it2->second + (*
this)(it2->first));
138 new_samples.emplace_back(it1->first, it1->second + it2->second);
145 new_samples.push_back(*it1);
148 while (it2 != other.
samples.end())
150 new_samples.push_back(*it2);
160 std::vector<std::pair<T, T>> sCopy =
samples;
163 for (
unsigned i = 0; i < n; ++i)
165 res.push_back(sCopy[i].first);
173 std::cout <<
"(" << sample.first <<
", " << sample.second <<
") ";
174 std::cout << std::endl;