From 364858a0cefdfd5541392b05e13d522e4d98ff8a Mon Sep 17 00:00:00 2001
From: Max Lyon <max.lyon@rwth-aachen.de>
Date: Tue, 10 Nov 2015 16:01:46 +0100
Subject: [PATCH] TetrahedralMesh support in Property Visualization

---
 CMakeLists.txt                           | 11 +++++++++++
 OpenVolumeMesh/OVMPropertyVisualizerT.cc |  3 +++
 PropertyModelFactory.cc                  | 11 +++++++++++
 PropertyVisPlugin.cc                     | 14 ++++++++++----
 4 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a6d78d1..3738c67 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,4 +14,15 @@ if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/HexahedralMesh)
     add_definitions (-DENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT)
 endif()
 
+find_package(OpenVolumeMesh)
+if(OPENVOLUMEMESH_FOUND)
+  if(EXISTS ${OPENVOLUMEMESH_INCLUDE_DIR}/OpenVolumeMesh/Mesh/TetrahedralMesh.hh)
+    if(EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/TetrahedralMesh/TetrahedralMesh.hh)
+      add_definitions (-DENABLE_OPENVOLUMEMESH_SUPPORT)
+      add_definitions (-DENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT)
+    endif()
+  endif()
+endif()
+
+
 openflipper_plugin (INSTALLDATA Icons DIRS OpenMesh OpenVolumeMesh Widgets DEPS OpenMesh OpenVolumeMesh)
diff --git a/OpenVolumeMesh/OVMPropertyVisualizerT.cc b/OpenVolumeMesh/OVMPropertyVisualizerT.cc
index 9adb802..9b4fa6b 100644
--- a/OpenVolumeMesh/OVMPropertyVisualizerT.cc
+++ b/OpenVolumeMesh/OVMPropertyVisualizerT.cc
@@ -57,6 +57,9 @@
 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
 #include <ObjectTypes/HexahedralMesh/HexahedralMesh.hh>
 #endif
+#ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT
+#include <ObjectTypes/TetrahedralMesh/TetrahedralMesh.hh>
+#endif
 
 #include "OVMPropertyVisualizer.hh"
 
diff --git a/PropertyModelFactory.cc b/PropertyModelFactory.cc
index 130c0b1..8ab928c 100644
--- a/PropertyModelFactory.cc
+++ b/PropertyModelFactory.cc
@@ -68,6 +68,10 @@
     #include <ObjectTypes/HexahedralMesh/HexahedralMesh.hh>
 #endif /* ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT */
 
+#ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT
+    #include <ObjectTypes/TetrahedralMesh/TetrahedralMesh.hh>
+#endif
+
 
 /**
  * @brief Returns the PropertyModel
@@ -154,6 +158,13 @@ PropertyModel* __PropertyModelFactory::getModel(int objectID)
         propertyModel = new OVMPropertyModel<HexahedralMesh>(mesh, objectID);
     }
 #endif /* ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT */
+#ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT
+    else if ( object->dataType(DATA_TETRAHEDRAL_MESH) )
+    {
+        TetrahedralMesh* mesh = PluginFunctions::tetrahedralMesh(object);
+        propertyModel = new OVMPropertyModel<TetrahedralMesh>(mesh, objectID);
+    }
+#endif
     else
     {
         return 0;
diff --git a/PropertyVisPlugin.cc b/PropertyVisPlugin.cc
index 8e07563..e474b79 100644
--- a/PropertyVisPlugin.cc
+++ b/PropertyVisPlugin.cc
@@ -76,10 +76,13 @@
 #include <ObjectTypes/PolyMesh/PolyMesh.hh>
 
 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
-	#include <ObjectTypes/PolyhedralMesh/PolyhedralMesh.hh>
+    #include <ObjectTypes/PolyhedralMesh/PolyhedralMesh.hh>
 #endif
 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
-	#include <ObjectTypes/HexahedralMesh/HexahedralMesh.hh>
+    #include <ObjectTypes/HexahedralMesh/HexahedralMesh.hh>
+#endif
+#ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT
+    #include <ObjectTypes/TetrahedralMesh/TetrahedralMesh.hh>
 #endif
 
 //== IMPLEMENTATION ==========================================================
@@ -215,9 +218,12 @@ void PropertyVisPlugin::updateGUI()
 	datatype |= DataType(DATA_POLYHEDRAL_MESH);
 #endif
 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
-	datatype |= DataType(DATA_HEXAHEDRAL_MESH);
+        datatype |= DataType(DATA_HEXAHEDRAL_MESH);
+#endif
+#ifdef ENABLE_OPENVOLUMEMESH_TETRAHEDRAL_SUPPORT
+        datatype |= DataType(DATA_TETRAHEDRAL_MESH);
 #endif
-	objectListItemModel_.refresh(datatype);
+        objectListItemModel_.refresh(datatype);
 }
 
 //-----------------------------------------------------------------------------
-- 
GitLab