xmsgrid  1.0
xms::GmPtSearchImpl Class Reference

Implementation of GmPtSearch. Generic class for searching location data. Uses a boost R-tree to query a set of locations. Works for 2D and 3D. More...

Inheritance diagram for xms::GmPtSearchImpl:
xms::GmPtSearch

Public Member Functions

 GmPtSearchImpl (bool a_2dSearch)
 Constructor. More...
 
virtual void PtsToSearch (BSHP< std::vector< Pt3d >> a_pts) override
 Adds the point locations to the class. More...
 
virtual void VectorThatGrowsToSearch (BSHP< std::vector< Pt3d >> a_) override
 Adds the point locations to the class. More...
 
virtual bool AddPtToVectorIfUnique (const Pt3d &a_, double a_tol, int &a_ptIdx) override
 Adds the point to the R-tree if the point location is unique based on the passed in tolerance. If a point exists at this location then return false. If the point is added then return true. More...
 
virtual void NearestPtsToPt (const Pt3d &a_pt, int a_numPtsToFind, bool a_quad_oct_Search, std::vector< int > &a_nearest) const override
 Finds the nearest points to the input a_pt with an option to search quadrants/octants. More...
 
virtual void NearestPtsToPtInRtree (int a_ptIdx, const Pt3d &a_pt, int a_numPtsToFind, bool a_quad_oct_Search, std::vector< int > &a_nearest) const override
 Finds the nearest points to the input a_pt with an option to search quadrants/octants. Similar to NearestPtsToPt but this method will always pass the fSatisfies class to the RTree. This method is used to find the nearest points to a point that is included in the RTree. More...
 
virtual bool PtInRTree (const Pt3d &a_pt, const double a_tol) override
 Checks if the point is in the Rtree within tolerance. More...
 
virtual void PtsWithinDistanceToPtInRtree (int a_ptIdx, const Pt3d &a_pt, double a_dist, std::vector< int > &a_nearest) const override
 Finds the nearest points to the input a_pt with an option to search quadrants/octants. Similar to NearestPtsToPt but this method will always pass the fSatisfies class to the RTree. This method is used to find the nearest points to a point that is included in the RTree. More...
 
virtual void NearestPtsToPt (const Pt3d &a_pt, int a_numPtsToFind, bool a_quad_oct_Search, std::vector< int > &a_nearest, fSatisfies *a_fsat) const
 Finds the nearest points to the input a_pt with an option to search quadrants/octants. The difference with this method is the addition of the fSatisfies class. When performing a search in each quadrant/octant it is possible for a point to be exactly on the boundary of a quadrant but we don't want to include that point more than 1 time. The fSatisfies class ensures that a point is only included 1 time. More...
 
virtual void SetActivity (DynBitset &a_activity) override
 Sets activity on the points in the Rtree so that points can be ignored when interpolating. More...
 
virtual DynBitset GetActivity () override
 Returns the point activity. More...
 
virtual const BSHP< VecPt3dGetPointsPtr () const override
 Returns shared point to the point locations in the RTree. More...
 
virtual bool Is2D () const override
 Returns true if class only searches in 2D. More...
 
virtual std::string ToString () const override
 Write the internals to a string. More...
 
void UpdateMinMax (const Pt3d *a_pts, size_t a_npts)
 Updates the m_min, m_max variables. More...
 
void CreateOctants (const Pt3d &a_pt, std::vector< box > &a_boxes) const
 Creates octants (or quadrants for 2d) to be used in the rtree query. More...
 

Public Attributes

bool m_2dSearch
 flag specifying 2d searching only
 
Pt3d m_min
 minimum extents of points
 
Pt3d m_max
 maximum extents of points
 
DynBitset m_activity
 point activity
 
bgi::rtree< value, qRtree, idx_pt > * m_rTree
 spatial index for searching the points
 
BSHP< VecPt3dm_bshpPt3d
 Vector of point locations.
 

Additional Inherited Members

Detailed Description

Implementation of GmPtSearch. Generic class for searching location data. Uses a boost R-tree to query a set of locations. Works for 2D and 3D.

Definition at line 168 of file GmPtSearch.cpp.

Constructor & Destructor Documentation

◆ GmPtSearchImpl()

xms::GmPtSearchImpl::GmPtSearchImpl ( bool  a_2dSearch)

Constructor.

Parameters
[in]a_2dSearchFlag to specify that searching is in 2D (x,y) only.

Definition at line 260 of file GmPtSearch.cpp.

Member Function Documentation

◆ AddPtToVectorIfUnique()

bool xms::GmPtSearchImpl::AddPtToVectorIfUnique ( const Pt3d a_pt,
double  a_tol,
int &  a_ptIdx 
)
overridevirtual

Adds the point to the R-tree if the point location is unique based on the passed in tolerance. If a point exists at this location then return false. If the point is added then return true.

Parameters
a_ptlocation to test
a_tolTolerance used to compare point locations
a_ptIdxNew point's index (if unique) or matching point's index.
Returns
true if unique, false if a_pt matched an existing point.

Definition at line 349 of file GmPtSearch.cpp.

References m_bshpPt3d, m_max, m_min, m_rTree, PtsWithinDistanceToPtInRtree(), xms::Pt3< T >::x, xms::Pt3< T >::y, and xms::Pt3< T >::z.

Referenced by PtSearchUnitTests::testVectorThatGrows().

◆ CreateOctants()

void xms::GmPtSearchImpl::CreateOctants ( const Pt3d a_pt,
std::vector< box > &  a_boxes 
) const

Creates octants (or quadrants for 2d) to be used in the rtree query.

Parameters
a_ptThe location about which to create the quadrants/octants.
a_boxesVector filled in by this method defining the quadrants/octants.

Definition at line 591 of file GmPtSearch.cpp.

References m_2dSearch, m_max, m_min, xms::Pt3< T >::x, xms::Pt3< T >::y, and xms::Pt3< T >::z.

Referenced by NearestPtsToPt().

◆ GetActivity()

DynBitset xms::GmPtSearchImpl::GetActivity ( )
overridevirtual

Returns the point activity.

Returns
dynamic bitset of point activity.

Definition at line 563 of file GmPtSearch.cpp.

References m_activity.

◆ GetPointsPtr()

virtual const BSHP<VecPt3d> xms::GmPtSearchImpl::GetPointsPtr ( ) const
inlineoverridevirtual

Returns shared point to the point locations in the RTree.

Returns
VecPt3d.

Definition at line 208 of file GmPtSearch.cpp.

References m_bshpPt3d.

◆ Is2D()

virtual bool xms::GmPtSearchImpl::Is2D ( ) const
inlineoverridevirtual

Returns true if class only searches in 2D.

Returns
true or false.

Definition at line 211 of file GmPtSearch.cpp.

References m_2dSearch.

◆ NearestPtsToPt() [1/2]

void xms::GmPtSearchImpl::NearestPtsToPt ( const Pt3d a_pt,
int  a_numPtsToFind,
bool  a_quad_oct_Search,
std::vector< int > &  a_nearest 
) const
overridevirtual

Finds the nearest points to the input a_pt with an option to search quadrants/octants.

Parameters
a_ptThe location we are interested in.
a_numPtsToFindThe number of nearest points to a_pt to find.
a_quad_oct_SearchWhether to perform the nearest points search in each quadrant (2d) or octant (3d).
a_nearestVector that is filled in by this method.

Definition at line 387 of file GmPtSearch.cpp.

References m_activity, and xms::fSatisfies::m_bits.

Referenced by NearestPtsToPtInRtree().

◆ NearestPtsToPt() [2/2]

void xms::GmPtSearchImpl::NearestPtsToPt ( const Pt3d a_pt,
int  a_numPtsToFind,
bool  a_quad_oct_Search,
std::vector< int > &  a_nearest,
fSatisfies a_fsat 
) const
virtual

Finds the nearest points to the input a_pt with an option to search quadrants/octants. The difference with this method is the addition of the fSatisfies class. When performing a search in each quadrant/octant it is possible for a point to be exactly on the boundary of a quadrant but we don't want to include that point more than 1 time. The fSatisfies class ensures that a point is only included 1 time.

Parameters
a_ptThe location we are interested in.
a_numPtsToFindThe number of nearest points to a_pt to find.
a_quad_oct_SearchWhether to perform the nearest points search in each quadrant (2d) or octant (3d).
a_nearestVector that is filled in by this method.
a_fsatClass used to ensure a point is include only 1 time in the search results.

Definition at line 415 of file GmPtSearch.cpp.

References CreateOctants(), xmlog::error, m_bshpPt3d, m_rTree, and XM_LOG.

◆ NearestPtsToPtInRtree()

void xms::GmPtSearchImpl::NearestPtsToPtInRtree ( int  a_ptIdx,
const Pt3d a_pt,
int  a_numPtsToFind,
bool  a_quad_oct_Search,
std::vector< int > &  a_nearest 
) const
overridevirtual

Finds the nearest points to the input a_pt with an option to search quadrants/octants. Similar to NearestPtsToPt but this method will always pass the fSatisfies class to the RTree. This method is used to find the nearest points to a point that is included in the RTree.

Parameters
a_ptIdxThe index of the point a_pt. a_pt is in the RTree and we don't want it in the results.
a_ptThe location we are interested in.
a_numPtsToFindThe number of nearest points to a_pt to find.
a_quad_oct_SearchWhether to perform the nearest points search in each quadrant (2d) or octant (3d).
a_nearestVector that is filled in by this method.

Definition at line 478 of file GmPtSearch.cpp.

References m_activity, xms::fSatisfies::m_bits, m_rTree, and NearestPtsToPt().

◆ PtInRTree()

bool xms::GmPtSearchImpl::PtInRTree ( const Pt3d a_pt,
const double  a_tol 
)
overridevirtual

Checks if the point is in the Rtree within tolerance.

Parameters
a_ptThe location being searched.
a_tolA distance used to define a box around a_pt to see if any Rtree pts are inside that box.
Returns
true if the point is in the RTree.

Definition at line 497 of file GmPtSearch.cpp.

References PtsWithinDistanceToPtInRtree().

◆ PtsToSearch()

void xms::GmPtSearchImpl::PtsToSearch ( BSHP< std::vector< Pt3d >>  a_pts)
overridevirtual

Adds the point locations to the class.

Parameters
[in]a_ptsArray of point locations.

Definition at line 280 of file GmPtSearch.cpp.

References m_2dSearch, m_bshpPt3d, m_rTree, and UpdateMinMax().

Referenced by PtSearchUnitTests::testPtsWithinDist().

◆ PtsWithinDistanceToPtInRtree()

void xms::GmPtSearchImpl::PtsWithinDistanceToPtInRtree ( int  a_ptIdx,
const Pt3d a_pt,
double  a_distance,
std::vector< int > &  a_nearest 
) const
overridevirtual

Finds the nearest points to the input a_pt with an option to search quadrants/octants. Similar to NearestPtsToPt but this method will always pass the fSatisfies class to the RTree. This method is used to find the nearest points to a point that is included in the RTree.

Parameters
a_ptIdxThe index of the point a_pt. a_pt is in the RTree and we don't want it in the results.
a_ptThe location we are interested in.
a_distanceThe distance from the point where we want to find additional points
a_nearestVector that is filled in by this method.

Definition at line 515 of file GmPtSearch.cpp.

References m_2dSearch, m_activity, xms::fSatisfies::m_bits, m_rTree, and xms::Pt3< T >::z.

Referenced by AddPtToVectorIfUnique(), PtInRTree(), and PtSearchUnitTests::testPtsWithinDist().

◆ SetActivity()

void xms::GmPtSearchImpl::SetActivity ( DynBitset a_activity)
overridevirtual

Sets activity on the points in the Rtree so that points can be ignored when interpolating.

Parameters
a_activityBitset of the point activity. Must be the same size as the number of points.

Definition at line 551 of file GmPtSearch.cpp.

References m_activity, and m_rTree.

◆ ToString()

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

Write the internals to a string.

Returns
The string.

Definition at line 573 of file GmPtSearch.cpp.

References m_2dSearch, m_activity, m_bshpPt3d, m_max, m_min, and VecToStream().

◆ UpdateMinMax()

void xms::GmPtSearchImpl::UpdateMinMax ( const Pt3d a_pts,
size_t  a_nPts 
)

Updates the m_min, m_max variables.

Parameters
a_ptsArray of point locations.
a_nPtsNumber of values in a_pts array.

Definition at line 299 of file GmPtSearch.cpp.

References m_2dSearch, m_max, m_min, xms::Pt3< T >::x, xms::Pt3< T >::y, and xms::Pt3< T >::z.

Referenced by PtsToSearch(), and VectorThatGrowsToSearch().

◆ VectorThatGrowsToSearch()

void xms::GmPtSearchImpl::VectorThatGrowsToSearch ( BSHP< std::vector< Pt3d >>  a_)
overridevirtual

Adds the point locations to the class.

Parameters
a_Shared pointer to array of point locations.

Definition at line 326 of file GmPtSearch.cpp.

References m_2dSearch, m_bshpPt3d, m_rTree, and UpdateMinMax().

Referenced by PtSearchUnitTests::testVectorThatGrows().


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