|
xmsgeom
1.0
|
Used to intersect a line segment with any number of polygons in 2D. Returns the intersected polygons in order along with t values. May be an alternative to SurfaceIter and feiTraverseLineSegment2. More...
Public Member Functions | |
| GmMultiPolyIntersectorImpl (const VecPt3d &a_points, const VecInt2d &a_polys, BSHP< GmMultiPolyIntersectionSorter > a_sorter, int a_startingId=1) | |
| constructor More... | |
| virtual void | SetQuery (GmMultiPolyIntersectorQueryEnum a_query) override |
| Set the query to use (covered by, intersects...). More... | |
| virtual void | TraverseLineSegment (double x1, double y1, double x2, double y2, VecInt &polyids, VecDbl &tvalues) override |
| Intersect segment with polys and save intersected polys and t-values. More... | |
| virtual void | TraverseLineSegment (double x1, double y1, double x2, double y2, VecInt &polyids) override |
| Intersect segment with polys and save intersected polys. More... | |
| virtual void | TraverseLineSegment (double a_x1, double a_y1, double a_x2, double a_y2, VecInt &a_polyids, std::vector< Pt3d > &a_pts) override |
| Intersect segment with polys and save intersected polys and intersection points. More... | |
| virtual int | PolygonFromPoint (const Pt3d &a_pt) override |
| Finds the polygon containing the point. More... | |
Private Member Functions | |
| void | CalculateBuffer () |
| Calculate a small buffer distance by which we expand all polygon bounding boxes. | |
| void | BufferTheBox (GmBstBox3d &box) const |
| Because the rtree intersection fails in some cases where the line is on an edge, we slightly expand the bounding box of the poly to ensure that it comes back as a potential intersection. This may result in more false positives but until boost geometry starts working correctly, it's the best idea we've got. More... | |
| GmBstPoly3d & | GetBoostPoly (int a_polyIdx) |
| Create and return a boost polygon given a polygon index. More... | |
| void | BuildBoostPoly (int a_polyIdx, GmBstPoly3d &a_boostPoly) const |
| Build a boost polygon given a polygon index. More... | |
| void | BuildRTree () |
| Create a boost rtree of polygon extents. | |
| void | CreateLine () |
| Creates a boost geom line of the current line segment. | |
| void | GetPolysForPoint (Pt3d pt, SetInt &poly) |
| Find the set of polygons intersected (in or on) by the point. More... | |
| void | EnsureEndPointsRepresented () |
| Because unfortunately intersecting the line with the poly doesn't always create an intersection if a point is on the polygon edge. | |
| void | IntersectEachPolyWithLine () |
| Go through results (potential polygons) and intersect each one. | |
| void | ComputeTValues () |
| Compute t values (0.0 - 1.0) from the intersection. More... | |
| void | SortIntersections () |
| Does a preliminary sort of the intersections by t value. | |
| void | OffsetPolyIds (VecInt &polyIds) const |
| If polygon IDs should start at something other than 1, we handle that here. More... | |
| void | PointsOnSegment (const GmBstPoly3d &a_poly, const GmBstLine3d &a_line, std::deque< Pt3d > &a_output) |
| Check if the points on the outside of the polygon lie on the line segment. More... | |
| void | TraverseLineSegmentAll (double a_x1, double a_y1, double a_x2, double a_y2, VecInt &a_polyids, VecDbl &a_tvalues, std::vector< Pt3d > &a_pts) |
| Intersect segment with polys and save intersected polys, t-values, and intersection points. More... | |
Private Attributes | |
| GmMultiPolyIntersectorData | m_d |
| Point and poly data. | |
| Pt3d | m_pt1 |
| 1st line segment point | |
| Pt3d | m_pt2 |
| 2nd line segment point | |
| RtreeBox * | m_rtree |
| Rtree used to find polygons. | |
| GmBstLine3d | m_line |
| Current line segment. | |
| double | m_buffer |
| Small buffer around each bounding box. | |
| int | m_startingId |
| Offset if polys start at something other than one. | |
| std::vector< GmBstPoly3d > | m_boostPolys |
| Polygons as boost geom polygons. | |
|
BSHP < GmMultiPolyIntersectionSorter > | m_sorter |
| Sorter used to process results. | |
| GmMultiPolyIntersectorQueryEnum | m_query |
| Type of query (intersect, covered by...) | |
Additional Inherited Members | |
Static Public Member Functions inherited from xms::GmMultiPolyIntersector | |
| static boost::shared_ptr < GmMultiPolyIntersector > | New (const std::vector< Pt3d > &a_points, const std::vector< std::vector< int > > &a_polys, boost::shared_ptr< GmMultiPolyIntersectionSorter > a_sorter, int a_startingId=1) |
| Creates a new GmMultiPolyIntersectorImpl object. More... | |
Used to intersect a line segment with any number of polygons in 2D. Returns the intersected polygons in order along with t values. May be an alternative to SurfaceIter and feiTraverseLineSegment2.
Definition at line 61 of file GmMultiPolyIntersector.cpp.
| xms::GmMultiPolyIntersectorImpl::GmMultiPolyIntersectorImpl | ( | const VecPt3d & | a_points, |
| const VecInt2d & | a_polys, | ||
| BSHP< GmMultiPolyIntersectionSorter > | a_sorter, | ||
| int | a_startingId = 1 |
||
| ) |
constructor
| a_points | The points that make up the polygon. |
| a_polys | 0-based indexes into a_points array to define polygons. The first point is NOT repeated as the last point. |
| a_sorter | Class to clean up and sort the intersections the way you want them. |
| a_startingId | If the polygon IDs should start at something other than 1, specify the starting value. |
Definition at line 164 of file GmMultiPolyIntersector.cpp.
References BuildRTree(), CalculateBuffer(), m_boostPolys, m_d, xms::GmMultiPolyIntersectorData::m_points, and xms::GmMultiPolyIntersectorData::m_polys.
|
private |
Because the rtree intersection fails in some cases where the line is on an edge, we slightly expand the bounding box of the poly to ensure that it comes back as a potential intersection. This may result in more false positives but until boost geometry starts working correctly, it's the best idea we've got.
| box | The box. |
Definition at line 227 of file GmMultiPolyIntersector.cpp.
References m_buffer.
Referenced by BuildRTree().
|
private |
Build a boost polygon given a polygon index.
| a_polyIdx | The polygon index. |
| a_boostPoly | GmBstPoly3d. |
Definition at line 250 of file GmMultiPolyIntersector.cpp.
References m_d, xms::GmMultiPolyIntersectorData::m_points, and xms::GmMultiPolyIntersectorData::m_polys.
Referenced by GetBoostPoly().
|
private |
Compute t values (0.0 - 1.0) from the intersection.
t values are the percent (0.0 - 1.0) distance from the line segment start to each intersection.
Definition at line 394 of file GmMultiPolyIntersector.cpp.
References m_d, xms::GmMultiPolyIntersectorData::m_ixs, m_pt1, m_pt2, and XM_NODATA.
Referenced by TraverseLineSegmentAll().
|
private |
Create and return a boost polygon given a polygon index.
| a_polyIdx | The polygon index. |
Definition at line 238 of file GmMultiPolyIntersector.cpp.
References BuildBoostPoly(), and m_boostPolys.
Referenced by GetPolysForPoint(), and IntersectEachPolyWithLine().
Find the set of polygons intersected (in or on) by the point.
| pt | point loction |
| a_poly | 1-based polygon ID. |
Definition at line 310 of file GmMultiPolyIntersector.cpp.
References GetBoostPoly(), m_query, m_rtree, and XM_ASSERT.
Referenced by PolygonFromPoint(), and TraverseLineSegmentAll().
|
private |
If polygon IDs should start at something other than 1, we handle that here.
| polyIds | 1-based list of polygons intersected by line segment. |
Definition at line 449 of file GmMultiPolyIntersector.cpp.
References m_startingId, and XM_NONE.
Referenced by TraverseLineSegmentAll().
|
private |
Check if the points on the outside of the polygon lie on the line segment.
| a_poly | GmBstPoly3d. |
| a_line | GmBstLine3d. |
| a_output | Output. |
Definition at line 369 of file GmMultiPolyIntersector.cpp.
References m_buffer, xms::Pt3< T >::x, and xms::Pt3< T >::y.
Referenced by IntersectEachPolyWithLine().
|
overridevirtual |
Finds the polygon containing the point.
| a_pt | the location of the point |
Definition at line 519 of file GmMultiPolyIntersector.cpp.
References GetPolysForPoint(), and XM_NONE.
|
overridevirtual |
Set the query to use (covered by, intersects...).
| a_query | GmMultiPolyIntersectorQueryEnum |
Definition at line 301 of file GmMultiPolyIntersector.cpp.
References m_query.
|
overridevirtual |
Intersect segment with polys and save intersected polys and t-values.
| x1 | x coordinate of 1st point defining a line segment. |
| y1 | y coordinate of 1st point defining a line segment. |
| x2 | x coordinate of 2nd point defining a line segment. |
| y2 | y coordinate of 2nd point defining a line segment. |
| polyids | 1-based list of polygons intersected by line segment. |
| tvalues | Values from 0.0 to 1.0 representing where on the line segment the intersection with the polygon in polyids occurs. If there are any t values there are always at least 2 and all represent where the line enters the polygon, except the last which represents where it exited. There would therefore be one more t value than poly id but we make the sizes equal by always making the last poly id -1. |
Definition at line 475 of file GmMultiPolyIntersector.cpp.
References TraverseLineSegmentAll().
|
overridevirtual |
Intersect segment with polys and save intersected polys.
| x1 | x coordinate of 1st point defining a line segment. |
| y1 | y coordinate of 1st point defining a line segment. |
| x2 | x coordinate of 2nd point defining a line segment. |
| y2 | y coordinate of 2nd point defining a line segment. |
| polyids | 1-based list of polygons intersected by line segment. |
Definition at line 490 of file GmMultiPolyIntersector.cpp.
References TraverseLineSegmentAll().
|
overridevirtual |
Intersect segment with polys and save intersected polys and intersection points.
| a_x1 | x coordinate of 1st point defining a line segment. |
| a_y1 | y coordinate of 1st point defining a line segment. |
| a_x2 | x coordinate of 2nd point defining a line segment. |
| a_y2 | y coordinate of 2nd point defining a line segment. |
| a_polyids | 1-based list of polygons intersected by line segment. |
| a_pts | Intersection points. |
Definition at line 507 of file GmMultiPolyIntersector.cpp.
References TraverseLineSegmentAll().
|
private |
Intersect segment with polys and save intersected polys, t-values, and intersection points.
| a_x1 | x coordinate of 1st point defining a line segment. |
| a_y1 | y coordinate of 1st point defining a line segment. |
| a_x2 | x coordinate of 2nd point defining a line segment. |
| a_y2 | y coordinate of 2nd point defining a line segment. |
| a_polyids | 1-based list of polygons intersected by line segment. |
| a_tvalues | Values from 0.0 to 1.0 representing where on the line segment the intersection with the polygon in polyids occurs. If there are any t values there are always at least 2 and all represent where the line enters the polygon, except the last which represents where it exited. There would therefore be one more t value than poly id but we make the sizes equal by always making the last poly id -1. |
| a_pts | Intersection points. |
Definition at line 546 of file GmMultiPolyIntersector.cpp.
References ComputeTValues(), CreateLine(), EnsureEndPointsRepresented(), GetPolysForPoint(), IntersectEachPolyWithLine(), m_d, xms::GmMultiPolyIntersectorData::m_ixs, m_line, xms::GmMultiPolyIntersectorData::m_polys1, xms::GmMultiPolyIntersectorData::m_polys2, m_pt1, m_pt2, m_sorter, OffsetPolyIds(), xms::Pt3< T >::Set(), SortIntersections(), and XM_ASSERT.
Referenced by TraverseLineSegment().