diff --git a/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp b/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp index 4a7caea00d432300b7d715172e3aea6c69eaa67c..dde814df04bf9dd9dc2bf0a71ab05fecd4ce10eb 100644 --- a/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp +++ b/MeshLib/MeshGenerators/LayeredMeshGenerator.cpp @@ -55,7 +55,8 @@ bool LayeredMeshGenerator::createLayers(MeshLib::Mesh const& mesh, return result; } -MeshLib::Mesh* LayeredMeshGenerator::getMesh(std::string const& mesh_name) const +std::unique_ptr<MeshLib::Mesh> +LayeredMeshGenerator::getMesh(std::string const& mesh_name) const { if (_nodes.empty() || _elements.empty()) return nullptr; @@ -71,11 +72,11 @@ MeshLib::Mesh* LayeredMeshGenerator::getMesh(std::string const& mesh_name) const else WARN ("Skipping MaterialID information, number of entries does not match element number"); - MeshLib::Mesh* result (new MeshLib::Mesh(mesh_name, _nodes, _elements, properties)); - MeshLib::NodeSearch ns(*result); + std::unique_ptr<MeshLib::Mesh> result(new MeshLib::Mesh(mesh_name, _nodes, _elements, properties)); + MeshLib::NodeSearch ns(*result.get()); if (ns.searchUnused() > 0) { - auto new_mesh = MeshLib::removeNodes(*result, ns.getSearchedNodeIDs(), mesh_name); - delete result; + std::unique_ptr<MeshLib::Mesh> new_mesh(MeshLib::removeNodes( + *result.get(), ns.getSearchedNodeIDs(), mesh_name)); return new_mesh; } return result; diff --git a/MeshLib/MeshGenerators/LayeredMeshGenerator.h b/MeshLib/MeshGenerators/LayeredMeshGenerator.h index 958d598d1022c29c138dc63ce0396c5780dd49fe..1b5a4692ecf431e04825fa68acf21a27c4edc164 100644 --- a/MeshLib/MeshGenerators/LayeredMeshGenerator.h +++ b/MeshLib/MeshGenerators/LayeredMeshGenerator.h @@ -15,9 +15,10 @@ #ifndef LAYEREDMESHGENERATOR_H #define LAYEREDMESHGENERATOR_H +#include <memory> +#include <limits> #include <string> #include <vector> -#include <limits> namespace GeoLib { class Raster; @@ -62,7 +63,7 @@ public: double noDataReplacementValue) = 0; /// Returns a mesh of the subsurface representation - MeshLib::Mesh* getMesh(std::string const& mesh_name) const; + std::unique_ptr<MeshLib::Mesh> getMesh(std::string const& mesh_name) const; protected: LayeredMeshGenerator();