xmsgeom  1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
xms::GmMultiPolyIntersectionSorterTerse Class Reference

Class for sorting intersections from GmMultiPolyIntersector in a terse way (with no duplicate info). More...

Inheritance diagram for xms::GmMultiPolyIntersectionSorterTerse:
xms::GmMultiPolyIntersectionSorter

Public Member Functions

virtual void Sort (GmMultiPolyIntersectorData &a_data, std::vector< int > &polyids, std::vector< double > &tvalues, std::vector< Pt3d > &a_pts, double a_tol) override
 Sort the intersections, remove redundant info. More...
 

Private Member Functions

void RemoveCornerTouches ()
 Remove polys that only touch the line at a corner. We try to identify these corner polys using the following criteria: More...
 
void RemoveDuplicateEdges ()
 If the line goes along an edge we may have polygons on both sides of the edge. Perhaps we want only the polygons on one side .... ?
 
void SwapAdjacents ()
 Swap adjacent identical intersections if necessary.
 
void IntersectionsToPolyIdsAndTValuesFor2 (std::vector< int > &polyids, std::vector< double > &tvalues, std::vector< Pt3d > &a_pts) const
 Copy intersections to polyids and tvalues when there are 2 intersections. More...
 
void IntersectionsToPolyIdsAndTValuesFor3OrMore (std::vector< int > &polyids, std::vector< double > &tvalues, std::vector< Pt3d > &a_pts) const
 Copy intersections to polyids and tvalues when there are 3 or more intersections. More...
 
void IntersectionsToPolyIdsAndTValues (std::vector< int > &polyids, std::vector< double > &tvalues, std::vector< Pt3d > &a_pts) const
 Copy intersections to polyids and tvalues, removing duplicates. More...
 
void FixArrays (std::vector< int > &polyids, std::vector< double > &tvalues, std::vector< Pt3d > &a_pts) const
 Make sure we always have at least two tvalues, an entrance and an exit, and that the last polyid = -1. More...
 
void AddToPolyIdsAndTValues (const ix &a_ix, std::vector< int > &polyids, std::vector< double > &tvalues, std::vector< Pt3d > &a_pts) const
 Add the intersection info to the arrays. More...
 
void FindPreviousNextNeither (const std::vector< int > &tChange, const int idx, std::vector< int > *inPrev, std::vector< int > *inNext, std::vector< int > *inNeither) const
 Look at each poly in this set of t values and see if it exists in the previous or next set of t values. More...
 
void Swap (int a, int b)
 Swap the order of the intersections a and b. More...
 
void FindWhereTValuesChange (std::vector< int > &tChange) const
 Mark where we have a change in t values. More...
 

Private Attributes

GmMultiPolyIntersectorDatam_d
 Intersection data from GmMultiPolyIntersector.
 
double m_tol
 Tolerance used when comparing t values.
 

Detailed Description

Class for sorting intersections from GmMultiPolyIntersector in a terse way (with no duplicate info).

This class removes corner touches, duplicate edges (by keeping the one on the right), and, ... well it's hard to define what it does here but suffice it to say that it causes all the unit tests in GmMultiPolyIntersector.cpp to pass.

Definition at line 32 of file GmMultiPolyIntersectionSorterTerse.h.

Member Function Documentation

void xms::GmMultiPolyIntersectionSorterTerse::AddToPolyIdsAndTValues ( const ix a_ix,
std::vector< int > &  polyids,
std::vector< double > &  tvalues,
std::vector< Pt3d > &  a_pts 
) const
private

Add the intersection info to the arrays.

Parameters
[in]a_ixIntersection info.
[in,out]polyidsIntersected polygons.
[in,out]tvaluesPercent distance (0.0 - 1.0) from beginning of line segment to each intersection.
[in,out]a_ptsPoints of intersection.

Definition at line 405 of file GmMultiPolyIntersectionSorterTerse.cpp.

References xms::ix::m_i, xms::ix::m_pt, and xms::ix::m_t.

Referenced by IntersectionsToPolyIdsAndTValuesFor2(), and IntersectionsToPolyIdsAndTValuesFor3OrMore().

void xms::GmMultiPolyIntersectionSorterTerse::FindPreviousNextNeither ( const std::vector< int > &  tChange,
const int  idx,
std::vector< int > *  inPrev,
std::vector< int > *  inNext,
std::vector< int > *  inNeither 
) const
private

Look at each poly in this set of t values and see if it exists in the previous or next set of t values.

Parameters
tChange
idxindex
inPrev= indices into m_ix of intersections in this group that also appear in the previous group.
inNext= indices into m_ix of intersections in this group that also appear in the next group.
inNeither= indices into m_ix of intersections in this group that don't appear in the previous or next group.

Definition at line 425 of file GmMultiPolyIntersectionSorterTerse.cpp.

References m_d, and xms::GmMultiPolyIntersectorData::m_ixs.

Referenced by IntersectionsToPolyIdsAndTValuesFor3OrMore(), RemoveCornerTouches(), and RemoveDuplicateEdges().

void xms::GmMultiPolyIntersectionSorterTerse::FindWhereTValuesChange ( std::vector< int > &  tChange) const
private

Mark where we have a change in t values.

Parameters
tChangeWhere tvalues change.

Definition at line 486 of file GmMultiPolyIntersectionSorterTerse.cpp.

References xms::EQ_TOL(), m_d, xms::GmMultiPolyIntersectorData::m_ixs, and m_tol.

Referenced by IntersectionsToPolyIdsAndTValuesFor3OrMore(), RemoveCornerTouches(), and RemoveDuplicateEdges().

void xms::GmMultiPolyIntersectionSorterTerse::FixArrays ( std::vector< int > &  polyids,
std::vector< double > &  tvalues,
std::vector< Pt3d > &  a_pts 
) const
private

Make sure we always have at least two tvalues, an entrance and an exit, and that the last polyid = -1.

Parameters
polyidsPoly IDs.
tvaluestvalues.
a_ptsPoint list.

Definition at line 364 of file GmMultiPolyIntersectionSorterTerse.cpp.

References m_d, xms::GmMultiPolyIntersectorData::m_polys2, and XM_ENSURE_TRUE_VOID_NO_ASSERT.

Referenced by Sort().

void xms::GmMultiPolyIntersectionSorterTerse::IntersectionsToPolyIdsAndTValues ( std::vector< int > &  polyids,
std::vector< double > &  tvalues,
std::vector< Pt3d > &  a_pts 
) const
private

Copy intersections to polyids and tvalues, removing duplicates.

Parameters
polyidsPoly IDs.
tvaluestvalues.
a_ptsPoints.

Definition at line 331 of file GmMultiPolyIntersectionSorterTerse.cpp.

References IntersectionsToPolyIdsAndTValuesFor2(), IntersectionsToPolyIdsAndTValuesFor3OrMore(), m_d, xms::GmMultiPolyIntersectorData::m_ixs, and XM_ENSURE_TRUE_VOID_NO_ASSERT.

Referenced by Sort().

void xms::GmMultiPolyIntersectionSorterTerse::IntersectionsToPolyIdsAndTValuesFor2 ( std::vector< int > &  polyids,
std::vector< double > &  tvalues,
std::vector< Pt3d > &  a_pts 
) const
private

Copy intersections to polyids and tvalues when there are 2 intersections.

Parameters
polyidsPoly IDs.
tvaluestvalues.
a_ptsPoints.

Definition at line 218 of file GmMultiPolyIntersectionSorterTerse.cpp.

References AddToPolyIdsAndTValues(), xms::EQ_EPS(), m_d, xms::GmMultiPolyIntersectorData::m_ixs, xms::GmMultiPolyIntersectorData::m_polys1, and xms::GmMultiPolyIntersectorData::m_polys2.

Referenced by IntersectionsToPolyIdsAndTValues().

void xms::GmMultiPolyIntersectionSorterTerse::IntersectionsToPolyIdsAndTValuesFor3OrMore ( std::vector< int > &  polyids,
std::vector< double > &  tvalues,
std::vector< Pt3d > &  a_pts 
) const
private

Copy intersections to polyids and tvalues when there are 3 or more intersections.

Parameters
polyidsPoly IDs.
tvaluestvalues.
a_ptsPoints.

Definition at line 249 of file GmMultiPolyIntersectionSorterTerse.cpp.

References AddToPolyIdsAndTValues(), FindPreviousNextNeither(), FindWhereTValuesChange(), m_d, xms::GmMultiPolyIntersectorData::m_ixs, and XM_ENSURE_TRUE_VOID_NO_ASSERT.

Referenced by IntersectionsToPolyIdsAndTValues().

void xms::GmMultiPolyIntersectionSorterTerse::RemoveCornerTouches ( )
private

Remove polys that only touch the line at a corner. We try to identify these corner polys using the following criteria:

  1. There are > 1 intersection with the same t value.
  2. The corner poly doesn't appear in the previous or next group of intersections that have the same t values.

Definition at line 83 of file GmMultiPolyIntersectionSorterTerse.cpp.

References FindPreviousNextNeither(), FindWhereTValuesChange(), m_d, xms::GmMultiPolyIntersectorData::m_ixs, and XM_ENSURE_TRUE_VOID_NO_ASSERT.

Referenced by Sort().

void xms::GmMultiPolyIntersectionSorterTerse::Sort ( GmMultiPolyIntersectorData a_data,
std::vector< int > &  polyids,
std::vector< double > &  tvalues,
std::vector< Pt3d > &  a_pts,
double  a_tol 
)
overridevirtual

Sort the intersections, remove redundant info.

Parameters
[in,out]a_dataThe intersection data from GmMultiPolyIntersector.
[out]polyidsIntersected polygons.
[out]tvaluesPercent distance (0.0 - 1.0) from segment starting location to all intersections.
[out]a_ptsPoints of intersection.
[in]a_tolTolerance used when comparing t values.

Definition at line 65 of file GmMultiPolyIntersectionSorterTerse.cpp.

References FixArrays(), IntersectionsToPolyIdsAndTValues(), m_d, m_tol, RemoveCornerTouches(), RemoveDuplicateEdges(), and SwapAdjacents().

void xms::GmMultiPolyIntersectionSorterTerse::Swap ( int  a,
int  b 
)
private

Swap the order of the intersections a and b.

Parameters
[in]aAn intersection.
[in]bAn intersection.

Definition at line 477 of file GmMultiPolyIntersectionSorterTerse.cpp.

References m_d, and xms::GmMultiPolyIntersectorData::m_ixs.

Referenced by SwapAdjacents().


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