xmsgrid  1.0
xms::GmTriSearchImpl Class Reference

Implementation of GmTriSearch. More...

Inheritance diagram for xms::GmTriSearchImpl:
xms::GmTriSearch

Public Member Functions

 GmTriSearchImpl ()
 Constructor.
 
virtual ~GmTriSearchImpl ()
 Destructor.
 
virtual void TrisToSearch (BSHP< std::vector< Pt3d >> a_pts, BSHP< std::vector< int >> a_tris) override
 Adds the triangles to the class. More...
 
virtual void SetPtActivity (DynBitset &a_activity) override
 Modifies the activity bitset of the points. More...
 
virtual void SetTriActivity (DynBitset &a_activity) override
 Modifies the activity bitset of the triangles. More...
 
virtual DynBitset GetPtActivity () const override
 Activity of the points based on the triangle activity. More...
 
virtual DynBitset GetTriActivity () const override
 Gets the activity bitset of the triangles. More...
 
bool ActiveTri (int a_idx) const
 Tests if a triangle is active. If any of the points of the tri are not active then the tri is not active. More...
 
virtual int TriContainingPt (const Pt3d &a_pt) override
 Find the triangle containing the point. More...
 
virtual void TriEnvelopsContainingPt (const Pt3d &a_pt, std::vector< int > &a_tris) override
 Find all triangles whose envelope contains the point. More...
 
virtual void TriEnvelopesOverlap (const Pt3d &a_pMin, const Pt3d &a_pMax, std::vector< int > &a_tris) override
 Find all triangles whose envelope overlaps the envelope defined by a_pMin and a_pMax. More...
 
virtual bool InterpWeights (const Pt3d &a_pt, std::vector< int > &a_idxs, std::vector< double > &a_wts) override
 Use the stored triangles to get interpolation weights for a point. Returns false if the point is outside the triangles. More...
 
virtual bool InterpWeightsTriangleIdx (const Pt3d &a_pt, int &a_triangleIdx, std::vector< int > &a_idxs, std::vector< double > &a_wts) override
 Use the stored triangles to get interpolation weights for a point. Returns false if the point is outside the triangles. More...
 
virtual const BSHP< VecPt3dGetPoints () const override
 Returns the points. More...
 
virtual const BSHP< VecIntGetTriangles () const override
 Returns the triangles. More...
 
virtual std::string ToString () const override
 Write the internals to a string. More...
 
void CreateRTree ()
 Creates the RTree of the triangles.
 
void PointIdxesFromTriIdx (int a_triIdx, int a_ptIdxes[3])
 Fills in the point indices based on the triangle index. More...
 
int FindTriangle (const Pt3d &a_pt, int ix[3], Pt3d &weights)
 Find the triangle containing the location a_pt. More...
 
void GetTriBarycentricVals (int a_idx, int a_ix[3], BarycentricVals &a_b)
 Gets the barycentric values for a triangle. More...
 
DynBitset PointActivityFromTriActivity () const
 Gets the activity of the points from the triangles. More...
 
BSHP< GmPtSearchCreatePtSearch ()
 creates the rtree of the points More...
 

Public Attributes

Pt3d m_min
 mininum extents of all points
 
Pt3d m_max
 maximum extents of all points
 
BSHP< std::vector< Pt3d > > m_pts
 point locations
 
BSHP< std::vector< int > > m_tris
 triangles that reference point indexes
 
DynBitset m_triActivity
 activity of the triangles
 
boost::unordered_map< size_t, BarycentricValsm_cache
 
bgi::rtree< value, qRtree, idx_tri > * m_rTree
 spatial index of the triangle extents
 

Additional Inherited Members

Detailed Description

Implementation of GmTriSearch.

Provides functionality to do spatial queries on a set of triangles. Uses the boost RTree for queries.

Definition at line 124 of file GmTriSearch.cpp.

Member Function Documentation

◆ ActiveTri()

bool xms::GmTriSearchImpl::ActiveTri ( int  a_idx) const

Tests if a triangle is active. If any of the points of the tri are not active then the tri is not active.

Parameters
a_idxTriangle index
Returns
true if the triangle a_idx is active.

Definition at line 380 of file GmTriSearch.cpp.

References m_triActivity.

Referenced by FindTriangle(), and PointActivityFromTriActivity().

◆ CreatePtSearch()

BSHP< GmPtSearch > xms::GmTriSearchImpl::CreatePtSearch ( )

creates the rtree of the points

Returns
GmPtSearch.

Definition at line 657 of file GmTriSearch.cpp.

References m_pts, xms::GmPtSearch::New(), and PointActivityFromTriActivity().

◆ FindTriangle()

int xms::GmTriSearchImpl::FindTriangle ( const Pt3d a_pt,
int  ix[3],
Pt3d weights 
)

Find the triangle containing the location a_pt.

Parameters
a_ptThe location to interpolate to.
ixThe point indices from the triangle containing a_pt.
weightsThe weights associated with the points ix.
Returns
index to the triangle containg a_pt.

Definition at line 550 of file GmTriSearch.cpp.

References ActiveTri(), BARYTOL, xmlog::error, GetTriBarycentricVals(), xms::iGetBarycentricCoords(), m_pts, m_rTree, m_tris, xms::Pt3< T >::x, XM_LOG, XM_NONE, xms::Pt3< T >::y, and xms::Pt3< T >::z.

Referenced by InterpWeightsTriangleIdx(), and TriContainingPt().

◆ GetPoints()

const BSHP< VecPt3d > xms::GmTriSearchImpl::GetPoints ( ) const
overridevirtual

Returns the points.

Returns
constant shared pointer to the vector of points.

Definition at line 494 of file GmTriSearch.cpp.

References m_pts.

◆ GetPtActivity()

virtual DynBitset xms::GmTriSearchImpl::GetPtActivity ( ) const
inlineoverridevirtual

Activity of the points based on the triangle activity.

Returns
boost::dynamic_bitset of size_t

Definition at line 134 of file GmTriSearch.cpp.

References PointActivityFromTriActivity().

◆ GetTriActivity()

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

Gets the activity bitset of the triangles.

Returns
bitset of the activity of the triangles

Definition at line 361 of file GmTriSearch.cpp.

References m_triActivity, and m_tris.

◆ GetTriangles()

const BSHP< VecInt > xms::GmTriSearchImpl::GetTriangles ( ) const
overridevirtual

Returns the triangles.

Returns
constant shared pointer to the vector of triangles.

Definition at line 502 of file GmTriSearch.cpp.

References m_tris.

◆ GetTriBarycentricVals()

void xms::GmTriSearchImpl::GetTriBarycentricVals ( int  a_idx,
int  a_ix[3],
BarycentricVals a_b 
)

Gets the barycentric values for a triangle.

Parameters
a_idxTriangle index
a_ixPoint indexes that make up triangle
a_bThe barycentric values

Definition at line 617 of file GmTriSearch.cpp.

References xms::iCartToBary(), m_cache, and m_pts.

Referenced by FindTriangle().

◆ InterpWeights()

bool xms::GmTriSearchImpl::InterpWeights ( const Pt3d a_pt,
std::vector< int > &  a_idxs,
std::vector< double > &  a_wts 
)
overridevirtual

Use the stored triangles to get interpolation weights for a point. Returns false if the point is outside the triangles.

Parameters
a_ptLocation that is interpolated to.
a_idxsVector of triangle point indices filled in by this method.
a_wtsVector of triangle point weights filled in by this method.
Returns
false if a_pt is not inside of any triangle

Definition at line 452 of file GmTriSearch.cpp.

References InterpWeightsTriangleIdx().

◆ InterpWeightsTriangleIdx()

bool xms::GmTriSearchImpl::InterpWeightsTriangleIdx ( const Pt3d a_pt,
int &  a_triangleIdx,
std::vector< int > &  a_idxs,
std::vector< double > &  a_wts 
)
overridevirtual

Use the stored triangles to get interpolation weights for a point. Returns false if the point is outside the triangles.

Parameters
a_ptLocation that is interpolated to.
a_triangleIdxFound triangles index in triangle array (zero based count*3).
a_idxsVector of triangle point indices filled in by this method.
a_wtsVector of triangle point weights filled in by this method.
Returns
false if a_pt is not inside of any triangle

Definition at line 468 of file GmTriSearch.cpp.

References FindTriangle(), xms::Pt3< T >::x, XM_NONE, xms::Pt3< T >::y, and xms::Pt3< T >::z.

Referenced by InterpWeights().

◆ PointActivityFromTriActivity()

DynBitset xms::GmTriSearchImpl::PointActivityFromTriActivity ( ) const

Gets the activity of the points from the triangles.

Returns
bitset of the activity of the points.

Definition at line 633 of file GmTriSearch.cpp.

References ActiveTri(), m_pts, m_triActivity, and m_tris.

Referenced by CreatePtSearch(), and GetPtActivity().

◆ PointIdxesFromTriIdx()

void xms::GmTriSearchImpl::PointIdxesFromTriIdx ( int  a_triIdx,
int  a_ptIdxes[3] 
)

Fills in the point indices based on the triangle index.

Parameters
a_triIdxThe triangle index in the m_tris vector.
a_ptIdxesArray of point indices filled by this method. The indices correspond to locations in the m_pts vector.

Definition at line 529 of file GmTriSearch.cpp.

References xmlog::debug, m_tris, and XM_LOG.

◆ SetPtActivity()

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

Modifies the activity bitset of the points.

Parameters
a_activitybitset of the activity of the points

Definition at line 316 of file GmTriSearch.cpp.

References m_pts, m_triActivity, m_tris, and XM_ENSURE_TRUE_NO_ASSERT.

◆ SetTriActivity()

void xms::GmTriSearchImpl::SetTriActivity ( DynBitset a_activity)
overridevirtual

Modifies the activity bitset of the triangles.

Parameters
a_activitybitset of the activity of the triangles

Definition at line 336 of file GmTriSearch.cpp.

References m_triActivity, m_tris, and XM_ENSURE_TRUE_NO_ASSERT.

◆ ToString()

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

Write the internals to a string.

Returns
The string.

Definition at line 510 of file GmTriSearch.cpp.

References m_max, m_min, m_pts, m_triActivity, m_tris, and VecToStream().

◆ TriContainingPt()

int xms::GmTriSearchImpl::TriContainingPt ( const Pt3d a_pt)
overridevirtual

Find the triangle containing the point.

Parameters
a_ptLocation used to find a triangle.
Returns
Index of triangle containing a_pt. If XM_NONE is returned then no triangle contained the point.

Definition at line 394 of file GmTriSearch.cpp.

References FindTriangle().

Referenced by TriSearchUnitTests::testSmsCase1(), and TriSearchUnitTests::testTouch().

◆ TriEnvelopesOverlap()

void xms::GmTriSearchImpl::TriEnvelopesOverlap ( const Pt3d a_pMin,
const Pt3d a_pMax,
std::vector< int > &  a_tris 
)
overridevirtual

Find all triangles whose envelope overlaps the envelope defined by a_pMin and a_pMax.

Parameters
a_pMinmin x,y location of the box
a_pMaxmax x,y location of the box
a_trisThe indices to triangles whose envelope intersects with the input envelope.

Definition at line 426 of file GmTriSearch.cpp.

References m_rTree, and xms::Pt3< T >::z.

Referenced by TriSearchUnitTests::testTriEnvelopesOverlap().

◆ TriEnvelopsContainingPt()

void xms::GmTriSearchImpl::TriEnvelopsContainingPt ( const Pt3d a_pt,
std::vector< int > &  a_tris 
)
overridevirtual

Find all triangles whose envelope contains the point.

Parameters
a_ptLocation used to find a triangle.
a_trisThe indices to triangles whose envelop contains the point

Definition at line 405 of file GmTriSearch.cpp.

References m_rTree, xms::Pt3< T >::x, and xms::Pt3< T >::y.

◆ TrisToSearch()

void xms::GmTriSearchImpl::TrisToSearch ( BSHP< std::vector< Pt3d >>  a_pts,
BSHP< std::vector< int >>  a_tris 
)
overridevirtual

Adds the triangles to the class.

Parameters
a_ptsArray of point locations.
a_trisArray of triangles that references the a_pts array. This array will have a size that is a multiple of 3. The first 3 locations in array represent the first triangle and will have indices that correspond to locations in the a_pts array.

Definition at line 266 of file GmTriSearch.cpp.

References CreateRTree(), m_cache, m_pts, m_rTree, and m_tris.

Referenced by TriSearchUnitTests::testSmsCase1(), TriSearchUnitTests::testTouch(), and TriSearchUnitTests::testTriEnvelopesOverlap().

Member Data Documentation

◆ m_cache

boost::unordered_map<size_t, BarycentricVals> xms::GmTriSearchImpl::m_cache

we create a cache of these for faster interp the second time we hit the triangle

Definition at line 173 of file GmTriSearch.cpp.

Referenced by GetTriBarycentricVals(), and TrisToSearch().


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