24 #include "atlas/library/config.h" 25 #include "atlas/util/Config.h" 26 #include "atlas/util/Object.h" 28 #include "atlas/util/VectorOfAbstract.h" 30 #include "atlas/projection/Projection.h" 38 class RectangularDomain;
48 class Polygon :
public std::vector<idx_t> {
52 struct edge_t : std::pair<idx_t, idx_t> {
55 edge_t reverse()
const {
return edge_t( std::pair<idx_t, idx_t>::second, std::pair<idx_t, idx_t>::first ); }
58 bool operator()(
const edge_t& e1,
const edge_t& e2 )
const {
60 return ( e1.first < e2.first ?
true : e1.first > e2.first ?
false : e1.second < e2.second );
65 using edge_set_t = std::set<edge_t, typename edge_t::LessThan>;
66 using container_t = std::vector<idx_t>;
75 operator bool()
const;
81 void print( std::ostream& )
const;
85 friend std::ostream& operator<<( std::ostream& s,
const Polygon& p ) {
91 void setup(
const edge_set_t& );
100 using Polygon::Polygon;
101 using PointsXY = std::vector<Point2>;
102 using PointsLonLat = std::vector<Point2>;
117 virtual PointsXY xy()
const = 0;
120 virtual PointsLonLat lonlat()
const = 0;
133 points_( std::move( points ) ), inscribed_( inscribed ) {
134 setup( compute_edges( points_.size() ) );
137 PointsXY
xy()
const override {
return points_; }
138 PointsLonLat
lonlat()
const override {
return points_; }
145 static util::Polygon::edge_set_t compute_edges(
idx_t points_size );
149 std::vector<Point2> points_;
166 template <
typename Po
intContainer>
169 template <
typename Po
intContainer>
170 PolygonCoordinates(
const PointContainer& points,
bool removeAlignedPoints );
174 virtual ~PolygonCoordinates();
181 virtual bool contains(
const Point2& P )
const = 0;
183 const Point2& coordinatesMax()
const;
184 const Point2& coordinatesMin()
const;
185 const Point2& centroid()
const;
187 idx_t size()
const {
return coordinates_.size(); }
189 void print( std::ostream& )
const;
194 Point2 coordinatesMin_;
195 Point2 coordinatesMax_;
197 std::vector<Point2> coordinates_;
A Field contains an Array, Metadata, and a reference to a FunctionSpace.
Definition: Field.h:59
Definition: Polygon.h:159
virtual void outputPythonScript(const eckit::PathName &, const eckit::Configuration &=util::NoConfig()) const
Output a python script that plots the partition.
Definition: Polygon.h:114
Definition: Polygon.h:155
This file contains classes and functions working on points.
Definition: Polygon.h:127
Polygon.
Definition: Polygon.h:48
PointsLonLat lonlat() const override
All (lon,lat) coordinates defining a polygon. Last point should match first.
Definition: Polygon.h:138
PointsXY xy() const override
All (x,y) coordinates defining a polygon. Last point should match first.
Definition: Polygon.h:137
Definition: VectorOfAbstract.h:52
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33
virtual idx_t halo() const
Return value of halo.
Definition: Polygon.h:108
long idx_t
Integer type for indices in connectivity tables.
Definition: config.h:42
const RectangularDomain & inscribedDomain() const override
Return inscribed rectangular domain (not rotated)
Definition: Polygon.h:142
virtual size_t footprint() const
Return the memory footprint of the Polygon.
Definition: Polygon.h:111