From 8b5f45856ff0d90718c8cda3c2279b119f30c99f Mon Sep 17 00:00:00 2001
From: rinkk <karsten.rink@ufz.de>
Date: Fri, 1 Jul 2016 11:20:41 +0200
Subject: [PATCH] first test example

---
 Applications/Utils/CMakeLists.txt             |  4 ++-
 .../Utils/SWMMConverter/CMakeLists.txt        | 10 ++++++
 .../Utils/SWMMConverter/SWMMInterface.cpp     | 36 +++++++++++++++++++
 ThirdParty/CMakeLists.txt                     |  5 +++
 4 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 Applications/Utils/SWMMConverter/CMakeLists.txt
 create mode 100644 Applications/Utils/SWMMConverter/SWMMInterface.cpp

diff --git a/Applications/Utils/CMakeLists.txt b/Applications/Utils/CMakeLists.txt
index abbe2a36bfd..81a1269d857 100644
--- a/Applications/Utils/CMakeLists.txt
+++ b/Applications/Utils/CMakeLists.txt
@@ -15,4 +15,6 @@ else()
     add_subdirectory(ModelPreparation/PartitionMesh)
 endif() # OGS_BUILD_GUI
 
-include(Tests.cmake)
+if(OGS_BUILD_SWMM)
+    add_subdirectory(SWMMConverter)
+endif()
diff --git a/Applications/Utils/SWMMConverter/CMakeLists.txt b/Applications/Utils/SWMMConverter/CMakeLists.txt
new file mode 100644
index 00000000000..e434d6a3fd0
--- /dev/null
+++ b/Applications/Utils/SWMMConverter/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_executable(SWMMInterface SWMMInterface.cpp)
+
+target_link_libraries(SWMMInterface
+    MeshLib
+    swmm5interface
+)
+
+ADD_VTK_DEPENDENCY(SWMMInterface)
+
+set_target_properties(SWMMInterface PROPERTIES FOLDER Utilities)
diff --git a/Applications/Utils/SWMMConverter/SWMMInterface.cpp b/Applications/Utils/SWMMConverter/SWMMInterface.cpp
new file mode 100644
index 00000000000..c7ccfdd593c
--- /dev/null
+++ b/Applications/Utils/SWMMConverter/SWMMInterface.cpp
@@ -0,0 +1,36 @@
+
+
+#include <string>
+#include <iostream>
+#include "ThirdParty/SWMMInterface/swmm5_iface.h"
+
+int main(int argc, char *argv[])
+{
+   // Open outfile as a SWMM output file
+    std::string outfile = argv[1];
+    int r = OpenSwmmOutFile(const_cast<char*>(outfile.c_str()));
+    if (r == 1)
+    {
+        printf("\nInvalid results in SWMM output file.\n");
+    }
+    else if (r == 2)
+    {
+        printf("\nFile is not a SWMM output file.\n");
+    }
+    else
+    {
+        printf("\nTime       Total     Total     Total");
+        printf("\nPeriod  Rainfall    Runoff   Outflow");
+        printf("\n====================================");
+        for (int i=1; i<=SWMM_Nperiods; i++)
+        {
+            float x, y, z;
+            GetSwmmResult(3, 0, 1, i, &x);
+            GetSwmmResult(3, 0, 4, i, &y);
+            GetSwmmResult(3, 0, 11, i, &z);
+            printf("\n%6d  %8.2f  %8.2f  %8.2f", i, x, y, z);
+        }
+        CloseSwmmOutFile();
+    }
+   return 0;
+}
\ No newline at end of file
diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt
index 049268fa81a..8f75c2e6a60 100644
--- a/ThirdParty/CMakeLists.txt
+++ b/ThirdParty/CMakeLists.txt
@@ -50,3 +50,8 @@ if(NOT TARGET vtkGUISupportQt AND OGS_BUILD_GUI)
     include_directories(SYSTEM ${VTK_INCLUDE_DIRS})
     add_subdirectory(${CMAKE_SOURCE_DIR}/ThirdParty/vtkGUISupportQt)
 endif()
+
+if(OGS_BUILD_SWMM)
+    add_subdirectory(${CMAKE_SOURCE_DIR}/ThirdParty/SWMMInterface/swmm5)
+    add_subdirectory(${CMAKE_SOURCE_DIR}/ThirdParty/SWMMInterface)
+endif()
-- 
GitLab