| 229 | } |
| 230 | |
| 231 | void BSpline::reduceSupport(std::vector<double> lb, std::vector<double> ub, bool doRegularizeKnotVectors) |
| 232 | { |
| 233 | if (lb.size() != numVariables || ub.size() != numVariables) |
| 234 | throw Exception("BSpline::reduceSupport: Inconsistent vector sizes!"); |
| 235 | |
| 236 | std::vector<double> sl = basis.getSupportLowerBound(); |
| 237 | std::vector<double> su = basis.getSupportUpperBound(); |
| 238 | |
| 239 | for (unsigned int dim = 0; dim < numVariables; dim++) |
| 240 | { |
| 241 | // Check if new domain is empty |
| 242 | if (ub.at(dim) <= lb.at(dim) || lb.at(dim) >= su.at(dim) || ub.at(dim) <= sl.at(dim)) |
| 243 | throw Exception("BSpline::reduceSupport: Cannot reduce B-spline domain to empty set!"); |
| 244 | |
| 245 | // Check if new domain is a strict subset |
| 246 | if (su.at(dim) < ub.at(dim) || sl.at(dim) > lb.at(dim)) |
| 247 | throw Exception("BSpline::reduceSupport: Cannot expand B-spline domain!"); |
| 248 | |
| 249 | // Tightest possible |
| 250 | sl.at(dim) = lb.at(dim); |
| 251 | su.at(dim) = ub.at(dim); |
| 252 | } |
| 253 | |
| 254 | if (doRegularizeKnotVectors) |
| 255 | { |
| 256 | regularizeKnotVectors(sl, su); |
| 257 | } |
| 258 | |
| 259 | // Remove knots and control points that are unsupported with the new bounds |
| 260 | if (!removeUnsupportedBasisFunctions(sl, su)) |
| 261 | { |
| 262 | throw Exception("BSpline::reduceSupport: Failed to remove unsupported basis functions!"); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | void BSpline::globalKnotRefinement() |
| 267 | { |