From 622077be0dd8df94e5312ce27d2ded692b83e97e Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Mon, 15 Aug 2016 07:48:34 +0200
Subject: [PATCH] [MeL/ME] const& instead of const* for dest. mesh.

---
 .../createMeshElemPropertiesFromASCRaster.cpp |  2 +-
 .../Mesh2MeshPropertyInterpolation.cpp        | 27 +++++++++++--------
 .../Mesh2MeshPropertyInterpolation.h          | 10 +++----
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp b/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp
index f42b1eb0b31..9d59d4ab877 100644
--- a/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp
+++ b/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp
@@ -168,7 +168,7 @@ int main(int argc, char* argv[])
     // do the interpolation
     MeshLib::Mesh2MeshPropertyInterpolation mesh_interpolation(
         *src_mesh, property_arg.getValue());
-    mesh_interpolation.setPropertiesForMesh(dest_mesh.get());
+    mesh_interpolation.setPropertiesForMesh(*dest_mesh);
 
     double scale(1.0);
     if (unit_arg.getValue() == "m/s")
diff --git a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp
index e8d9fb856e8..0cde2892ab9 100644
--- a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp
+++ b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.cpp
@@ -35,24 +35,29 @@ Mesh2MeshPropertyInterpolation::Mesh2MeshPropertyInterpolation(
     : _src_mesh(src_mesh), _property_name(property_name)
 {}
 
-bool Mesh2MeshPropertyInterpolation::setPropertiesForMesh(Mesh *dest_mesh) const
+bool Mesh2MeshPropertyInterpolation::setPropertiesForMesh(Mesh& dest_mesh) const
 {
-    if (_src_mesh->getDimension() != dest_mesh->getDimension()) {
-        ERR ("MeshLib::Mesh2MeshPropertyInterpolation::setPropertiesForMesh() dimension of source (dim = %d) and destination (dim = %d) mesh does not match.", _src_mesh->getDimension(), dest_mesh->getDimension());
+    if (_src_mesh.getDimension() != dest_mesh.getDimension()) {
+        ERR("MeshLib::Mesh2MeshPropertyInterpolation::setPropertiesForMesh() "
+            "dimension of source (dim = %d) and destination (dim = %d) mesh "
+            "does not match.",
+            _src_mesh.getDimension(), dest_mesh.getDimension());
         return false;
     }
 
-    if (_src_mesh->getDimension() != 2) {
-        WARN ("MeshLib::Mesh2MeshPropertyInterpolation::setPropertiesForMesh() implemented only for 2D case at the moment.");
+    if (_src_mesh.getDimension() != 2) {
+        WARN(
+            "MeshLib::Mesh2MeshPropertyInterpolation::setPropertiesForMesh() "
+            "implemented only for 2D case at the moment.");
         return false;
     }
 
     boost::optional<MeshLib::PropertyVector<double> &> opt_pv(
-        dest_mesh->getProperties().getPropertyVector<double>(_property_name));
+        dest_mesh.getProperties().getPropertyVector<double>(_property_name));
     if (!opt_pv) {
         INFO("Create new PropertyVector \"%s\" of type double.",
              _property_name.c_str());
-        opt_pv = dest_mesh->getProperties().createNewPropertyVector<double>(
+        opt_pv = dest_mesh.getProperties().createNewPropertyVector<double>(
             _property_name, MeshItemType::Cell, 1);
         if (!opt_pv) {
             WARN("Could not get or create a PropertyVector of type double"
@@ -61,16 +66,16 @@ bool Mesh2MeshPropertyInterpolation::setPropertiesForMesh(Mesh *dest_mesh) const
         }
     }
     MeshLib::PropertyVector<double> & dest_properties(opt_pv.get());
-    if (dest_properties.size() != dest_mesh->getNumberOfElements())
-        dest_properties.resize(dest_mesh->getNumberOfElements());
+    if (dest_properties.size() != dest_mesh.getNumberOfElements())
+        dest_properties.resize(dest_mesh.getNumberOfElements());
 
-    interpolatePropertiesForMesh(*dest_mesh, dest_properties);
+    interpolatePropertiesForMesh(dest_mesh, dest_properties);
 
     return true;
 }
 
 void Mesh2MeshPropertyInterpolation::interpolatePropertiesForMesh(
-    Mesh &dest_mesh, MeshLib::PropertyVector<double> & dest_properties) const
+    Mesh& dest_mesh, MeshLib::PropertyVector<double>& dest_properties) const
 {
     std::vector<double> interpolated_src_node_properties(_src_mesh.getNumberOfNodes());
     interpolateElementPropertiesToNodeProperties(
diff --git a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h
index 118cf0a3ad6..6d3de0466af 100644
--- a/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h
+++ b/MeshLib/MeshEditing/Mesh2MeshPropertyInterpolation.h
@@ -41,13 +41,13 @@ public:
                                    std::string const& property_name);
 
     /**
-     * Calculates entries for the property vector and sets appropriate indices in the
-     * mesh elements.
-     * @param mesh the mesh the property information will be calculated and set via
-     * weighted interpolation
+     * Calculates entries for the property vector and sets appropriate indices
+     * in the mesh elements.
+     * @param mesh the mesh the property information will be calculated and set
+     * via weighted interpolation
      * @return true if the operation was successful, false on error
      */
-    bool setPropertiesForMesh(Mesh *mesh) const;
+    bool setPropertiesForMesh(Mesh& mesh) const;
 
 private:
     /**
-- 
GitLab