xmsgrid  1.0
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 FixTValueAtDuplicateXy ()
 The t-value at the same point should be the same, but it can be off in the floating point representation. This makes them the same to prevent too many points from being removed in RemoveCornerTouches.
 
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 AddMissingEndpointIds (const std::vector< int > &a_tChange)
 Add endpoint polygon IDs that may be removed as duplicates. More...
 
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 31 of file GmMultiPolyIntersectionSorterTerse.h.

Member Function Documentation

◆ AddMissingEndpointIds()

void xms::GmMultiPolyIntersectionSorterTerse::AddMissingEndpointIds ( const std::vector< int > &  a_tChange)
private

Add endpoint polygon IDs that may be removed as duplicates.

Parameters
a_tChangeindexes of t-value changes.

Definition at line 269 of file GmMultiPolyIntersectionSorterTerse.cpp.

References m_d, xms::GmMultiPolyIntersectorData::m_ixs, xms::GmMultiPolyIntersectorData::m_polys1, xms::GmMultiPolyIntersectorData::m_polys2, and XM_ENSURE_TRUE_NO_ASSERT.

Referenced by RemoveCornerTouches().

◆ AddToPolyIdsAndTValues()

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 490 of file GmMultiPolyIntersectionSorterTerse.cpp.

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

Referenced by IntersectionsToPolyIdsAndTValuesFor2(), and IntersectionsToPolyIdsAndTValuesFor3OrMore().

◆ FindPreviousNextNeither()

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 510 of file GmMultiPolyIntersectionSorterTerse.cpp.

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

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

◆ FindWhereTValuesChange()

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 571 of file GmMultiPolyIntersectionSorterTerse.cpp.

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

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

◆ FixArrays()

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 449 of file GmMultiPolyIntersectionSorterTerse.cpp.

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

Referenced by Sort().

◆ IntersectionsToPolyIdsAndTValues()

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 416 of file GmMultiPolyIntersectionSorterTerse.cpp.

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

Referenced by Sort().

◆ IntersectionsToPolyIdsAndTValuesFor2()

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 303 of file GmMultiPolyIntersectionSorterTerse.cpp.

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

Referenced by IntersectionsToPolyIdsAndTValues().

◆ IntersectionsToPolyIdsAndTValuesFor3OrMore()

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 334 of file GmMultiPolyIntersectionSorterTerse.cpp.

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

Referenced by IntersectionsToPolyIdsAndTValues().

◆ RemoveCornerTouches()

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 115 of file GmMultiPolyIntersectionSorterTerse.cpp.

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

Referenced by Sort().

◆ 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 64 of file GmMultiPolyIntersectionSorterTerse.cpp.

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

◆ Swap()

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 562 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: