[opengtl-commits] [362] use the changed function in the raw scripts and in the shiva interpreter

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


Revision: 362
Author:   cyrille
Date:     2008-09-03 23:05:44 +0200 (Wed, 03 Sep 2008)

Log Message:
-----------
use the changed function in the raw scripts and in the shiva interpreter

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/tests/raw/RawToColor.shiva
    trunk/OpenGTL/OpenShiva/tests/raw/RawToGray.shiva
    trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp


Modified: trunk/OpenGTL/OpenShiva/tests/raw/RawToColor.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/raw/RawToColor.shiva	2008-09-03 21:05:09 UTC (rev 361)
+++ trunk/OpenGTL/OpenShiva/tests/raw/RawToColor.shiva	2008-09-03 21:05:44 UTC (rev 362)
@@ -27,4 +27,9 @@
     result.data[index] = v;
     result.data[3] = 1.0;
   }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
+
 }

Modified: trunk/OpenGTL/OpenShiva/tests/raw/RawToGray.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/raw/RawToGray.shiva	2008-09-03 21:05:09 UTC (rev 361)
+++ trunk/OpenGTL/OpenShiva/tests/raw/RawToGray.shiva	2008-09-03 21:05:44 UTC (rev 362)
@@ -6,4 +6,8 @@
     result.data = v;
     result[3] = 1.0;
   }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
 }

Modified: trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp	2008-09-03 21:05:09 UTC (rev 361)
+++ trunk/OpenGTL/OpenShiva/tools/interpreter/Shiva.cpp	2008-09-03 21:05:44 UTC (rev 362)
@@ -140,7 +140,7 @@
       std::getline(in,str);
     }
     int channelsCount = 3;
-    GTLCore::PixelDescription pixel( GTLCore::Type::UnsignedInteger8, channelsCount );
+    GTLCore::PixelDescription pixel( GTLCore::Type::UnsignedInteger16, channelsCount );
     OpenShiva::Kernel p(fileName, channelsCount);
     p.setSource( source );
     p.compile();
@@ -156,8 +156,8 @@
     {
       region = p.generated();
     }
-    GTLCore::Image image( region.bottom() - 1, region.right() - 1, pixel );
     std::list<GTLCore::AbstractImage*> images;
+    std::list<GTLCore::Region> inputDOD;
     for( std::list< GTLCore::String >::iterator it = fileNames.begin();
          it != fileNames.end(); ++it )
     {
@@ -167,13 +167,24 @@
         std::cerr << "Can't find decoder for " << *it << std::endl;
         return EXIT_FAILURE;
       }
-      GTLCore::AbstractImage* image = decoder->decode( *it, 0, &errMsg );
+      GTLCore::Region region;
+      GTLCore::AbstractImage* image = decoder->decode( *it, &region, &errMsg );
       if( not image )
       {
         std::cerr << "Can't read image " << *it << " : " << errMsg << std::endl;
       }
       images.push_back( image );
+      inputDOD.push_back( region );
     }
+    if( p.hasChangedFunction() )
+    {
+      int i = 0;
+      for( std::list<GTLCore::Region>::iterator it = inputDOD.begin(); it != inputDOD.end(); ++it, ++i)
+      {
+        region += p.changed( *it, i, inputDOD );
+      }
+    }
+    GTLCore::Image image( region.right() - 1, region.bottom() - 1, pixel );
     p.evaluatePixeles( GTLCore::Region(region.x() , region.y(), region.width(), region.height()), images, &image );
     if( showAssembly )
     {
@@ -185,7 +196,7 @@
       std::cerr << "Can't find encoder for " << outputFileName << std::endl;
       return EXIT_FAILURE;
     }
-    if( not encoder->encode( &image, GTLCore::Region(0, 0, width, height), outputFileName, &errMsg ) )
+    if( not encoder->encode( &image, GTLCore::Region(0, 0, image.width(), image.height()), outputFileName, &errMsg ) )
     {
       std::cerr << "Can't encode " << outputFileName << " : " << errMsg << std::endl;
       return EXIT_FAILURE;


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