xmsinterp  1.0
xms::InterpIdwImpl Class Reference

Implementation of InterpIdw class. More...

Inheritance diagram for xms::InterpIdwImpl:
xms::InterpIdw xms::InterpBase

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< VecPt3dGetPts () const override
 Returns shared pointer to points vector. More...
 
virtual const BSHP< VecIntGetTris () const override
 Returns shared pointer to triangles vector. More...
 
virtual const BSHP< VecFltGetScalars () 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< VecPt3dm_pts
 Points used to interpolate.
 
BSHP< VecIntm_tris
 triangles ignored by idw
 
BSHP< VecFltm_scalarFrom
 Scalars at the points used to interpolate.
 
BSHP< NodalFuncm_nodalFunc
 Nodal function (constant, gradient plane, quadratic)
 
BSHP< Observerm_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< InterpIdwNew ()
 Creates an InterpIdw class. More...
 
- Protected Member Functions inherited from xms::InterpIdw
 InterpIdw ()
 Constructor.
 

Detailed Description

Implementation of InterpIdw class.

Inverse distance weighted interpolation class.

idw_const.png

Definition at line 47 of file InterpIdw.cpp.

Member Function Documentation

◆ CreateNodalFunctionPtr()

void xms::InterpIdwImpl::CreateNodalFunctionPtr ( NodalFuncEnum  a_,
int  a_nNearest,
bool  a_quad_oct,
BSHP< Observer a_p 
)

Creates the Nodal function class.

Parameters
a_Type of nodal function: gradient plane, quadratic
a_nNearestNumber of nearest points to use when calculating nodal functions.
a_quad_octflag to turn on/off quadrant or octant searching for nearest number of points.
a_pObserver 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().

◆ GetNodalFunctionNumNearestPts()

virtual int xms::InterpIdwImpl::GetNodalFunctionNumNearestPts ( ) const
inlineoverridevirtual

get the nodal function number of nearest points

Returns
the nodal function number of nearest points

Definition at line 143 of file InterpIdw.cpp.

References m_nodalFunc.

◆ GetNodalFunctionType()

virtual NodalFuncEnum xms::InterpIdwImpl::GetNodalFunctionType ( ) const
inlineoverridevirtual

get the type of nodal function (constant, gradient plane, quadratic)

Returns
the type of nodal function

Definition at line 135 of file InterpIdw.cpp.

References m_nodalFunc.

◆ GetNodalFunctionUseQuadrantSearch()

virtual bool xms::InterpIdwImpl::GetNodalFunctionUseQuadrantSearch ( ) const
inlineoverridevirtual

get the nodal function option to use a quadrant search

Returns
the nodal function option to use a quadrant search

Definition at line 151 of file InterpIdw.cpp.

References m_nodalFunc.

◆ GetPower()

virtual double xms::InterpIdwImpl::GetPower ( ) const
inlineoverridevirtual

get the idw power (1/d or 1/d^2 or 1/d^3)

Returns
the power

Definition at line 118 of file InterpIdw.cpp.

References m_power.

◆ GetPtActivity()

DynBitset xms::InterpIdwImpl::GetPtActivity ( ) const
overridevirtual

Returns bitset of point activity.

Returns
Returns bitset of point activity

Definition at line 537 of file InterpIdw.cpp.

References m_ptSearch.

◆ GetPts()

const BSHP< VecPt3d > xms::InterpIdwImpl::GetPts ( ) const
overridevirtual

Returns shared pointer to points vector.

Returns
Shared pointer to points vector.

Definition at line 513 of file InterpIdw.cpp.

References m_pts.

◆ GetScalars()

const BSHP< VecFlt > xms::InterpIdwImpl::GetScalars ( ) const
overridevirtual

Returns shared pointer to scalars vector.

Returns
Shared pointer to scalars vector.

Definition at line 529 of file InterpIdw.cpp.

References m_scalarFrom.

◆ GetSearchOptsNumNearestPts()

virtual int xms::InterpIdwImpl::GetSearchOptsNumNearestPts ( ) const
inlineoverridevirtual

get the search options number of nearest points

Returns
the number of nearest points

Definition at line 121 of file InterpIdw.cpp.

References m_nNearestPts.

◆ GetSearchOptsUseQuadrantSearch()

virtual bool xms::InterpIdwImpl::GetSearchOptsUseQuadrantSearch ( ) const
inlineoverridevirtual

get the search options option to do a quadrant or octant search

Returns
the option to do a quadrant or octant search

Definition at line 124 of file InterpIdw.cpp.

References m_quadOctSearch.

◆ GetTriActivity()

DynBitset xms::InterpIdwImpl::GetTriActivity ( ) const
overridevirtual

Returns empty bitset. No triangles used for idw.

Returns
Returns empty bitset

Definition at line 547 of file InterpIdw.cpp.

◆ GetTris()

const BSHP< VecInt > xms::InterpIdwImpl::GetTris ( ) const
overridevirtual

Returns shared pointer to triangles vector.

Returns
Shared pointer to triangles vector.

Definition at line 521 of file InterpIdw.cpp.

References m_tris.

◆ GetTruncateInterpolatedValues()

virtual bool xms::InterpIdwImpl::GetTruncateInterpolatedValues ( ) const
inlineoverridevirtual

get the option to truncate interpolated values

Returns
the option to truncate interpolated values

Definition at line 109 of file InterpIdw.cpp.

References m_trunc.

◆ GetTruncMax()

virtual double xms::InterpIdwImpl::GetTruncMax ( ) const
inlineoverridevirtual

get the maximum truncation value

Returns
the maximum truncation value

Definition at line 115 of file InterpIdw.cpp.

References m_truncMax.

◆ GetTruncMin()

virtual double xms::InterpIdwImpl::GetTruncMin ( ) const
inlineoverridevirtual

get minimum truncation value

Returns
the minimum truncation value

Definition at line 112 of file InterpIdw.cpp.

References m_truncMin.

◆ GetWeightCalcMethod()

virtual WeightEnum xms::InterpIdwImpl::GetWeightCalcMethod ( ) const
inlineoverridevirtual

get the weight calculation method

Returns
the weight calculation method

Definition at line 127 of file InterpIdw.cpp.

References m_modifiedShepardWeights.

◆ InterpToPt() [1/2]

float xms::InterpIdwImpl::InterpToPt ( const Pt3d a_pt)
overridevirtual

Interpolates to the location specified by a_pt and returns the value.

Parameters
a_ptThe location of the interpolation point.
Returns
The interpolated value.

Definition at line 427 of file InterpIdw.cpp.

References XM_NONE.

Referenced by InterpToPts(), InterpIdwUnitTests::testErrors2(), and xms::InterpIdwImpl::InterpThread::Worker().

◆ InterpToPt() [2/2]

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.

Parameters
a_ptThe location of the interpolation point.
a_idxIndex related to the location a_pt used to later process interpolation weights related to a_pt.
Returns
The interpolated value.

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.

◆ InterpToPts()

void xms::InterpIdwImpl::InterpToPts ( const VecPt3d a_pts,
VecFlt a_scalars 
)
overridevirtual

Interpolates to an array of points and fills in an array of scalars. This method will run in parallel using multiple threads.

Parameters
a_ptsArray of points to interpolate to.
a_scalarsArray 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().

◆ InterpWeights()

void xms::InterpIdwImpl::InterpWeights ( const Pt3d a_pt,
VecInt a_nPts,
VecDbl a_w 
) const
overridevirtual

Given a location and an array of points the weights associated with array of points are calculated.

Parameters
a_ptLocation of the interpolation point
a_nPtsVector of indices indicating the location in the m_pts vector of the nearest points to a_pt.
a_wVector 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().

◆ ScalarFromNodalFunc()

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.

Parameters
a_ptIdxThe index of one of the points being used to interpolate (index into m_pts).
a_locThe location of the point we are interpolating to.
Returns
Scalar value at a_ptIdx adjusted by the nodal function.

Definition at line 733 of file InterpIdw.cpp.

References m_nodalFunc, and m_scalarFrom.

Referenced by ValFromWeights().

◆ SetMultiThreading()

virtual void xms::InterpIdwImpl::SetMultiThreading ( bool  a_)
inlineoverridevirtual

sets a flag to use (or not) multi-threading when interpolating

Parameters
[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.

◆ SetNodalFunction()

void xms::InterpIdwImpl::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.

Parameters
a_The nodal function methodology: constant (0), gradient plane (1), quadratic (2).
a_nNearestThe nearest number of points to use when calculating the nodal functions.
a_quad_octFind the nearest number of points in each quadrant (2d) or octant (3d) when computing nodal functions.
a_pProgress 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().

◆ SetObserver()

void xms::InterpIdwImpl::SetObserver ( BSHP< Observer a_prog)
inlineoverride

Set the observer class so that feedback on the interpolation process can be received.

Parameters
a_progThe observer.

Definition at line 180 of file InterpIdw.cpp.

References m_prog.

◆ SetPower()

void xms::InterpIdwImpl::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.

Parameters
a_powerthe 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.

◆ SetPtActivity()

void xms::InterpIdwImpl::SetPtActivity ( DynBitset a_activity)
overridevirtual

Sets the activity on the point being used to interpolate.

Parameters
a_activityBitset of point activity.

Definition at line 505 of file InterpIdw.cpp.

References m_ptSearch.

◆ SetPts()

void xms::InterpIdwImpl::SetPts ( BSHP< VecPt3d a_pts,
bool  a_2d 
)
overridevirtual

Sets the points that will be used to do the interpolation.

Parameters
a_ptsarray of the point locations
a_2dindicates 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().

◆ SetPtsTris()

void xms::InterpIdwImpl::SetPtsTris ( BSHP< VecPt3d a_pts,
BSHP< VecInt a_tris 
)
overridevirtual

Sets the points that will be used to do the interpolation.

Parameters
a_ptsarray of the point locations
a_tristriangles

Definition at line 340 of file InterpIdw.cpp.

References m_tris, and SetPts().

◆ SetSaveWeights()

virtual void xms::InterpIdwImpl::SetSaveWeights ( bool  a_)
inlineoverridevirtual

sets a flag to save the weights computed by the interpolation

Parameters
[in]a_flag: true will save weights and false will not

Definition at line 161 of file InterpIdw.cpp.

References m_saveWeights.

◆ SetScalars() [1/2]

void xms::InterpIdwImpl::SetScalars ( const float *  a_scalar,
size_t  a_n 
)
override

Sets the scalar values that will be used to do the interpolation.

Parameters
a_scalararray of scalar values
a_nsize 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().

◆ SetScalars() [2/2]

void xms::InterpIdwImpl::SetScalars ( BSHP< VecFlt a_scalar)
override

Sets the scalar values that will be used to do the interpolation.

Parameters
a_scalararray of scalar values

Definition at line 381 of file InterpIdw.cpp.

References m_scalarFrom, and RecalcNodalFunc().

◆ SetSearchOpts()

void xms::InterpIdwImpl::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.

Parameters
a_nNearestPointsthe number of nearest points to the interpolation point. These points are used to do the interpolation.
a_quad_oct_Searchspecifies 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.

◆ SetTrunc()

void xms::InterpIdwImpl::SetTrunc ( double  a_sMax,
double  a_sMin 
)
overridevirtual

Set the truncation values for the interpolation and turn on truncation.

Parameters
a_sMaxThe maximum value for truncation.
a_sMinThe minimum value for truncation.

Definition at line 557 of file InterpIdw.cpp.

References m_trunc, m_truncMax, and m_truncMin.

◆ SetWeightCalcMethod()

void xms::InterpIdwImpl::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.

Parameters
a_The weight calculation method.

Definition at line 676 of file InterpIdw.cpp.

References m_modifiedShepardWeights.

◆ ToString()

std::string xms::InterpIdwImpl::ToString ( ) const
overridevirtual

Write the internals to a string.

Returns
The 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().

◆ ValFromWeights()

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.

Parameters
a_wVector of weights associated with locations indicated in the a_nPts vector.
a_nPtsVector of indices into the m_pts vector for the nearest points to a_pt.
a_valInterpolated value calculated in this method.
a_ptIdxIndex associated with a_pt that is used to later process interpolation weights.
a_ptThe location of the interpolation point.

Definition at line 652 of file InterpIdw.cpp.

References m_saveWeights, and ScalarFromNodalFunc().

Referenced by InterpToPt().

Member Data Documentation

◆ m_2d

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().

◆ m_nNearestPts

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().

◆ m_power

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().


The documentation for this class was generated from the following file: