32 #include "MeshKernel/Constants.hpp"
33 #include "MeshKernel/Definitions.hpp"
34 #include "MeshKernel/Exceptions.hpp"
35 #include "MeshKernel/Point.hpp"
50 using Edge = std::pair<UInt, UInt>;
53 static bool IsValid(
const UInt value)
55 return value != constants::missing::uintValue;
58 static bool IsValidEdge(
const Edge& edge)
60 return IsValid(edge.first) && IsValid(edge.second);
69 return edge[0] == elementId ? edge[1] : edge[0];
78 return node == edge.first ? edge.second : edge.first;
84 static UInt EdgeNodeIndex(
const Edge& edge,
UInt position)
90 else if (position == 1)
96 throw ConstraintError(
"Position out of bounds: {} not in [0 .. 1]", position);
112 double value = constants::missing::doubleValue;
130 const double** samplesYCoordinate,
131 const double** samplesValue)
134 std::vector<Sample> samples(numSamples);
135 for (
UInt i = 0; i < samples.size(); ++i)
137 samples[i].x = (*samplesXCoordinate)[i];
138 samples[i].y = (*samplesYCoordinate)[i];
139 samples[i].value = (*samplesValue)[i];
145 [[nodiscard]]
bool IsValid(
const double missingValue = constants::missing::doubleValue)
const
147 bool isInvalid =
IsEqual(
x, missingValue) ||
155 static std::vector<Edge> ConvertToEdgeNodesVector(
int numEdges,
const int*
const edge_nodes)
157 std::vector<Edge> edges(numEdges);
160 for (
auto e = 0; e < numEdges; e++)
162 edges[e].first = edge_nodes[ei];
164 edges[e].second = edge_nodes[ei];
171 static std::vector<Point> ConvertToNodesVector(
int numNodes,
172 const double*
const node_x,
173 const double*
const node_y)
175 std::vector<Point> nodes(numNodes);
176 for (
auto n = 0; n < numNodes; n++)
178 nodes[n].x = node_x[n];
179 nodes[n].y = node_y[n];
185 static std::tuple<int, double*, double*> ConvertFromNodesVector(
const std::vector<Point>& nodes);
188 static std::vector<Point> ConvertToFaceCentersVector(
int numFaces,
189 const double*
const facex,
190 const double*
const facey)
192 std::vector<Point> faceCenters(numFaces);
193 for (
auto n = 0; n < numFaces; n++)
195 faceCenters[n].x = facex[n];
196 faceCenters[n].y = facey[n];
202 static std::vector<std::vector<UInt>> ConvertToFaceNodesVector(
int num_faces,
203 const int*
const face_nodes,
204 const int*
const nodes_per_face)
206 std::vector<std::vector<UInt>> result;
207 result.reserve(num_faces);
209 std::vector<UInt> nodes;
211 for (
auto f = 0; f < num_faces; f++)
214 for (
auto n = 0; n < nodes_per_face[f]; n++)
216 nodes.emplace_back(
static_cast<UInt>(face_nodes[index]));
219 result.emplace_back(nodes);