[opengtl-commits] [623] add a tool to show information of a shiva source file

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 623
Author:   cyrille
Date:     2009-03-14 17:32:43 +0100 (Sat, 14 Mar 2009)

Log Message:
-----------
add a tool to show information of a shiva source file

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/tools/CMakeLists.txt

Added Paths:
-----------
    trunk/OpenGTL/OpenShiva/tools/shivainfo/
    trunk/OpenGTL/OpenShiva/tools/shivainfo/CMakeLists.txt
    trunk/OpenGTL/OpenShiva/tools/shivainfo/ShivaInfo.cpp


Modified: trunk/OpenGTL/OpenShiva/tools/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/tools/CMakeLists.txt	2009-03-14 16:31:32 UTC (rev 622)
+++ trunk/OpenGTL/OpenShiva/tools/CMakeLists.txt	2009-03-14 16:32:43 UTC (rev 623)
@@ -1,3 +1,5 @@
 add_subdirectory(compiler)
 add_subdirectory(interpreter)
 add_subdirectory(tester)
+
+add_subdirectory(shivainfo)
\ No newline at end of file

Added: trunk/OpenGTL/OpenShiva/tools/shivainfo/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/tools/shivainfo/CMakeLists.txt	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/tools/shivainfo/CMakeLists.txt	2009-03-14 16:32:43 UTC (rev 623)
@@ -0,0 +1,10 @@
+include_directories( ${CMAKE_SOURCE_DIR} )
+
+set(shivainfo_SRCS
+  ShivaInfo.cpp
+    )
+
+add_executable(shivainfo ${shivainfo_SRCS})
+target_link_libraries(shivainfo OpenShiva )
+install( TARGETS shivainfo DESTINATION ${BIN_INSTALL_DIR} )
+

Added: trunk/OpenGTL/OpenShiva/tools/shivainfo/ShivaInfo.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/tools/shivainfo/ShivaInfo.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/tools/shivainfo/ShivaInfo.cpp	2009-03-14 16:32:43 UTC (rev 623)
@@ -0,0 +1,110 @@
+/*
+ *  Copyright (c) 2009 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+// C++ Headers
+#include <iostream>
+#include <cstdlib>
+
+// GTLCore Headers
+#include <GTLCore/String.h>
+#include <GTLCore/Metadata/Debug_p.h>
+
+// OpenShiva Headers
+#include <OpenShiva/Source.h>
+#include <OpenShiva/Version.h>
+#include <OpenShiva/Metadata.h>
+
+#define ARG_IS(a,b) argv[ai] == GTLCore::String(a) or argv[ai] == GTLCore::String(b)
+
+void printVersion()
+{
+  std::cout << OpenShiva::LibraryShortName << " - " << OpenShiva::LibraryName << " - " << OpenShiva::LibraryVersionString << std::endl;
+  std::cout << OpenShiva::LibraryCopyright << std::endl;
+  std::cout << "Shiva Version : " << OpenShiva::LanguageVersion << std::endl;
+}
+void printHelp()
+{
+  std::cout << "Usage : shivatester [option] fileName.shiva" << std::endl;
+  std::cout << std::endl;
+  std::cout << "Options : " << std::endl;
+  std::cout << "  -r --run-test           run the function 'run-test'" << std::endl;
+  std::cout << "  -c --compare            compare the result of the program with a file stored on disk" << std::endl;
+//   std::cout << "  -L --module-dir   add a location where to find modules" << std::endl;
+  std::cout << std::endl;
+  std::cout << "  -h --help               print this message" << std::endl;
+  std::cout << "  -v --version            print the version information" << std::endl;
+}
+
+GTLCore::String imageToString( OpenShiva::Source::ImageType imageType )
+{
+  switch( imageType )
+  {
+    case OpenShiva::Source::Image1:
+      return "Image1";
+    case OpenShiva::Source::Image2:
+      return "Image2";
+    case OpenShiva::Source::Image3:
+      return "Image3";
+    case OpenShiva::Source::Image4:
+      return "Image4";
+    case OpenShiva::Source::Image:
+      return "Image";
+    case OpenShiva::Source::InvalidImage:
+      return "InvalidImage";
+  }
+  return "Error";
+}
+
+int main(int argc, char** argv)
+{
+  GTLCore::String fileName = "";
+
+  for(int ai = 1; ai < argc; ai++)
+  {
+    if(ARG_IS("-h","--help"))
+    {
+      printHelp();
+      return EXIT_SUCCESS;
+    } else if(ARG_IS("-v","--version"))
+    {
+      printVersion();
+      return EXIT_SUCCESS;
+    } else {
+      fileName = argv[ai];
+    }
+  }
+  
+  OpenShiva::Source source;
+  source.loadFromFile(fileName);
+  
+  std::cout << "Name: " << source.name() << std::endl;
+  if(source.metadata())
+  {
+    std::cout << "<<<<<<<<<<< Metadata >>>>>>>>>>>" << std::endl;
+    GTLCore::Metadata::dumpAll(source.metadata());
+  }
+  std::cout << "<<<<<<<<<<< evaluatePixel >>>>>>>>>>>" << std::endl;
+  std::cout << "Ouptut: " << imageToString( source.outputImageType() ) << std::endl;
+  std::cout << "Input: " << source.countInputImages() << std::endl;
+  for(int i = 0; i < source.countInputImages(); ++i)
+  {
+    std::cout << "Input[" << i << "]: " << imageToString(source.inputImageType(i)) << std::endl;
+  }
+  return EXIT_SUCCESS;
+}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/