15 #include "subdivSegment.h"
26 binary_search(
double val,
const double *array,
int bot,
int top) {
30 int mid = (bot + top)/2;
32 if (array[mid] < val) {
33 return binary_search(val, array, mid+1, top);
35 return binary_search(val, array, bot, mid-1);
50 _cuts.erase(_cuts.begin(), _cuts.end());
52 for (c = 1; c < _num_cuts+1; c++) {
53 double val = (double)c * ct / (
double)(_num_cuts+1) + _cint[_f];
54 int i = binary_search(val, _cint, _f, _t);
55 if (i != last && i < _t) {
61 while ((
int)_cuts.size() < _num_cuts) {
66 for (c = 0; c < (int)_cuts.size(); c++) {
67 if (mc == -1 || _cuts[c] - last > mv) {
79 _cuts.insert(_cuts.begin() + mc, (_cuts[mc] + _f) / 2);
81 _cuts.insert(_cuts.begin() + mc, (_cuts[mc] + _cuts[mc-1]) / 2);
double get_score() const
Returns the net score of the segment.
void cut()
Applies _num_cuts cuts to the segment.