xmsinterp
1.0
|
Implementation of InterpIdw class. More...
Classes | |
class | InterpThread |
Threading class to compute idw interpolation in parallel. More... | |
Public Member Functions | |
InterpIdwImpl () | |
Creates an InterpIdw class. | |
virtual void | SetPtsTris (BSHP< VecPt3d > a_pts, BSHP< VecInt > a_tris) override |
Sets the points that will be used to do the interpolation. More... | |
void | SetScalars (const float *a_scalar, size_t a_n) override |
Sets the scalar values that will be used to do the interpolation. More... | |
void | SetScalars (BSHP< VecFlt > a_scalar) override |
Sets the scalar values that will be used to do the interpolation. More... | |
virtual void | SetPts (BSHP< VecPt3d > a_pts, bool a_2d) override |
Sets the points that will be used to do the interpolation. More... | |
virtual float | InterpToPt (const Pt3d &a_pt) override |
Interpolates to the location specified by a_pt and returns the value. More... | |
virtual void | InterpToPts (const VecPt3d &a_pts, VecFlt &a_scalars) override |
Interpolates to an array of points and fills in an array of scalars. This method will run in parallel using multiple threads. More... | |
virtual void | SetPtActivity (DynBitset &a_activity) override |
Sets the activity on the point being used to interpolate. More... | |
virtual void | SetTriActivity (DynBitset &) override |
Sets triangle activity. Ignored by IDW. | |
virtual const BSHP< VecPt3d > | GetPts () const override |
Returns shared pointer to points vector. More... | |
virtual const BSHP< VecInt > | GetTris () const override |
Returns shared pointer to triangles vector. More... | |
virtual const BSHP< VecFlt > | GetScalars () const override |
Returns shared pointer to scalars vector. More... | |
virtual DynBitset | GetPtActivity () const override |
Returns bitset of point activity. More... | |
virtual DynBitset | GetTriActivity () const override |
Returns empty bitset. No triangles used for idw. More... | |
virtual void | SetTrunc (double a_sMax, double a_sMin) override |
Set the truncation values for the interpolation and turn on truncation. More... | |
virtual bool | GetTruncateInterpolatedValues () const override |
get the option to truncate interpolated values More... | |
virtual double | GetTruncMin () const override |
get minimum truncation value More... | |
virtual double | GetTruncMax () const override |
get the maximum truncation value More... | |
virtual double | GetPower () const override |
get the idw power (1/d or 1/d^2 or 1/d^3) More... | |
virtual int | GetSearchOptsNumNearestPts () const override |
get the search options number of nearest points More... | |
virtual bool | GetSearchOptsUseQuadrantSearch () const override |
get the search options option to do a quadrant or octant search More... | |
virtual WeightEnum | GetWeightCalcMethod () const override |
get the weight calculation method More... | |
virtual NodalFuncEnum | GetNodalFunctionType () const override |
get the type of nodal function (constant, gradient plane, quadratic) More... | |
virtual int | GetNodalFunctionNumNearestPts () const override |
get the nodal function number of nearest points More... | |
virtual bool | GetNodalFunctionUseQuadrantSearch () const override |
get the nodal function option to use a quadrant search More... | |
virtual void | SetSaveWeights (bool a_) override |
sets a flag to save the weights computed by the interpolation More... | |
virtual void | InterpWeights (const Pt3d &a_pt, VecInt &a_idx, VecDbl &a_wt) const override |
Given a location and an array of points the weights associated with array of points are calculated. More... | |
virtual void | SetMultiThreading (bool a_) override |
sets a flag to use (or not) multi-threading when interpolating More... | |
virtual std::string | ToString () const override |
Write the internals to a string. More... | |
void | SetPower (double a_power) override |
Sets the exponent for the interpolation. By default the class does inverse distance squared weighting but the exponent can be changed to any value. More... | |
void | RecalcNodalFunc () |
Recalculates the nodal function. This happens when the scalars change. | |
void | SetSearchOpts (int a_nNearestPoints, bool a_quad_oct_Search) override |
Sets the search options for how to find the nearest points to the interpolation point. The number of nearest points can be specified as well as whether to find the nearest points in each quadrant or octant. More... | |
float | InterpToPt (const Pt3d &a_pt, int a_idx) const |
overload to interpolate to the location specified by a_pt. The a_idx variable is used if the interpolation weights are being saved for later processing by the calling program. More... | |
void | SetObserver (BSHP< Observer > a_prog) override |
Set the observer class so that feedback on the interpolation process can be received. More... | |
void | ValFromWeights (VecDbl &a_w, VecInt &a_nPts, float &a_val, int a_ptIdx, const Pt3d &a_pt) const |
Given a vector of weights, the interpolated value a_val is computed at the point a_pt. More... | |
void | SetWeightCalcMethod (InterpIdw::WeightEnum a_) override |
Sets the method for calculating the weights. The classic just uses 1/distance^exponent. The modified method uses another formulation based on the distance of the furtherest location from the interpolation pt. More... | |
void | SetNodalFunction (NodalFuncEnum a_, int a_nNearest, bool a_quad_oct, BSHP< Observer > a_p) override |
Sets the type of nodal function as well as options for computing nodal functions. More... | |
void | CreateNodalFunctionPtr (NodalFuncEnum a_, int a_nNearest, bool a_quad_oct, BSHP< Observer > a_p) |
Creates the Nodal function class. More... | |
double | ScalarFromNodalFunc (int a_ptIdx, const Pt3d &a_loc) const |
Returns a scalar value based on the nodal function. When nodal functions are used then the scalar value used at each point depends on the location of the you are interpolating to. More... | |
Public Member Functions inherited from xms::InterpIdw | |
virtual | ~InterpIdw () |
Destructor. | |
Public Attributes | |
bool | m_2d |
bool | m_quadOctSearch |
flag for performing quadrant(2d) or octant (3d) searching for nearest ps | |
bool | m_modifiedShepardWeights |
flag for calculating weights using a the modified shepard's approach | |
int | m_nNearestPts |
double | m_power |
BSHP< GmPtSearch > | m_ptSearch |
Class used to find nearest points. | |
BSHP< VecPt3d > | m_pts |
Points used to interpolate. | |
BSHP< VecInt > | m_tris |
triangles ignored by idw | |
BSHP< VecFlt > | m_scalarFrom |
Scalars at the points used to interpolate. | |
BSHP< NodalFunc > | m_nodalFunc |
Nodal function (constant, gradient plane, quadratic) | |
BSHP< Observer > | m_prog |
Observer that reports status of interpolation process. | |
bool | m_saveWeights |
flag for saving the interpolation weights | |
VecInt2d | m_ptIdx |
pt indexes for saving weights | |
VecDbl2d | m_weights |
calculated weights for saving weights | |
bool | m_trunc |
flag to indicate if truncation is on | |
double | m_truncMax |
Maximum truncation value. All interpolated values will be <=. | |
double | m_truncMin |
Minimum truncation value. All interpolated values will be >=. | |
bool | m_multiThread |
flag to indicate if multithreading should be used when interpolating | |
std::string | m_idString |
identification for comparison with other Interp classes | |
Additional Inherited Members | |
Public Types inherited from xms::InterpIdw | |
enum | WeightEnum { CLASSIC, MODIFIED } |
Weight calculation method enumeration. | |
enum | NodalFuncEnum { CONSTANT, GRAD_PLANE, QUADRATIC } |
Nodal fuction type enumeration. | |
Static Public Member Functions inherited from xms::InterpIdw | |
static BSHP< InterpIdw > | New () |
Creates an InterpIdw class. More... | |
Protected Member Functions inherited from xms::InterpIdw | |
InterpIdw () | |
Constructor. | |
Implementation of InterpIdw class.
Inverse distance weighted interpolation class.
Definition at line 47 of file InterpIdw.cpp.
void xms::InterpIdwImpl::CreateNodalFunctionPtr | ( | NodalFuncEnum | a_, |
int | a_nNearest, | ||
bool | a_quad_oct, | ||
BSHP< Observer > | a_p | ||
) |
Creates the Nodal function class.
a_ | Type of nodal function: gradient plane, quadratic |
a_nNearest | Number of nearest points to use when calculating nodal functions. |
a_quad_oct | flag to turn on/off quadrant or octant searching for nearest number of points. |
a_p | Observer for reporting progress of nodal function calculations. |
Definition at line 716 of file InterpIdw.cpp.
References m_2d, m_modifiedShepardWeights, m_nodalFunc, m_power, m_pts, m_ptSearch, m_scalarFrom, and xms::NodalFunc::New().
Referenced by SetNodalFunction(), InterpIdwUnitTests::testErrors(), and InterpIdwUnitTests::testErrors2().
|
inlineoverridevirtual |
get the nodal function number of nearest points
Definition at line 143 of file InterpIdw.cpp.
References m_nodalFunc.
|
inlineoverridevirtual |
get the type of nodal function (constant, gradient plane, quadratic)
Definition at line 135 of file InterpIdw.cpp.
References m_nodalFunc.
|
inlineoverridevirtual |
get the nodal function option to use a quadrant search
Definition at line 151 of file InterpIdw.cpp.
References m_nodalFunc.
|
inlineoverridevirtual |
get the idw power (1/d or 1/d^2 or 1/d^3)
Definition at line 118 of file InterpIdw.cpp.
References m_power.
|
overridevirtual |
Returns bitset of point activity.
Definition at line 537 of file InterpIdw.cpp.
References m_ptSearch.
Returns shared pointer to points vector.
Definition at line 513 of file InterpIdw.cpp.
References m_pts.
Returns shared pointer to scalars vector.
Definition at line 529 of file InterpIdw.cpp.
References m_scalarFrom.
|
inlineoverridevirtual |
get the search options number of nearest points
Definition at line 121 of file InterpIdw.cpp.
References m_nNearestPts.
|
inlineoverridevirtual |
get the search options option to do a quadrant or octant search
Definition at line 124 of file InterpIdw.cpp.
References m_quadOctSearch.
|
overridevirtual |
Returns empty bitset. No triangles used for idw.
Definition at line 547 of file InterpIdw.cpp.
Returns shared pointer to triangles vector.
Definition at line 521 of file InterpIdw.cpp.
References m_tris.
|
inlineoverridevirtual |
get the option to truncate interpolated values
Definition at line 109 of file InterpIdw.cpp.
References m_trunc.
|
inlineoverridevirtual |
get the maximum truncation value
Definition at line 115 of file InterpIdw.cpp.
References m_truncMax.
|
inlineoverridevirtual |
get minimum truncation value
Definition at line 112 of file InterpIdw.cpp.
References m_truncMin.
|
inlineoverridevirtual |
get the weight calculation method
Definition at line 127 of file InterpIdw.cpp.
References m_modifiedShepardWeights.
|
overridevirtual |
Interpolates to the location specified by a_pt and returns the value.
a_pt | The location of the interpolation point. |
Definition at line 427 of file InterpIdw.cpp.
References XM_NONE.
Referenced by InterpToPts(), InterpIdwUnitTests::testErrors2(), and xms::InterpIdwImpl::InterpThread::Worker().
float xms::InterpIdwImpl::InterpToPt | ( | const Pt3d & | a_pt, |
int | a_idx | ||
) | const |
overload to interpolate to the location specified by a_pt. The a_idx variable is used if the interpolation weights are being saved for later processing by the calling program.
a_pt | The location of the interpolation point. |
a_idx | Index related to the location a_pt used to later process interpolation weights related to a_pt. |
Definition at line 440 of file InterpIdw.cpp.
References InterpWeights(), m_saveWeights, m_scalarFrom, m_trunc, m_truncMax, m_truncMin, ValFromWeights(), and XM_ENSURE_FALSE.
Interpolates to an array of points and fills in an array of scalars. This method will run in parallel using multiple threads.
a_pts | Array of points to interpolate to. |
a_scalars | Array of scalar values that is filled in by this method. a_scalars will be the same size as a_pts and each value corresponds to the interpolated value at the respective location in the a_pts array. |
Definition at line 472 of file InterpIdw.cpp.
References InterpToPt(), m_multiThread, m_prog, m_saveWeights, and xms::ThreadMgr::New().
|
overridevirtual |
Given a location and an array of points the weights associated with array of points are calculated.
a_pt | Location of the interpolation point |
a_nPts | Vector of indices indicating the location in the m_pts vector of the nearest points to a_pt. |
a_w | Vector weights associated with the nearest points to a_pt. |
Definition at line 571 of file InterpIdw.cpp.
References xms::inDistanceSquared(), xms::inIdwWeights(), m_2d, m_modifiedShepardWeights, m_nNearestPts, m_power, m_pts, m_ptSearch, and m_quadOctSearch.
Referenced by InterpToPt().
double xms::InterpIdwImpl::ScalarFromNodalFunc | ( | int | a_ptIdx, |
const Pt3d & | a_loc | ||
) | const |
Returns a scalar value based on the nodal function. When nodal functions are used then the scalar value used at each point depends on the location of the you are interpolating to.
a_ptIdx | The index of one of the points being used to interpolate (index into m_pts). |
a_loc | The location of the point we are interpolating to. |
Definition at line 733 of file InterpIdw.cpp.
References m_nodalFunc, and m_scalarFrom.
Referenced by ValFromWeights().
|
inlineoverridevirtual |
sets a flag to use (or not) multi-threading when interpolating
[in] | a_ | flag: true will use multi-threading and false will not. The default setting for the class is to use multi-threading. |
Definition at line 169 of file InterpIdw.cpp.
References m_multiThread.
|
override |
Sets the type of nodal function as well as options for computing nodal functions.
a_ | The nodal function methodology: constant (0), gradient plane (1), quadratic (2). |
a_nNearest | The nearest number of points to use when calculating the nodal functions. |
a_quad_oct | Find the nearest number of points in each quadrant (2d) or octant (3d) when computing nodal functions. |
a_p | Progress bar to give user feedback. |
Definition at line 696 of file InterpIdw.cpp.
References CreateNodalFunctionPtr(), xms::inAllScalarsEqual(), m_pts, m_ptSearch, m_scalarFrom, XM_ENSURE_TRUE, and XM_ENSURE_TRUE_VOID_NO_ASSERT.
Referenced by InterpIdwUnitTests::testErrors(), and InterpIdwUnitTests::testErrors2().
Set the observer class so that feedback on the interpolation process can be received.
a_prog | The observer. |
Definition at line 180 of file InterpIdw.cpp.
References m_prog.
|
override |
Sets the exponent for the interpolation. By default the class does inverse distance squared weighting but the exponent can be changed to any value.
a_power | the exponent used to compute the point weights 1 / distance^a_power |
Definition at line 393 of file InterpIdw.cpp.
References m_nodalFunc, m_power, and XM_ENSURE_TRUE.
|
overridevirtual |
Sets the activity on the point being used to interpolate.
a_activity | Bitset of point activity. |
Definition at line 505 of file InterpIdw.cpp.
References m_ptSearch.
Sets the points that will be used to do the interpolation.
a_pts | array of the point locations |
a_2d | indicates if the class will do 2D or 3D interpolation |
Definition at line 350 of file InterpIdw.cpp.
References m_2d, m_pts, m_ptSearch, and m_scalarFrom.
Referenced by SetPtsTris(), InterpIdwUnitTests::testErrors(), and InterpIdwUnitTests::testErrors2().
|
overridevirtual |
Sets the points that will be used to do the interpolation.
a_pts | array of the point locations |
a_tris | triangles |
Definition at line 340 of file InterpIdw.cpp.
|
inlineoverridevirtual |
sets a flag to save the weights computed by the interpolation
[in] | a_ | flag: true will save weights and false will not |
Definition at line 161 of file InterpIdw.cpp.
References m_saveWeights.
|
override |
Sets the scalar values that will be used to do the interpolation.
a_scalar | array of scalar values |
a_n | size of the a_scalar array |
Definition at line 371 of file InterpIdw.cpp.
References m_scalarFrom, and RecalcNodalFunc().
Referenced by InterpIdwUnitTests::testErrors(), and InterpIdwUnitTests::testErrors2().
Sets the scalar values that will be used to do the interpolation.
a_scalar | array of scalar values |
Definition at line 381 of file InterpIdw.cpp.
References m_scalarFrom, and RecalcNodalFunc().
|
override |
Sets the search options for how to find the nearest points to the interpolation point. The number of nearest points can be specified as well as whether to find the nearest points in each quadrant or octant.
a_nNearestPoints | the number of nearest points to the interpolation point. These points are used to do the interpolation. |
a_quad_oct_Search | specifies if the search criterion should find the nearest points in each quadrant (2d) or octant (3d) |
Definition at line 417 of file InterpIdw.cpp.
References m_nNearestPts, and m_quadOctSearch.
|
overridevirtual |
Set the truncation values for the interpolation and turn on truncation.
a_sMax | The maximum value for truncation. |
a_sMin | The minimum value for truncation. |
Definition at line 557 of file InterpIdw.cpp.
References m_trunc, m_truncMax, and m_truncMin.
|
override |
Sets the method for calculating the weights. The classic just uses 1/distance^exponent. The modified method uses another formulation based on the distance of the furtherest location from the interpolation pt.
a_ | The weight calculation method. |
Definition at line 676 of file InterpIdw.cpp.
References m_modifiedShepardWeights.
|
overridevirtual |
Write the internals to a string.
Definition at line 605 of file InterpIdw.cpp.
References m_2d, m_modifiedShepardWeights, m_multiThread, m_nNearestPts, m_nodalFunc, m_power, m_ptIdx, m_pts, m_ptSearch, m_quadOctSearch, m_saveWeights, m_scalarFrom, m_tris, m_weights, and VecToStream().
void xms::InterpIdwImpl::ValFromWeights | ( | VecDbl & | a_w, |
VecInt & | a_nPts, | ||
float & | a_val, | ||
int | a_ptIdx, | ||
const Pt3d & | a_pt | ||
) | const |
Given a vector of weights, the interpolated value a_val is computed at the point a_pt.
a_w | Vector of weights associated with locations indicated in the a_nPts vector. |
a_nPts | Vector of indices into the m_pts vector for the nearest points to a_pt. |
a_val | Interpolated value calculated in this method. |
a_ptIdx | Index associated with a_pt that is used to later process interpolation weights. |
a_pt | The location of the interpolation point. |
Definition at line 652 of file InterpIdw.cpp.
References m_saveWeights, and ScalarFromNodalFunc().
Referenced by InterpToPt().
bool xms::InterpIdwImpl::m_2d |
flag for computing distances in xy instead of xyz
Definition at line 198 of file InterpIdw.cpp.
Referenced by CreateNodalFunctionPtr(), InterpWeights(), SetPts(), and ToString().
int xms::InterpIdwImpl::m_nNearestPts |
number of nearest points to use in the interpolation
Definition at line 203 of file InterpIdw.cpp.
Referenced by GetSearchOptsNumNearestPts(), InterpWeights(), SetSearchOpts(), and ToString().
double xms::InterpIdwImpl::m_power |
The exponent to be used with the inverse of the distance. By default this is 2 so we use 1/d^2. The exponent can be changed so that the calculation is 1/d or 1/d^3...
Definition at line 207 of file InterpIdw.cpp.
Referenced by CreateNodalFunctionPtr(), GetPower(), InterpWeights(), SetPower(), and ToString().