xmsgrid  1.0
xms::GmPolygonImpl Class Reference

Wraps a boost polygon for point in poly, min distance from point to poly etc. More...

Inheritance diagram for xms::GmPolygonImpl:
xms::GmPolygon

Public Member Functions

 GmPolygonImpl ()
 Constructor.
 
virtual void Setup (const VecPt3d &a_poly, const VecPt3d2d &a_inPolys) override
 Create a boost geometry polygon to use in point in polygon. More...
 
virtual void GetPoints (VecPt3d &a_poly, VecPt3d2d &a_inPolys) const override
 Get the points from a boost polygon as vectors of Pt3d. More...
 
virtual bool CoveredBy (Pt3d a_point) const override
 Tests if a_point is inside or on the polygon and not in a hole. More...
 
virtual bool Within (Pt3d a_point) const override
 Tests if a_point is inside the polygon and not in a hole. More...
 
virtual double MinDistanceToBoundary (Pt3d a_pt) const override
 Computes the min distance from a point to a polygon. More...
 
virtual void Intersection (const GmPolygon &a_, std::vector< BSHP< GmPolygon >> &a_out) const override
 Performs a polygon intersection. More...
 
virtual void Union (const GmPolygon &a_, std::vector< BSHP< GmPolygon >> &a_out) const override
 Performs a polygon union. More...
 
- Public Member Functions inherited from xms::GmPolygon
 GmPolygon ()
 Constructor.
 
virtual ~GmPolygon ()
 Destructor.
 

Private Attributes

GmBstPoly3d m_poly
 The boost geom polygon.
 

Additional Inherited Members

- Static Public Member Functions inherited from xms::GmPolygon
static BSHP< GmPolygonNew ()
 Creates a class. More...
 

Detailed Description

Wraps a boost polygon for point in poly, min distance from point to poly etc.

gmPointInPolygon2D is faster, but if you need a boost polygon, consider using this class. This class is best if being used repeatedly for the same polygon as it takes time for setup due to it being allocated on the heap and creating a boost polygon under the hood, but the methods can then be called repeatedly at speed.

See also
EFastPointInPoly
gmPointInPolygon2D

Definition at line 44 of file GmPolygon.cpp.

Member Function Documentation

◆ CoveredBy()

bool xms::GmPolygonImpl::CoveredBy ( Pt3d  a_point) const
overridevirtual

Tests if a_point is inside or on the polygon and not in a hole.

Parameters
a_pointThe location to test.
Returns
true if inside or on.

gmPointInPolygon2D is faster.

See also
EFastPointInPoly
gmPointInPolygon2D

Definition at line 168 of file GmPolygon.cpp.

References m_poly.

◆ GetPoints()

void xms::GmPolygonImpl::GetPoints ( VecPt3d a_outPoly,
VecPt3d2d a_inPolys 
) const
overridevirtual

Get the points from a boost polygon as vectors of Pt3d.

Parameters
a_outPolyOuter polygon, clockwise.
a_inPolysInner polygons (if any), counter clockwise.

Definition at line 149 of file GmPolygon.cpp.

References m_poly.

◆ Intersection()

void xms::GmPolygonImpl::Intersection ( const GmPolygon a_,
std::vector< BSHP< GmPolygon >> &  a_out 
) const
overridevirtual

Performs a polygon intersection.

Parameters
a_Another polygon to do the intersection operation with
a_outVector of polygons created from the intersection operation

Definition at line 219 of file GmPolygon.cpp.

References m_poly, xms::GmPolygon::New(), and XM_ENSURE_TRUE.

◆ MinDistanceToBoundary()

double xms::GmPolygonImpl::MinDistanceToBoundary ( Pt3d  a_pt) const
overridevirtual

Computes the min distance from a point to a polygon.

Parameters
a_ptThe location from which the minimum distance is calculated.
Returns
the distance

Definition at line 202 of file GmPolygon.cpp.

References xms::iDistanceToRing(), and m_poly.

Referenced by GmPolygonUnitTests::testMinDistanceToBoundary().

◆ Setup()

void xms::GmPolygonImpl::Setup ( const VecPt3d a_outPoly,
const VecPt3d2d a_inPolys 
)
overridevirtual

Create a boost geometry polygon to use in point in polygon.

The first point should be repeated as the last point but if not, it will get fixed automatically. Also, if the orientation of the polygons is not correct, it is automatically corrected.

Parameters
a_outPolyOuter polygon, clockwise.
a_inPolysInner polygons (if any), counter clockwise.

Definition at line 116 of file GmPolygon.cpp.

References m_poly.

Referenced by GmPolygonUnitTests::testMinDistanceToBoundary().

◆ Union()

void xms::GmPolygonImpl::Union ( const GmPolygon a_,
std::vector< BSHP< GmPolygon >> &  a_out 
) const
overridevirtual

Performs a polygon union.

Parameters
a_Another polygon to do the union operation with
a_outVector of polygons created from the union operation

Definition at line 246 of file GmPolygon.cpp.

References m_poly, xms::GmPolygon::New(), and XM_ENSURE_TRUE.

◆ Within()

bool xms::GmPolygonImpl::Within ( Pt3d  a_point) const
overridevirtual

Tests if a_point is inside the polygon and not in a hole.

Parameters
a_pointThe location to test.
Returns
true if inside.

gmPointInPolygon2D is faster.

See also
EFastPointInPoly
gmPointInPolygon2D

Definition at line 187 of file GmPolygon.cpp.

References m_poly.


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