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

A closed polygon. More...

#include <Polygon.hpp>

Public Member Functions

 Polygon ()=default
 Default constructor.
 
 Polygon (const Polygon &copy)=default
 Default copy constructor.
 
 Polygon (Polygon &&copy)=default
 Default move constructor.
 
 Polygon (const std::vector< Point > &points, Projection projection)
 Constructor.
 
 Polygon (std::vector< Point > &&points, Projection projection)
 Constructor. More...
 
void Reset (const std::vector< Point > &points, Projection projection)
 Reset the polygon.
 
Polygonoperator= (const Polygon &copy)
 Copy assignment operator.
 
Polygonoperator= (Polygon &&copy)
 Move assignment operator.
 
UInt Size () const
 Return the number of points in the polygon.
 
const std::vector< Point > & Nodes () const
 Return vector of nodes of the polygon.
 
PointNode (const size_t i)
 Return single point at position.
 
const PointNode (const size_t i) const
 Return single point at position.
 
const BoundingBoxGetBoundingBox () const
 Get the bounding box of the polygon.
 
bool Contains (const Point &point) const
 Determine if the polygon contains the point.
 
void SnapToLandBoundary (const size_t startIndex, const size_t endIndex, const LandBoundary &boundary)
 Snap the section of the polygon defined by start- and end-index to the land boundary. More...
 
std::vector< PointRefine (UInt startIndex, UInt endIndex, double refinementDistance) const
 Refine the polygon. More...
 
std::vector< PointLinearRefine (UInt startIndex, UInt endIndex) const
 Refine the polygon. More...
 
std::tuple< double, Point, TraversalDirectionFaceAreaAndCenterOfMass () const
 Compute the area of the polygon, its centre of mass and the direction.
 
double PerimeterLength () const
 Compute the perimiter length of the closed polygon.
 
std::vector< double > EdgeLengths () const
 Computes the edge lengths of the polygon. More...
 
std::vector< PointComputeOffset (double displacement, const bool innerAndOuter) const
 Compute the poygon offset.
 
Projection GetProjection () const
 Get the projection used.
 

Static Public Member Functions

static std::tuple< double, Point, TraversalDirectionFaceAreaAndCenterOfMass (const std::vector< Point > &polygon, const Projection projection)
 Compute the area of the polygon, its centre of mass and the direction.
 
static std::tuple< double, Point, TraversalDirectionFaceAreaAndCenterOfMass (const std::vector< Point > &nodes, const std::vector< UInt > &nodeIndices, const Projection projection, bool isClosed)
 Compute the area of the polygon, its centre of mass and the direction. More...
 

Detailed Description

A closed polygon.

A polygon consists of at least 3 distinct points, and 1 point to close the polygon.

Constructor & Destructor Documentation

◆ Polygon()

meshkernel::Polygon::Polygon ( std::vector< Point > &&  points,
Projection  projection 
)

Constructor.

Note
Points are moved to the polygon

Member Function Documentation

◆ EdgeLengths()

std::vector<double> meshkernel::Polygon::EdgeLengths ( ) const

Computes the edge lengths of the polygon.

Returns
edgeLengths The length of each polygon edge

◆ FaceAreaAndCenterOfMass()

static std::tuple<double, Point, TraversalDirection> meshkernel::Polygon::FaceAreaAndCenterOfMass ( const std::vector< Point > &  nodes,
const std::vector< UInt > &  nodeIndices,
const Projection  projection,
bool  isClosed 
)
static

Compute the area of the polygon, its centre of mass and the direction.

This version uses an indirect indexing of the set of nodes, this can be used to reduce the need to copy nodes to a separate array.

◆ LinearRefine()

std::vector<Point> meshkernel::Polygon::LinearRefine ( UInt  startIndex,
UInt  endIndex 
) const

Refine the polygon.

Returns
The points for the refined polygon

◆ Refine()

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

Refine the polygon.

The refined nodes are placed at equally spaced intervals for each polygon segment. The spacing of the refined nodes may differ between polygon segments.

Returns
The points for the refined polygon

◆ SnapToLandBoundary()

void meshkernel::Polygon::SnapToLandBoundary ( const size_t  startIndex,
const size_t  endIndex,
const LandBoundary boundary 
)

Snap the section of the polygon defined by start- and end-index to the land boundary.

Note
The bounding box may be changed

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