MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / Search

Method Search

ngstd/bspline.cpp:377–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375 }
376
377 std::tuple<int,int,bool> BSpline2D :: Search(double x, double y) const
378 {
379 int ix=0, iy=0;
380 if(!extrapolate)
381 {
382 if(x<px[0] || x>px.Last())
383 throw Exception("x out of range: " + ToString(x) + "\t[" + ToString(px[0]) + "," + ToString(px.Last())+"]");
384
385 if(y<py[0] || y>py.Last())
386 throw Exception("y out of range: " + ToString(y) + "\t[" + ToString(py[0]) + "," + ToString(py.Last())+"]");
387 }
388
389 if(x<px[0]) ix = -1;
390 else if(x>px.Last()) ix = px.Size();
391 else
392 for(auto i : Range(px.Size()-1))
393 if(px[i]<=x && x<=px[i+1]) {
394 ix = i;
395 break;
396 }
397
398 if(y<py[0]) iy = -1;
399 else if(y>py.Last()) iy = py.Size();
400 else
401 for(auto i : Range(py.Size()-1))
402 if(py[i]<=y && y<=py[i+1]) {
403 iy = i;
404 break;
405 }
406
407 bool outside = min(ix,iy)==-1 || iy==py.Size() || ix==px.Size();
408 return {ix, iy, outside};
409 }
410
411 double BSpline2D :: Evaluate (double x, double y) const
412 {

Callers

nothing calls this directly

Calls 3

ToStringFunction · 0.85
RangeFunction · 0.50
SizeMethod · 0.45

Tested by

no test coverage detected