Solving issue #984: Crash on opening raw

This commit is contained in:
natureh 2011-09-14 00:41:18 +02:00
parent 3f921ea255
commit b9fb664670
2 changed files with 8 additions and 9 deletions

View File

@ -76,10 +76,10 @@ namespace rtengine {
double const increment = 1./hashSize;
double milestone = 0.;
for (unsigned int i=0; i<(hashSize+1); i++) {
for (unsigned int i=0; i<(hashSize+1);) {
while(poly_x[polyIter] <= milestone) ++polyIter;
hash[i] = polyIter-1;
milestone += increment;
milestone = (++i)*increment;
}
hash[hashSize+1] = poly_x.size()-1;

View File

@ -290,11 +290,9 @@ void FlatCurve::CtrlPoints_set () {
}
}
// adding an final horizontal line if necessary
if (!periodic && sc_x[--j] != 1.) {
poly_x.push_back(1.);
poly_y.push_back(sc_y[j]);
}
// adding the final horizontal segment, always (see under)
poly_x.push_back(3.0); // 3.0 is a hack for optimization purpose of the getVal method (the last value has to be beyond the normal range)
poly_y.push_back(sc_y[j-1]);
/*
// Checking the values
@ -335,8 +333,9 @@ double FlatCurve::getVal (double t) {
k_lo = k;
}
double h = poly_x[k_hi] - poly_x[k_lo];
return poly_y[k_lo] + (t - poly_x[k_lo]) * ( poly_y[k_hi] - poly_y[k_lo] ) / h;
double dx = poly_x[k_hi] - poly_x[k_lo];
double dy = poly_y[k_hi] - poly_y[k_lo];
return poly_y[k_lo] + (t - poly_x[k_lo]) * dy / dx;
break;
}
/*case Parametric : {