Skip to content
Snippets Groups Projects
Commit 8a698bd6 authored by Tom Fischer's avatar Tom Fischer
Browse files

[MeL/MG] LayeredMeshGenerateor::getMesh(): Declare the ownership of the mesh.

parent 312cb991
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment