MeshKernel
Public Member Functions | List of all members
meshkernel::Polygons Class Reference

A class containing a list of polygonaly enclosed regions. More...

#include <Polygons.hpp>

Public Member Functions

 Polygons ()=default
 Default constructor.
 
 Polygons (const std::vector< Point > &polygon, Projection projection)
 Constructor. More...
 
std::tuple< UInt, UInt, UIntPolygonIndex (UInt startIndex, UInt endIndex) const
 Get index of the polygon, and map the start- and end-index to the start- and end-index of the local polygon nodes.
 
const PolygonalEnclosureEnclosure (const UInt index) const
 Get the polygonal enclosure at the index. More...
 
std::vector< std::vector< Point > > ComputePointsInPolygons () const
 Creates points inside the polygon using triangulation (the edges size determines how many points will be generated) More...
 
std::vector< PointRefineFirstPolygon (UInt startIndex, UInt endIndex, double refinementDistance) const
 Refines the polygon edges with additional nodes, from the start to the end index (refinepolygonpart) More...
 
std::vector< PointRefinePolygon (UInt polygonIndex, UInt startIndex, UInt endIndex, double refinementDistance) const
 Refines the polygon edges with additional nodes, from the start to the end index (refinepolygonpart) More...
 
std::vector< PointLinearRefinePolygon (UInt polygonIndex, UInt startIndex, UInt endIndex) const
 Linear refines the polygon edges with additional nodes, from the start to the end index. More...
 
Polygons OffsetCopy (double distance, bool innerAndOuter) const
 Makes a new polygon from an existing one, by offsetting it by a distance (copypol) More...
 
void SnapToLandBoundary (const LandBoundary &landBoundary, UInt startIndex, UInt endIndex)
 Snap the polygon to the land boundary. More...
 
bool IsPointInPolygon (Point const &point, UInt polygonIndex) const
 Checks if a point is included in a given polygon. When the polygon is empty, the point is always included by default. More...
 
bool IsPointInAnyPolygon (const Point &point) const
 Checks if a point is included in any of the polygonal enclosures contained. More...
 
std::tuple< bool, UIntIsPointInPolygons (const Point &point) const
 Checks if a point is included in any of the polygons (dbpinpol_optinside_perpol) More...
 
std::vector< bool > PointsInPolygons (const std::vector< Point > &point) const
 For each point, compute the index of the polygon including it. More...
 
bool IsEmpty () const
 Checks if the polygon is empty. More...
 
UInt GetNumPolygons () const
 Gives the number of polygons. More...
 
UInt GetNumNodes () const
 Gets the number of polygon nodes. More...
 
Projection GetProjection () const
 Gets the projection. More...
 
std::vector< PointGatherAllEnclosureNodes () const
 Gets the nodes of all enclosures.
 
BoundingBox GetBoundingBox (UInt polygonIndex) const
 Gets the bounding box for the polygon index i. More...
 

Detailed Description

A class containing a list of polygonaly enclosed regions.

Constructor & Destructor Documentation

◆ Polygons()

meshkernel::Polygons::Polygons ( const std::vector< Point > &  polygon,
Projection  projection 
)

Constructor.

Parameters
[in]polygonThe polygon nodes
[in]projectionThe projection to use

Member Function Documentation

◆ ComputePointsInPolygons()

std::vector<std::vector<Point> > meshkernel::Polygons::ComputePointsInPolygons ( ) const

Creates points inside the polygon using triangulation (the edges size determines how many points will be generated)

Returns
The generated points

◆ Enclosure()

const meshkernel::PolygonalEnclosure & meshkernel::Polygons::Enclosure ( const UInt  index) const
inline

Get the polygonal enclosure at the index.

Note
Will throw ConstraintError exception if polygons.IsEmpty = true or index is out of range

◆ GetBoundingBox()

BoundingBox meshkernel::Polygons::GetBoundingBox ( UInt  polygonIndex) const

Gets the bounding box for the polygon index i.

Parameters
[in]polygonIndexOuter polygon index
Returns
The bounding box

◆ GetNumNodes()

meshkernel::UInt meshkernel::Polygons::GetNumNodes ( ) const
inline

Gets the number of polygon nodes.

Returns
The number of polygon nodes

◆ GetNumPolygons()

meshkernel::UInt meshkernel::Polygons::GetNumPolygons ( ) const
inline

Gives the number of polygons.

Returns
Number of polygons

◆ GetProjection()

Projection meshkernel::Polygons::GetProjection ( ) const
inline

Gets the projection.

Returns
The projection

◆ IsEmpty()

bool meshkernel::Polygons::IsEmpty ( ) const

Checks if the polygon is empty.

Returns
True if it is empty, false otherwise

◆ IsPointInAnyPolygon()

bool meshkernel::Polygons::IsPointInAnyPolygon ( const Point point) const

Checks if a point is included in any of the polygonal enclosures contained.

Parameters
[in]pointThe point to check
Returns
True if it is included, false otherwise

◆ IsPointInPolygon()

bool meshkernel::Polygons::IsPointInPolygon ( Point const &  point,
UInt  polygonIndex 
) const

Checks if a point is included in a given polygon. When the polygon is empty, the point is always included by default.

Parameters
[in]pointThe point to check
[in]polygonIndexThe index of the polygon to account for
Returns
True if it is included, false otherwise

◆ IsPointInPolygons()

std::tuple<bool, UInt> meshkernel::Polygons::IsPointInPolygons ( const Point point) const

Checks if a point is included in any of the polygons (dbpinpol_optinside_perpol)

Parameters
[in]pointThe point to check
Returns
The index of a polygon where the point is included or if none has been found, constants::missing::sizetValue

◆ LinearRefinePolygon()

std::vector<Point> meshkernel::Polygons::LinearRefinePolygon ( UInt  polygonIndex,
UInt  startIndex,
UInt  endIndex 
) const

Linear refines the polygon edges with additional nodes, from the start to the end index.

Parameters
[in]polygonIndexThe polygon index
[in]startIndexThe start index for the node array for the polygon
[in]endIndexThe end index for the node array for the polygon
Returns
refinedPolygon The computed polygon

◆ OffsetCopy()

Polygons meshkernel::Polygons::OffsetCopy ( double  distance,
bool  innerAndOuter 
) const

Makes a new polygon from an existing one, by offsetting it by a distance (copypol)

Parameters
[in]distanceThe offset distance
[in]innerAndOuterOffset inwards or outward
Returns
The new offset polygon

◆ PointsInPolygons()

std::vector<bool> meshkernel::Polygons::PointsInPolygons ( const std::vector< Point > &  point) const

For each point, compute the index of the polygon including it.

Parameters
[in]pointThe vector of points
Returns
A vector of booleans to indicate if the point is in polygon

◆ RefineFirstPolygon()

std::vector<Point> meshkernel::Polygons::RefineFirstPolygon ( UInt  startIndex,
UInt  endIndex,
double  refinementDistance 
) const

Refines the polygon edges with additional nodes, from the start to the end index (refinepolygonpart)

Parameters
[in]startIndexThe start index
[in]endIndexThe end index
[in]refinementDistanceThe chosen refinement distance
Returns
refinedPolygon The computed polygon

◆ RefinePolygon()

std::vector<Point> meshkernel::Polygons::RefinePolygon ( UInt  polygonIndex,
UInt  startIndex,
UInt  endIndex,
double  refinementDistance 
) const

Refines the polygon edges with additional nodes, from the start to the end index (refinepolygonpart)

Parameters
[in]polygonIndexThe polygon index
[in]startIndexThe start index for the node array for the polygon
[in]endIndexThe end index for the node array for the polygon
[in]refinementDistanceThe chosen refinement distance
Returns
refinedPolygon The computed polygon

◆ SnapToLandBoundary()

void meshkernel::Polygons::SnapToLandBoundary ( const LandBoundary landBoundary,
UInt  startIndex,
UInt  endIndex 
)

Snap the polygon to the land boundary.

The polygon points are snapped to the closest point on the land boundary.

Parameters
[in]landBoundaryThe land boundary to which the polygon should be snapped.
[in]startIndexThe start index
[in]endIndexThe end index

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