From 33a58a47f2a90b7206a9a00bb311378a0e869b42 Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Tue, 8 Aug 2023 14:38:52 +0200
Subject: [PATCH] [T/GL] create random points used by other tests

---
 Tests/GeoLib/CreateTestPoints.cpp | 23 +++++++++++++++++++++++
 Tests/GeoLib/CreateTestPoints.h   |  5 +++++
 2 files changed, 28 insertions(+)

diff --git a/Tests/GeoLib/CreateTestPoints.cpp b/Tests/GeoLib/CreateTestPoints.cpp
index 5c2445a5675..f6837031e5d 100644
--- a/Tests/GeoLib/CreateTestPoints.cpp
+++ b/Tests/GeoLib/CreateTestPoints.cpp
@@ -11,6 +11,7 @@
 
 #include <map>
 #include <memory>
+#include <random>
 #include <vector>
 
 void createSetOfTestPointsAndAssociatedNames(GeoLib::GEOObjects& geo_objs,
@@ -42,3 +43,25 @@ void createSetOfTestPointsAndAssociatedNames(GeoLib::GEOObjects& geo_objs,
 
     geo_objs.addPointVec(std::move(pnts), name, std::move(pnt_name_map));
 }
+
+std::vector<GeoLib::Point*> createRandomPoints(
+    std::size_t const number_of_random_points,
+    std::array<double, 6> const& limits)
+{
+    std::random_device rd;
+    std::mt19937 random_engine_mt19937(rd());
+    std::normal_distribution<> normal_dist_x(limits[0], limits[1]);
+    std::normal_distribution<> normal_dist_y(limits[2], limits[3]);
+    std::normal_distribution<> normal_dist_z(limits[4], limits[5]);
+
+    std::vector<GeoLib::Point*> random_points;
+
+    for (std::size_t k = 0; k < number_of_random_points; ++k)
+    {
+        random_points.push_back(new GeoLib::Point(
+            std::array{normal_dist_x(random_engine_mt19937),
+                       normal_dist_y(random_engine_mt19937),
+                       normal_dist_z(random_engine_mt19937)}));
+    }
+    return random_points;
+}
diff --git a/Tests/GeoLib/CreateTestPoints.h b/Tests/GeoLib/CreateTestPoints.h
index 04518c0e938..3d69b4cc666 100644
--- a/Tests/GeoLib/CreateTestPoints.h
+++ b/Tests/GeoLib/CreateTestPoints.h
@@ -9,6 +9,7 @@
 
 #pragma once
 
+#include <array>
 #include <string>
 
 #include "GeoLib/GEOObjects.h"
@@ -17,3 +18,7 @@ void createSetOfTestPointsAndAssociatedNames(GeoLib::GEOObjects& geo_objs,
                                              std::string& name,
                                              std::size_t const pnts_per_edge,
                                              GeoLib::Point const& shift);
+
+std::vector<GeoLib::Point*> createRandomPoints(
+    std::size_t const number_of_random_points,
+    std::array<double, 6> const& limits);
-- 
GitLab