xmsmesh  1.0
MePolyPts.cpp File Reference

Go to the source code of this file.

Classes

class  xms::MePolyPts::impl
 Implementation of MePolyPts. More...
 

Macros

#define T_TOL   1e-13
 tolerance used in multipoly intersector
 

Typedefs

typedef std::map< size_t, std::multimap< double, size_t > > xms::SegMap
 map for segment intersection indices
 
typedef std::map< const std::vector< size_t > *, SegMap > xms::MapSegMap
 map used to see where segments cross each other
 

Functions

static size_t xms::iNextSegIdx (size_t a_i, const std::vector< size_t > &a_seg)
 Get the next index for a segment. The segments are stored as a vector and it forms a closed loop so the last item in the vector makes a segment with the first item in the vector. More...
 
static void xms::iAddIntersection (size_t a_i, const std::vector< size_t > &a_iSeg, size_t a_j, double a_t, MapSegMap &a_mapSegCross)
 Adds an intersection to a map of intersection information. More...
 
static void xms::iHashPts (std::vector< size_t > &a_newIdx, BSHP< std::vector< Pt3d >> a_pts, double a_xyTol)
 hash the points and fill in a vector with the new index assigned to each point. If there are no duplicates the a_newIdx will be 0,1,2,3,4 If there are duplicates then a_newIdx will be 0,1,0,1,4,5,0... More...
 
static std::vector< GmBstBox3dxms::iCalcSegEnvelopes (const std::vector< size_t > &a_segs, const std::vector< Pt3d > &a_pts)
 Returns the envelopes of the segments. More...
 
static bool xms::iEnvelopesOverlapOrTouch (size_t a_i, size_t a_j, const std::vector< GmBstBox3d > &a_iEnv, const std::vector< GmBstBox3d > &a_jEnv)
 Returns true if the envelopes overlap or touch. More...
 
static double xms::iCalcIntersectionT (const Pt3d &a_p0, const Pt3d &a_p1, Pt3d &a_iPt, double a_xyTol)
 Computes the T value for the point on the line a_p0, a_p1. More...
 
static bool xms::iCheckSharedPtIdx (size_t a_i, size_t a_j, const std::vector< size_t > &a_iSeg, const std::vector< size_t > &a_jSeg, const std::vector< Pt3d > &a_pts, double a_xyTol, MapSegMap &a_mapSegCross)
 Check segments to see if they share a point index. More...
 
static bool xms::iIntersectTwoSegments (const Pt3d &a_s1p0, const Pt3d &a_s1p1, const Pt3d &a_s2p0, const Pt3d &a_s2p1, double a_xyTol, std::vector< Pt3d > &a_pts)
 Intersects 2 segments. Normally there is only 1 intersection between 2 segments but if the lines are colinear and they overlap then we get the endpoint of the overlap as the intersection points. More...
 
static void xms::iCheckIntersection (size_t a_i, size_t a_j, const std::vector< size_t > &a_iSeg, const std::vector< size_t > &a_jSeg, BSHP< std::vector< Pt3d >> &a_shptrPts, double a_xyTol, MapSegMap &a_mapSegCross, BSHP< GmPtSearch > a_ps)
 Sees if 2 segments intersects and if they do then information is added to the a_mapSegCross. More...
 
static bool xms::iPolyInsideOfPoly (const GmBstPoly3d &a_poly, const std::vector< size_t > &a_polyToTest, const std::vector< Pt3d > &a_pts)
 Returns true if a polygon is inside of another polygon. More...
 
static void xms::iFindPolysInsideOfOtherPolys (std::vector< std::vector< size_t >> &a_polyInsideOfPoly, std::list< std::vector< size_t >> &a_loops, MePolyPts &a_polyPts)
 Given a list of polygons, finds the polygons that are inside of other polygons. More...
 
static std::vector< double > xms::iCalcPolyAreas (const std::list< std::vector< size_t >> &a_loops, const std::vector< Pt3d > &a_pts)
 Calculates polygon areas. More...
 
static void xms::iRemoveRepeatedSegmentFromSequence (std::list< size_t > &a_sequence)
 Removes a repeated segment (2 numbers) from a sequence. More...
 

Detailed Description

Definition in file MePolyPts.cpp.

Function Documentation

◆ iAddIntersection()

static void xms::iAddIntersection ( size_t  a_i,
const std::vector< size_t > &  a_iSeg,
size_t  a_j,
double  a_t,
MapSegMap a_mapSegCross 
)
static

Adds an intersection to a map of intersection information.

Parameters
a_iIndex for a segment.
a_iSegVector of segments that a_i refers to.
a_jIndex for a point location.
a_tParametric value for the location of point a_j along segment a_i.
a_mapSegCrossMap that holds information about intersections of line segments.

Definition at line 101 of file MePolyPts.cpp.

References xms::iAddIntersection().

Referenced by xms::iAddIntersection(), xms::iCheckIntersection(), and xms::iCheckSharedPtIdx().

◆ iCalcIntersectionT()

static double xms::iCalcIntersectionT ( const Pt3d a_p0,
const Pt3d a_p1,
Pt3d a_iPt,
double  a_xyTol 
)
static

Computes the T value for the point on the line a_p0, a_p1.

Parameters
a_p0Location of the 1st point defining a line segment.
a_p1Location of the 2nd point defining a line segment.
a_iPtLocation of the intersection that lies on the line segment defined by a_p0, a_p1.
a_xyTolTolerance used in geometric calculations.
Returns
Parametric value for location of intersection.

Definition at line 211 of file MePolyPts.cpp.

References EQ_TOL(), gmEqualPointsXY(), xms::iCalcIntersectionT(), T_TOL, xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by xms::iCalcIntersectionT(), xms::iCheckIntersection(), and xms::iCheckSharedPtIdx().

◆ iCalcPolyAreas()

static std::vector<double> xms::iCalcPolyAreas ( const std::list< std::vector< size_t >> &  a_loops,
const std::vector< Pt3d > &  a_pts 
)
static

Calculates polygon areas.

Parameters
a_loops2D vector of point indexes that define polygons.
a_ptsLocations referred to by indexes in a_loops.
Returns
vector of areas, one for each polygon

Definition at line 492 of file MePolyPts.cpp.

References gmPolygonArea(), and xms::iCalcPolyAreas().

Referenced by xms::MePolyPts::ClassifyLoopsFromInPolyAndRemoveInvalid(), xms::iCalcPolyAreas(), and xms::MePolyPts::RemoveBackwardLoopsForCleanPolyOffset().

◆ iCalcSegEnvelopes()

static std::vector<GmBstBox3d> xms::iCalcSegEnvelopes ( const std::vector< size_t > &  a_segs,
const std::vector< Pt3d > &  a_pts 
)
static

Returns the envelopes of the segments.

Parameters
a_segsVector of indexes defining the segments. This is a closed loop polyline the first point connects to the last point in the vector.
a_ptsVector of locations referenced by the indexes in a_segs.
Returns
vector of envelopes, one for each segment

Definition at line 154 of file MePolyPts.cpp.

References xms::iCalcSegEnvelopes(), xms::iNextSegIdx(), xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by xms::iCalcSegEnvelopes(), and xms::MePolyPts::IntersectSegs().

◆ iCheckIntersection()

static void xms::iCheckIntersection ( size_t  a_i,
size_t  a_j,
const std::vector< size_t > &  a_iSeg,
const std::vector< size_t > &  a_jSeg,
BSHP< std::vector< Pt3d >> &  a_shptrPts,
double  a_xyTol,
MapSegMap a_mapSegCross,
BSHP< GmPtSearch a_ps 
)
static

Sees if 2 segments intersects and if they do then information is added to the a_mapSegCross.

Parameters
a_iIndex to a segment.
a_jIndex to a segment.
a_iSegVector of segments referred to by a_i.
a_jSegVector of segments referred to by a_j.
a_shptrPtsVector of point locations. The segments just store indexes that refer to locations in this vector.
a_xyTolTolerance used in geometric calculations.
a_mapSegCrossMap of intersection information.
a_psA PtSearch class. Will hash newly calculated locations with existing point locations.

segment are sorted correctly

Definition at line 348 of file MePolyPts.cpp.

References xms::iAddIntersection(), xms::iCalcIntersectionT(), xms::iCheckIntersection(), xms::iCheckSharedPtIdx(), xms::iIntersectTwoSegments(), xms::iNextSegIdx(), and XM_ASSERT.

Referenced by xms::MePolyPts::CheckIntersectTwoSegs(), and xms::iCheckIntersection().

◆ iCheckSharedPtIdx()

static bool xms::iCheckSharedPtIdx ( size_t  a_i,
size_t  a_j,
const std::vector< size_t > &  a_iSeg,
const std::vector< size_t > &  a_jSeg,
const std::vector< Pt3d > &  a_pts,
double  a_xyTol,
MapSegMap a_mapSegCross 
)
static

Check segments to see if they share a point index.

Parameters
a_iIndex to a segment.
a_jIndex to a segment.
a_iSegVector of segments referred to by a_i.
a_jSegVector of segments referred to by a_j.
a_ptsVector of point locations. The segments just store indexes that refer to locations in this vector.
a_xyTolTolerance used in geometric calculations.
a_mapSegCrossMap of intersection information.
Returns
true if the segments share a point

Definition at line 248 of file MePolyPts.cpp.

References gmOnLineAndBetweenEndpointsWithTol(), xms::iAddIntersection(), xms::iCalcIntersectionT(), xms::iCheckSharedPtIdx(), xms::iNextSegIdx(), xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by xms::iCheckIntersection(), and xms::iCheckSharedPtIdx().

◆ iEnvelopesOverlapOrTouch()

static bool xms::iEnvelopesOverlapOrTouch ( size_t  a_i,
size_t  a_j,
const std::vector< GmBstBox3d > &  a_iEnv,
const std::vector< GmBstBox3d > &  a_jEnv 
)
static

Returns true if the envelopes overlap or touch.

Parameters
a_iIndex of an envelope of a segment.
a_jIndex of an envelope of a segment.
a_iEnvVector of envelopes referenced by a_i.
a_jEnvVector of envelopes referenced by a_j.
Returns
true if the envelopes overlap or touch

Definition at line 191 of file MePolyPts.cpp.

References xms::iEnvelopesOverlapOrTouch(), xms::Pt3< T >::x, and xms::Pt3< T >::y.

Referenced by xms::iEnvelopesOverlapOrTouch(), and xms::MePolyPts::IntersectSegs().

◆ iFindPolysInsideOfOtherPolys()

static void xms::iFindPolysInsideOfOtherPolys ( std::vector< std::vector< size_t >> &  a_polyInsideOfPoly,
std::list< std::vector< size_t >> &  a_loops,
MePolyPts a_polyPts 
)
static

Given a list of polygons, finds the polygons that are inside of other polygons.

Parameters
a_polyInsideOfPoly2D vector of polygon indexes.
a_loops2D vector of point indexes that define polygons.
a_polyPtsClass with information on locations of points that define the polygons.

Definition at line 453 of file MePolyPts.cpp.

References xms::iFindPolysInsideOfOtherPolys(), xms::iPolyInsideOfPoly(), and xms::MePolyPts::Pts().

Referenced by xms::MePolyPts::ClassifyLoopsFromInPolyAndRemoveInvalid(), and xms::iFindPolysInsideOfOtherPolys().

◆ iHashPts()

static void xms::iHashPts ( std::vector< size_t > &  a_newIdx,
BSHP< std::vector< Pt3d >>  a_pts,
double  a_xyTol 
)
static

hash the points and fill in a vector with the new index assigned to each point. If there are no duplicates the a_newIdx will be 0,1,2,3,4 If there are duplicates then a_newIdx will be 0,1,0,1,4,5,0...

Parameters
a_newIdxVector of new indexes for points.
a_ptsVector of point locations.
a_xyTolTolerance used to determine if 2 locations should be considered the same location.

Definition at line 121 of file MePolyPts.cpp.

References xms::iHashPts(), and xms::GmPtSearch::New().

Referenced by xms::MePolyPts::HashPts(), and xms::iHashPts().

◆ iIntersectTwoSegments()

static bool xms::iIntersectTwoSegments ( const Pt3d a_s1p0,
const Pt3d a_s1p1,
const Pt3d a_s2p0,
const Pt3d a_s2p1,
double  a_xyTol,
std::vector< Pt3d > &  a_pts 
)
static

Intersects 2 segments. Normally there is only 1 intersection between 2 segments but if the lines are colinear and they overlap then we get the endpoint of the overlap as the intersection points.

Parameters
a_s1p0Location of 1st point on segment 1.
a_s1p1Location of 2nd point on segment 1.
a_s2p0Location of 1st point on segment 2.
a_s2p1Location of 2nd point on segment 2.
a_xyTolTolerance used in geometric calculations.
a_ptsLocations of intersections between 2 segments.
Returns
true if the segments intersect

Definition at line 291 of file MePolyPts.cpp.

References EQ_TOL(), gmIntersectLineSegmentsWithTol(), gmOnLineAndBetweenEndpointsWithTol(), xms::iIntersectTwoSegments(), T_TOL, xms::Pt3< T >::x, xms::Pt3< T >::y, and xms::Pt3< T >::z.

Referenced by xms::iCheckIntersection(), and xms::iIntersectTwoSegments().

◆ iNextSegIdx()

static size_t xms::iNextSegIdx ( size_t  a_i,
const std::vector< size_t > &  a_seg 
)
static

Get the next index for a segment. The segments are stored as a vector and it forms a closed loop so the last item in the vector makes a segment with the first item in the vector.

Parameters
a_iIndex into the vector a_seg.
a_segVector of indexes that make up a closed loop polyline.
Returns
index to the next segment index

Definition at line 85 of file MePolyPts.cpp.

References xms::iNextSegIdx().

Referenced by xms::iCalcSegEnvelopes(), xms::iCheckIntersection(), xms::iCheckSharedPtIdx(), and xms::iNextSegIdx().

◆ iPolyInsideOfPoly()

static bool xms::iPolyInsideOfPoly ( const GmBstPoly3d a_poly,
const std::vector< size_t > &  a_polyToTest,
const std::vector< Pt3d > &  a_pts 
)
static

Returns true if a polygon is inside of another polygon.

Parameters
a_polyA polygon used to test a_polyToTest
a_polyToTestVector of indices defining a polygon. Want to determine if it is inside of a_poly.
a_ptsVector of locations referenced by a_polyToTest.
Returns
true if a_polyToTest is inside of a_poly

Definition at line 430 of file MePolyPts.cpp.

References xms::iPolyInsideOfPoly().

Referenced by xms::iFindPolysInsideOfOtherPolys(), xms::iPolyInsideOfPoly(), and xms::MePolyPts::PolyInsideOfPoly().

◆ iRemoveRepeatedSegmentFromSequence()

static void xms::iRemoveRepeatedSegmentFromSequence ( std::list< size_t > &  a_sequence)
static

Removes a repeated segment (2 numbers) from a sequence.

Parameters
a_sequenceList of indexes defining a closed loop polyline.

Definition at line 511 of file MePolyPts.cpp.

References xms::iRemoveRepeatedSegmentFromSequence().

Referenced by xms::MePolyPts::CalcLoopsForCleanPolyOffset(), and xms::iRemoveRepeatedSegmentFromSequence().