xmsinterp
1.0
|
Performs natural neighbor interpolation to a location. More...
Public Member Functions | |
InterpNatNeighImpl (const std::vector< xms::Pt3d > &a_pts, const std::vector< int > &a_tris, const std::vector< float > &a_scalar, GmTriSearch *a_triSearch) | |
Consructor. More... | |
virtual float | InterpToPt (const xms::Pt3d &a_pt) override |
Interpolates to a_pt. More... | |
virtual void | GetNeighbors (int a_ptIdx, std::vector< int > &a_neigh) override |
Finds neighboring triangles for the pt at a_ptIdx index in m_pts. More... | |
virtual void | SetNodalFunc (BSHP< NodalFunc > a_) override |
Set the precomputed nodal function. More... | |
virtual void | RecalcNodalFunc () override |
Recalculates the nodal function. This happens when the scalars change. | |
virtual void | SetBlendWeights (bool a_) override |
Turns on a flag for using a blending function when calculating weights. More... | |
virtual std::string | ToString () override |
serializes the class to a string More... | |
void | FillEdgeMap () |
Creates a map of edges for natural neighbor calculations. | |
void | FillCenterVec () |
calculate the circumcircle centers for all triangles | |
void | EdgesFromTri (int a_triIdx, std::pair< int, int > a_edges[3]) |
fill an array of edges from a triangle index More... | |
void | NeighTriFromTriIdx (int a_triIdx, std::vector< int > &a_tris) |
Gets the adjacent triangles to a_triIdx. More... | |
void | GetNatNeighTriangles (const xms::Pt3d &a_pt, std::vector< int > &a_tris) |
Given a pt this will find the "natural neighbor" triangles. First, we find the triangle that the pt is in. Then we visit the neighbor triangles to see if the point is inside of its circumcircle. If it is then we will also visit the neighbors of that triangle and so on. More... | |
double | BlendFunc (double a_x) |
Blending function to smooth interpolation weights refactored from GMS. More... | |
double | ScalarFromNodalFunc (int a_ptIdx, const xms::Pt3d &a_loc) |
calculates the scalar using the nodal function More... | |
double | HaleNnInterp (const xms::Pt3d &a_pt) |
Implementation of natural neighbor interpolation taken from this paper A stable and fast implementation of natural neighbor interpolation Luming Liang & Dave Hale Center for Wave Phenomena, Colorado School of Mines,Golden, CO 80401, USA April 20, 2010. More... | |
void | HaleNnVisitNeighbors (int a_tIdx, const xms::Pt3d &a_pt, std::vector< nnOuterEdgeStruct > &a_outerEdges, std::map< int, double > &a_weights) |
Visit the neighbors to a_pt and calculate the interpolation weight for the natural neighbors. More... | |
int | AdjacentTriangle (std::pair< int, int > &a_edge, int a_triIdx) |
Gets the triangle adjacent to a_edge. More... | |
bool | PtInTriCircumCircle (const xms::Pt3d &a_pt, int a_tri) |
Determines if a point is inside of a triangle circumcircle. More... | |
void | HaleNnAddOuterEdge (std::vector< nnOuterEdgeStruct > &a_, int a_tIdx, int a_ptIdx0, int a_ptIdx1, const xms::Pt3d &a_pt) |
Adds a nnOuterEdgeStruct to a vector. More... | |
void | HaleNnSortOuterEdges (std::vector< nnOuterEdgeStruct > &a_) |
Sorts the outer edges. More... | |
void | HaleNnOuterEdgesToWeights (std::vector< nnOuterEdgeStruct > &a_outerEdges, std::map< int, double > &a_weights) |
Calculates weights from the outer edges. More... | |
void | NormalizeWeights (std::map< int, double > &a_weights) |
Normalizes the weights so that they sum to 1.0. More... | |
void | BlendWeights (std::map< int, double > &a_weights) |
Blends the weights using BlendFunc. Smooths the interpolation. More... | |
double | ScalarFromWeights (std::map< int, double > &a_weights, const xms::Pt3d &a_pt) |
Computes a scalar at a_pt based on the interpolation weights. More... | |
Public Member Functions inherited from xms::InterpNatNeigh | |
virtual | ~InterpNatNeigh () |
Destructor. | |
Private Types | |
typedef boost::unordered_map< std::pair< int, int >, std::pair< int, int > > | MapEdges |
typedef for long template | |
Private Attributes | |
const std::vector< xms::Pt3d > & | m_pts |
points interpolating from | |
const std::vector< int > & | m_tris |
triangles interpolating from | |
const std::vector< float > & | m_scalar |
scalar interpolating from | |
double | m_tol |
tolerance for geometric floating point comparisons | |
MapEdges | m_edges |
map of triangle edges | |
std::vector< xms::Pt3d > | m_centers |
circumcircle centers of triangles | |
BSHP< NodalFunc > | m_nf |
Nodal function (constant, gradient plane, quadratic) | |
GmTriSearch * | m_triSearch |
Spatial index for searching triangles. | |
bool | m_blendWeights |
flag for blending interpolation weights | |
Additional Inherited Members | |
Static Public Member Functions inherited from xms::InterpNatNeigh | |
static boost::shared_ptr< InterpNatNeigh > | New (const std::vector< Pt3d > &a_pts, const std::vector< int > &a_tris, const std::vector< float > &a_scalar, GmTriSearch *a_triSearch) |
Creates a Natural Neighbor Interpolation class. More... | |
Protected Member Functions inherited from xms::InterpNatNeigh | |
InterpNatNeigh () | |
Constructor. | |
Performs natural neighbor interpolation to a location.
Definition at line 58 of file InterpNatNeigh.cpp.
xms::InterpNatNeighImpl::InterpNatNeighImpl | ( | const std::vector< xms::Pt3d > & | a_pts, |
const std::vector< int > & | a_tris, | ||
const std::vector< float > & | a_scalar, | ||
GmTriSearch * | a_triSearch | ||
) |
Consructor.
[in] | a_pts | Locations that are interpolated from |
[in] | a_tris | Triangles connecting a_pts and defining neighbors |
[in] | a_scalar | Scalars that are interpolated from |
[in] | a_triSearch | Spatial index for searching triangles |
Definition at line 168 of file InterpNatNeigh.cpp.
References FillCenterVec(), and FillEdgeMap().
int xms::InterpNatNeighImpl::AdjacentTriangle | ( | std::pair< int, int > & | a_edge, |
int | a_triIdx | ||
) |
Gets the triangle adjacent to a_edge.
[in] | a_edge | A triangle edge |
[in] | a_triIdx | Triangle index |
Definition at line 508 of file InterpNatNeigh.cpp.
References m_edges, and XM_NONE.
Referenced by HaleNnVisitNeighbors().
double xms::InterpNatNeighImpl::BlendFunc | ( | double | x | ) |
Blending function to smooth interpolation weights refactored from GMS.
x | interpolation weight |
Definition at line 399 of file InterpNatNeigh.cpp.
Referenced by BlendWeights().
void xms::InterpNatNeighImpl::BlendWeights | ( | std::map< int, double > & | a_weights | ) |
Blends the weights using BlendFunc. Smooths the interpolation.
[out] | a_weights | The interpolation weights |
Definition at line 622 of file InterpNatNeigh.cpp.
References BlendFunc().
Referenced by HaleNnInterp().
void xms::InterpNatNeighImpl::EdgesFromTri | ( | int | a_triIdx, |
std::pair< int, int > | a_edges[3] | ||
) |
fill an array of edges from a triangle index
[in] | a_triIdx | Index of the triangle |
[out] | a_edges | Array of triangle edges filled by this method |
Definition at line 325 of file InterpNatNeigh.cpp.
References m_tris.
Referenced by FillEdgeMap(), and NeighTriFromTriIdx().
void xms::InterpNatNeighImpl::GetNatNeighTriangles | ( | const xms::Pt3d & | a_pt, |
std::vector< int > & | a_tris | ||
) |
Given a pt this will find the "natural neighbor" triangles. First, we find the triangle that the pt is in. Then we visit the neighbor triangles to see if the point is inside of its circumcircle. If it is then we will also visit the neighbors of that triangle and so on.
[in] | a_pt | The location to find the natural neighbor triangles |
[out] | a_tris | The triangle indexes that are natural neighbors to a_pt |
Definition at line 360 of file InterpNatNeigh.cpp.
References m_centers, m_tris, m_triSearch, NeighTriFromTriIdx(), and XM_NONE.
Referenced by GetNeighbors(), and InterpNatNeighUnitTests::testGetTris().
|
overridevirtual |
Finds neighboring triangles for the pt at a_ptIdx index in m_pts.
[in] | a_ptIdx | Index to the point where we want to find its neighbor triangles |
[out] | a_neigh | Vector of triangle indexes |
Definition at line 199 of file InterpNatNeigh.cpp.
References GetNatNeighTriangles(), m_pts, and m_tris.
Referenced by InterpNatNeighUnitTests::testGetNeighbors().
void xms::InterpNatNeighImpl::HaleNnAddOuterEdge | ( | std::vector< nnOuterEdgeStruct > & | a_, |
int | a_tIdx, | ||
int | a_ptIdx0, | ||
int | a_ptIdx1, | ||
const xms::Pt3d & | a_pt | ||
) |
Adds a nnOuterEdgeStruct to a vector.
[out] | a_ | Vector of outer edges |
[in] | a_tIdx | Triangle index |
[in] | a_ptIdx0 | Point index for first point on edge of triangle a_tIdx |
[in] | a_ptIdx1 | Point index for second point on edge of triangle a_tIdx |
[in] | a_pt | Location used to find this outer edge |
Definition at line 542 of file InterpNatNeigh.cpp.
References xms::nnOuterEdgeStruct::m_cc, xms::nnOuterEdgeStruct::m_edge, m_pts, m_tol, and xms::nnOuterEdgeStruct::m_triIdx.
Referenced by HaleNnVisitNeighbors().
double xms::InterpNatNeighImpl::HaleNnInterp | ( | const xms::Pt3d & | a_pt | ) |
Implementation of natural neighbor interpolation taken from this paper A stable and fast implementation of natural neighbor interpolation Luming Liang & Dave Hale Center for Wave Phenomena, Colorado School of Mines,Golden, CO 80401, USA April 20, 2010.
[in] | a_pt | The location being interpolated to |
Definition at line 427 of file InterpNatNeigh.cpp.
References BlendWeights(), HaleNnOuterEdgesToWeights(), HaleNnSortOuterEdges(), HaleNnVisitNeighbors(), m_blendWeights, m_triSearch, NormalizeWeights(), ScalarFromWeights(), and XM_NONE.
Referenced by InterpToPt(), and InterpNatNeighUnitTests::testHaleNnInterp().
void xms::InterpNatNeighImpl::HaleNnOuterEdgesToWeights | ( | std::vector< nnOuterEdgeStruct > & | a_outerEdges, |
std::map< int, double > & | a_weights | ||
) |
Calculates weights from the outer edges.
[in] | a_outerEdges | The outer edges |
[out] | a_weights | Weight calculated for each outer edge |
Definition at line 577 of file InterpNatNeigh.cpp.
References xms::nnOuterEdgeStruct::m_cc, m_centers, xms::nnOuterEdgeStruct::m_edge, and xms::nnOuterEdgeStruct::m_triIdx.
Referenced by HaleNnInterp().
void xms::InterpNatNeighImpl::HaleNnSortOuterEdges | ( | std::vector< nnOuterEdgeStruct > & | a_ | ) |
Sorts the outer edges.
[out] | a_ | Vector of outer edges |
Definition at line 560 of file InterpNatNeigh.cpp.
Referenced by HaleNnInterp(), and InterpNatNeighUnitTests::testHaleNnSortOuterEdges().
void xms::InterpNatNeighImpl::HaleNnVisitNeighbors | ( | int | a_tIdx, |
const xms::Pt3d & | a_pt, | ||
std::vector< nnOuterEdgeStruct > & | a_outerEdges, | ||
std::map< int, double > & | a_weights | ||
) |
Visit the neighbors to a_pt and calculate the interpolation weight for the natural neighbors.
[in] | a_tIdx | Starting triangle index |
[in] | a_pt | Location used to find natural neighbors |
[out] | a_outerEdges | Outer edges for a_pt |
[out] | a_weights | Interpolation weight for neighbor triangle |
Definition at line 459 of file InterpNatNeigh.cpp.
References AdjacentTriangle(), HaleNnAddOuterEdge(), m_centers, m_tris, PtInTriCircumCircle(), and XM_NONE.
Referenced by HaleNnInterp().
|
overridevirtual |
Interpolates to a_pt.
[in] | a_pt | The location to interpolate to |
Definition at line 189 of file InterpNatNeigh.cpp.
References HaleNnInterp().
void xms::InterpNatNeighImpl::NeighTriFromTriIdx | ( | int | a_triIdx, |
std::vector< int > & | a_tris | ||
) |
Gets the adjacent triangles to a_triIdx.
[in] | a_triIdx | Index of the triangle |
[out] | a_tris | Indexes of adjacent triangles |
Definition at line 336 of file InterpNatNeigh.cpp.
References EdgesFromTri(), m_edges, and XM_NONE.
Referenced by GetNatNeighTriangles().
void xms::InterpNatNeighImpl::NormalizeWeights | ( | std::map< int, double > & | a_weights | ) |
Normalizes the weights so that they sum to 1.0.
[out] | a_weights | The interpolation weights |
Definition at line 609 of file InterpNatNeigh.cpp.
Referenced by HaleNnInterp().
bool xms::InterpNatNeighImpl::PtInTriCircumCircle | ( | const xms::Pt3d & | a_pt, |
int | a_tri | ||
) |
Determines if a point is inside of a triangle circumcircle.
[in] | a_pt | The location to test |
[in] | a_tri | Index to the triangle |
Definition at line 526 of file InterpNatNeigh.cpp.
References m_centers.
Referenced by HaleNnVisitNeighbors().
double xms::InterpNatNeighImpl::ScalarFromNodalFunc | ( | int | a_ptIdx, |
const xms::Pt3d & | a_loc | ||
) |
calculates the scalar using the nodal function
[in] | a_ptIdx | Index to point in m_pts |
[in] | a_loc | Location being interpolated to |
Definition at line 409 of file InterpNatNeigh.cpp.
References m_nf, and m_scalar.
Referenced by ScalarFromWeights().
double xms::InterpNatNeighImpl::ScalarFromWeights | ( | std::map< int, double > & | a_weights, |
const xms::Pt3d & | a_pt | ||
) |
Computes a scalar at a_pt based on the interpolation weights.
[in] | a_weights | The interpolation weights |
[in] | a_pt | The location interpolated to. |
Definition at line 640 of file InterpNatNeigh.cpp.
References ScalarFromNodalFunc().
Referenced by HaleNnInterp().
|
overridevirtual |
Turns on a flag for using a blending function when calculating weights.
[in] | a_ | flag to turn on weight blending |
Definition at line 236 of file InterpNatNeigh.cpp.
References m_blendWeights.
Set the precomputed nodal function.
a_ | The nodal function class. |
Definition at line 220 of file InterpNatNeigh.cpp.
References m_nf.
|
overridevirtual |
serializes the class to a string
Definition at line 244 of file InterpNatNeigh.cpp.
References m_blendWeights, m_centers, m_edges, m_pts, m_scalar, m_tol, m_tris, and VecToStream().