From aa06980db61e2b48a891214d9b67b89f089d588b Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 12 Aug 2014 14:47:07 +0200
Subject: [PATCH] Some comments and cleanup.

---
 InSituLib/VtkMappedMesh.h                     |  4 +-
 InSituLib/VtkMappedMeshSource.h               | 20 +++--
 .../VtkMeshNodalCoordinatesTemplate-impl.h    |  2 +-
 InSituLib/VtkMeshNodalCoordinatesTemplate.h   |  3 +-
 Tests/InSituLib/TestVtkMappedMeshSource.cpp   | 81 +++++++++++++++++++
 .../TestVtkMeshNodalCoordinatesTemplate.cpp   | 61 --------------
 6 files changed, 100 insertions(+), 71 deletions(-)
 create mode 100644 Tests/InSituLib/TestVtkMappedMeshSource.cpp

diff --git a/InSituLib/VtkMappedMesh.h b/InSituLib/VtkMappedMesh.h
index 1cad249a8f0..066b9c4ff67 100644
--- a/InSituLib/VtkMappedMesh.h
+++ b/InSituLib/VtkMappedMesh.h
@@ -2,7 +2,9 @@
  * \file
  * \author Lars Bilke
  * \date   2014-02-27
- * \brief  Definition of the VtkMappedMesh class.
+ * \brief  VtkMappedMesh is a adapter for converting OGS cell connectivity to its
+ *         VTK counter part. This generates an incomplete vtkUnstructureGrid
+ *         without node coordinates. See VtkMeshNodalCoordinatesTemplate.
  *
  * \copyright
  * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
diff --git a/InSituLib/VtkMappedMeshSource.h b/InSituLib/VtkMappedMeshSource.h
index 8d92b58452e..6cfcb3212d4 100644
--- a/InSituLib/VtkMappedMeshSource.h
+++ b/InSituLib/VtkMappedMeshSource.h
@@ -2,7 +2,15 @@
  * \file
  * \author Lars Bilke
  * \date   2014-08-12
- * \brief  Definition of the VtkMappedMeshSource class.
+ * \brief  VtkMappedMeshSource is a souce class to transform OGS meshes into complete
+ *         vtkUnstructuredGrids.
+ * Usage:
+ * \code
+ * vtkNew<InSituLib::VtkMappedMeshSource> vtkSource;
+ * vtkSource->SetMesh(mesh);
+ * vtkSource->Update();
+ * vtkUnstructuredGrid* output = vtkSource->GetOutput();
+ * \endcode
  *
  * \copyright
  * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
@@ -16,9 +24,9 @@
 #define _VTKMAPPEDMESHSOURCE
 
 #include "vtkUnstructuredGridAlgorithm.h"
-#include "vtkNew.h" // For vtkNew
-#include <string> // For std::string
-#include <vector> // For std::vector
+#include "vtkNew.h"
+#include <string>
+#include <vector>
 
 class vtkDataArrayCollection;
 class vtkPointData;
@@ -52,16 +60,14 @@ protected:
 
 private:
 	VtkMappedMeshSource(const VtkMappedMeshSource &); // Not implemented.
-	void operator=(const VtkMappedMeshSource &);   // Not implemented.
+	void operator=(const VtkMappedMeshSource &);      // Not implemented.
 
 	const MeshLib::Mesh* _mesh;
 
 	int NumberOfDimensions;
 	int NumberOfNodes;
-	//int NumberOfElementBlocks;
 	std::vector<std::string> NodalVariableNames;
 	std::vector<std::string> ElementVariableNames;
-	//std::vector<int> ElementBlockIds;
 
 	vtkNew<vtkPoints> Points;
 	vtkNew<vtkPointData> PointData;
diff --git a/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h b/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h
index 1e2b67ff44b..28b2a86a9a2 100644
--- a/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h
+++ b/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h
@@ -2,7 +2,7 @@
  * \file
  * \author Lars Bilke
  * \date   2014-02-26
- * \brief  Definition of the ElementStatus class.
+ * \brief  Definition of the VtkMeshNodalCoordinatesTemplate class.
  *
  * \copyright
  * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
diff --git a/InSituLib/VtkMeshNodalCoordinatesTemplate.h b/InSituLib/VtkMeshNodalCoordinatesTemplate.h
index 17b124ed4df..2a4c58ba65a 100644
--- a/InSituLib/VtkMeshNodalCoordinatesTemplate.h
+++ b/InSituLib/VtkMeshNodalCoordinatesTemplate.h
@@ -2,7 +2,8 @@
  * \file
  * \author Lars Bilke
  * \date   2014-02-26
- * \brief  Definition of the VtkMeshNodalCoordinates class.
+ * \brief  VtkMeshNodalCoordinatesTemplate is a adapter for node coordinates of
+ *         OGS meshes to VTK unstructured grids.
  *
  * \copyright
  * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
diff --git a/Tests/InSituLib/TestVtkMappedMeshSource.cpp b/Tests/InSituLib/TestVtkMappedMeshSource.cpp
new file mode 100644
index 00000000000..b94868719f1
--- /dev/null
+++ b/Tests/InSituLib/TestVtkMappedMeshSource.cpp
@@ -0,0 +1,81 @@
+/**
+ * \file
+ * \author Lars Bilke
+ * \date   2014-08-12
+ * \brief  Unit tests for In-Situ mesh source
+ *
+ * \copyright
+ * Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+#include <vtkNew.h>
+#include <vtkUnstructuredGrid.h>
+
+#include "gtest/gtest.h"
+
+#include "Mesh.h"
+#include "MeshGenerators/MeshGenerator.h"
+
+#include "VtkMappedMesh.h"
+#include "VtkMappedMeshSource.h"
+
+class InSituMesh : public ::testing::Test
+{
+	public:
+	InSituMesh()
+	 : mesh(nullptr)
+	{
+		mesh = MeshLib::MeshGenerator::generateRegularQuadMesh(this->length, this->subdivisions);
+	}
+
+	~InSituMesh()
+	{
+		delete mesh;
+	}
+
+	MeshLib::Mesh const* mesh;
+	const size_t subdivisions = 99;
+	const double length = 10.0;
+	const double dx = length / subdivisions;
+};
+
+TEST_F(InSituMesh, Construction)
+{
+	ASSERT_TRUE(mesh != nullptr);
+	ASSERT_EQ((subdivisions+1)*(subdivisions+1), mesh->getNNodes());
+}
+
+
+TEST_F(InSituMesh, MappedMesh)
+{
+	ASSERT_TRUE(mesh != nullptr);
+
+	vtkNew<InSituLib::VtkMappedMesh> vtkMesh;
+	vtkMesh->GetImplementation()->SetNodes(mesh->getNodes());
+	vtkMesh->GetImplementation()->SetElements(mesh->getElements());
+
+	ASSERT_EQ(subdivisions*subdivisions, vtkMesh->GetNumberOfCells());
+	ASSERT_EQ(VTK_QUAD, vtkMesh->GetCellType(0));
+	ASSERT_EQ(VTK_QUAD, vtkMesh->GetCellType(vtkMesh->GetNumberOfCells()-1));
+	ASSERT_EQ(1, vtkMesh->IsHomogeneous());
+	ASSERT_EQ(4, vtkMesh->GetMaxCellSize());
+
+
+	ASSERT_EQ(0, vtkMesh->GetNumberOfPoints()); // No points are defined
+}
+
+TEST_F(InSituMesh, MappedMeshSource)
+{
+	ASSERT_TRUE(mesh != nullptr);
+
+	vtkNew<InSituLib::VtkMappedMeshSource> vtkSource;
+	vtkSource->SetMesh(mesh);
+	vtkSource->Update();
+	vtkUnstructuredGrid* output = vtkSource->GetOutput();
+
+	ASSERT_EQ((subdivisions+1)*(subdivisions+1), output->GetNumberOfPoints());
+	ASSERT_EQ(subdivisions*subdivisions, output->GetNumberOfCells());
+}
diff --git a/Tests/InSituLib/TestVtkMeshNodalCoordinatesTemplate.cpp b/Tests/InSituLib/TestVtkMeshNodalCoordinatesTemplate.cpp
index a7717f1d40e..cee76f8ff30 100644
--- a/Tests/InSituLib/TestVtkMeshNodalCoordinatesTemplate.cpp
+++ b/Tests/InSituLib/TestVtkMeshNodalCoordinatesTemplate.cpp
@@ -20,67 +20,6 @@
 #include "MeshGenerators/MeshGenerator.h"
 
 #include "VtkMeshNodalCoordinatesTemplate.h"
-#include "VtkMappedMesh.h"
-#include "VtkMappedMeshSource.h"
-
-class InSituMesh : public ::testing::Test
-{
-	public:
-	InSituMesh()
-	 : mesh(nullptr)
-	{
-		mesh = MeshLib::MeshGenerator::generateRegularQuadMesh(this->length, this->subdivisions);
-	}
-
-	~InSituMesh()
-	{
-	    delete mesh;
-	}
-
-	MeshLib::Mesh const* mesh;
-	const size_t subdivisions = 99;
-	const double length = 10.0;
-	const double dx = length / subdivisions;
-};
-
-TEST_F(InSituMesh, Construction)
-{
-	ASSERT_TRUE(mesh != nullptr);
-	ASSERT_EQ((subdivisions+1)*(subdivisions+1), mesh->getNNodes());
-}
-
-
-TEST_F(InSituMesh, MappedMesh)
-{
-	ASSERT_TRUE(mesh != nullptr);
-
-	vtkNew<InSituLib::VtkMappedMesh> vtkMesh;
-	vtkMesh->GetImplementation()->SetNodes(mesh->getNodes());
-	vtkMesh->GetImplementation()->SetElements(mesh->getElements());
-
-	ASSERT_EQ(subdivisions*subdivisions, vtkMesh->GetNumberOfCells());
-	ASSERT_EQ(VTK_QUAD, vtkMesh->GetCellType(0));
-	ASSERT_EQ(VTK_QUAD, vtkMesh->GetCellType(vtkMesh->GetNumberOfCells()-1));
-	ASSERT_EQ(1, vtkMesh->IsHomogeneous());
-	ASSERT_EQ(4, vtkMesh->GetMaxCellSize());
-
-
-	ASSERT_EQ(0, vtkMesh->GetNumberOfPoints()); // No points are defined
-}
-
-TEST_F(InSituMesh, MappedMeshSource)
-{
-	ASSERT_TRUE(mesh != nullptr);
-
-	vtkNew<InSituLib::VtkMappedMeshSource> vtkSource;
-	vtkSource->SetMesh(mesh);
-	vtkSource->UpdateInformation();
-	vtkSource->Update();
-	vtkUnstructuredGrid* output = vtkSource->GetOutput();
-
-	ASSERT_EQ((subdivisions+1)*(subdivisions+1), output->GetNumberOfPoints());
-	ASSERT_EQ(subdivisions*subdivisions, output->GetNumberOfCells());
-}
 
 TEST(InSituLibNodalCoordinates, Init)
 {
-- 
GitLab