32 #include <MeshKernel/BoundingBox.hpp>
33 #include <MeshKernel/Exceptions.hpp>
34 #include <MeshKernel/Polygon.hpp>
35 #include <MeshKernel/PolygonalEnclosure.hpp>
53 Polygons(
const std::vector<Point>& polygon,
82 [[nodiscard]] std::vector<Point>
RefinePolygon(
UInt polygonIndex,
UInt startIndex,
UInt endIndex,
double refinementDistance)
const;
126 [[nodiscard]] std::vector<bool>
PointsInPolygons(
const std::vector<Point>& point)
const;
130 [[nodiscard]]
bool IsEmpty()
const;
157 double PerimeterClosedPolygon(
const std::vector<Point>& polygonNodes)
const;
162 std::vector<double> PolygonEdgeLengths(
const std::vector<Point>& polygonNodes)
const;
164 std::vector<PolygonalEnclosure> m_enclosures;
166 std::vector<std::pair<UInt, UInt>> m_outer_polygons_indices;
167 UInt m_numberOfNodes = 0;
178 if (index >= m_enclosures.size())
180 throw ConstraintError(
"Invalid enclosure index: {}, maximum index: {}", index, m_enclosures.size() - 1);
183 return m_enclosures[index];
188 return static_cast<UInt>(m_enclosures.size());
193 return m_numberOfNodes;
Projection
Enumerator describing the supported projections.
Definition: Definitions.hpp:41
UInt GetNumNodes() const
Gets the number of polygon nodes.
Definition: Polygons.hpp:191
UInt GetNumPolygons() const
Gives the number of polygons.
Definition: Polygons.hpp:186
std::vector< std::vector< Point > > ComputePointsInPolygons() const
Creates points inside the polygon using triangulation (the edges size determines how many points will...
std::vector< Point > 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)
bool IsPointInAnyPolygon(const Point &point) const
Checks if a point is included in any of the polygonal enclosures contained.
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 incl...
std::tuple< bool, UInt > IsPointInPolygons(const Point &point) const
Checks if a point is included in any of the polygons (dbpinpol_optinside_perpol)
Polygons()=default
Default constructor.
A class defining a bounding box.
Definition: BoundingBox.hpp:39
A struct describing a point in a two-dimensional space.
Definition: Point.hpp:40
Polygons OffsetCopy(double distance, bool innerAndOuter) const
Makes a new polygon from an existing one, by offsetting it by a distance (copypol)
std::vector< bool > PointsInPolygons(const std::vector< Point > &point) const
For each point, compute the index of the polygon including it.
A class containing the land boundary polylines.
Definition: LandBoundary.hpp:39
const PolygonalEnclosure & Enclosure(const UInt index) const
Get the polygonal enclosure at the index.
Definition: Polygons.hpp:171
std::vector< Point > GatherAllEnclosureNodes() const
Gets the nodes of all enclosures.
Contains the logic of the C++ static library.
Definition: AveragingInterpolation.hpp:36
A region enclosed by a polygonal permieter.
Definition: PolygonalEnclosure.hpp:45
void SnapToLandBoundary(const LandBoundary &landBoundary, UInt startIndex, UInt endIndex)
Snap the polygon to the land boundary.
std::vector< Point > LinearRefinePolygon(UInt polygonIndex, UInt startIndex, UInt endIndex) const
Linear refines the polygon edges with additional nodes, from the start to the end index.
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition: Definitions.hpp:38
std::tuple< UInt, UInt, UInt > PolygonIndex(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 p...
Projection GetProjection() const
Gets the projection.
Definition: Polygons.hpp:143
A class containing a list of polygonaly enclosed regions.
Definition: Polygons.hpp:44
std::vector< Point > RefineFirstPolygon(UInt startIndex, UInt endIndex, double refinementDistance) const
Refines the polygon edges with additional nodes, from the start to the end index (refinepolygonpart)
bool IsEmpty() const
Checks if the polygon is empty.
BoundingBox GetBoundingBox(UInt polygonIndex) const
Gets the bounding box for the polygon index i.
An exception class thrown when an attempt is made that violates a range constraint.
Definition: Exceptions.hpp:266