/* * (C) Copyright 2023 ECMWF. * * This software is licensed under the terms of the Apache Licence Version 2.0 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. * In applying this licence, ECMWF does not waive the privileges and immunities * granted to it by virtue of its status as an intergovernmental organisation * nor does it submit to any jurisdiction. */ #pragma once #include #include #include #include "atlas/library/config.h" namespace atlas { namespace util { class CGALSphericalTriangulation { public: template CGALSphericalTriangulation(const LonLatVector& lonlat); CGALSphericalTriangulation(size_t N, const double lonlat[]); CGALSphericalTriangulation(size_t N, const double lon[], const double lat[]); CGALSphericalTriangulation(size_t N, const double lon[], const double lat[], int lon_stride, int lat_stride); ~CGALSphericalTriangulation(); /// @return number of triangles size_t size() const; void triangles(std::array[]) const; void triangles(std::array[]) const; void triangles(std::array[]) const; void triangles(std::array[]) const; template std::vector> triangles() const; std::vector> triangles() const; private: struct CGAL; std::unique_ptr cgal_; std::vector> points_xyz_; }; template inline CGALSphericalTriangulation::CGALSphericalTriangulation(const LonLatVector& lonlat) : CGALSphericalTriangulation(lonlat.size(), reinterpret_cast(lonlat.data())) {} template inline std::vector> CGALSphericalTriangulation::triangles() const { std::vector> vector(size()); triangles(vector.data()); return vector; } } }