Skip to content

Commit d17284c

Browse files
committed
Review: various refinements
1 parent 6d7b728 commit d17284c

4 files changed

Lines changed: 5 additions & 12 deletions

File tree

src/atlas/interpolation/method/unstructured/SphericalMeanValue.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,7 @@ Method::Triplets SphericalMeanValue::projectPointToElements(size_t ip, const Ele
397397
nb_cols = currentPolygon.size();
398398
ATLAS_ASSERT(nb_cols == 3 || nb_cols == 4);
399399

400-
std::vector<double> polygonWeights;
401-
polygonWeights.reserve(nb_cols);
400+
std::vector<double> polygonWeights(nb_cols);
402401

403402
if (currentPolygon.compute_vertex_weights(candidatePoint, polygonWeights.data(), polygonWeights.size()) == 1) {
404403
if (normalisation_) {

src/atlas/util/ConvexSphericalPolygon.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ ConvexSphericalPolygon::ConvexSphericalPolygon(const PointLonLat points[], size_
9494
++isp;
9595
}
9696
size_ = isp;
97-
ATLAS_ASSERT(size_ > 2, "Polygon must have at least 3 points");
9897
validate();
9998

10099
if (not valid_) {
@@ -121,7 +120,6 @@ ConvexSphericalPolygon::ConvexSphericalPolygon(const PointXYZ points[], size_t s
121120
++isp;
122121
}
123122
size_ = isp;
124-
ATLAS_ASSERT(size_ > 2, "Polygon must have at least 3 points");
125123
validate();
126124

127125
if (not valid_) {

src/atlas/util/ConvexSphericalPolygon.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#pragma once
1212

13-
#include <optional>
1413
#include <vector>
1514

1615
#include "eckit/deprecated.h"
@@ -87,7 +86,7 @@ class ConvexSphericalPolygon {
8786

8887
size_t size() const { return size_; }
8988

90-
std::vector<PointXYZ> edge_normals() const {
89+
std::vector<PointXYZ>& edge_normals() const {
9190
if (not computed_edge_normals_) {
9291
compute_edge_normals();
9392
}

src/tests/util/test_convexsphericalmeanvalue.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ CASE("test_convex_spherical_polygon_triag") {
8181
size_t pointsOutside = 0;
8282

8383
for (size_t i = 0; i < numberTestPoints; ++i) {
84-
std::vector<double> polygonWeights;
85-
polygonWeights.reserve(testTriangle.size());
84+
std::vector<double> polygonWeights(testTriangle.size());
8685

8786
if (testTriangle.compute_vertex_weights(candidatePoints[i], polygonWeights.data(), polygonWeights.size()) ==
8887
1) {
@@ -163,8 +162,7 @@ CASE("test_spherical_polygon_nonplanar_quad") {
163162
size_t pointsOutside = 0;
164163

165164
for (size_t i = 0; i < numberTestPoints; ++i) {
166-
std::vector<double> polygonWeights;
167-
polygonWeights.reserve(testQuad.size());
165+
std::vector<double> polygonWeights(testQuad.size());
168166

169167
if (testQuad.compute_vertex_weights(candidatePoints[i], polygonWeights.data(), polygonWeights.size()) ==
170168
1) {
@@ -195,8 +193,7 @@ CASE("test_spherical_polygon_nonplanar_quad") {
195193
size_t pointsOutsideRotated = 0;
196194

197195
for (size_t i = 0; i < numberTestPoints; ++i) {
198-
std::vector<double> polygonWeightsRotated;
199-
polygonWeightsRotated.reserve(testQuadRotated.size());
196+
std::vector<double> polygonWeightsRotated(testQuadRotated.size());
200197

201198
if (testQuadRotated.compute_vertex_weights(candidatePoints[i], polygonWeightsRotated.data(),
202199
polygonWeightsRotated.size()) == 1) {

0 commit comments

Comments
 (0)