Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r926 - in trunk: Engine/Control Interface StandAlone UserInterface


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r926 - in trunk: Engine/Control Interface StandAlone UserInterface
  • Date: Fri, 10 Feb 2006 18:42:27 -0700 (MST)

Author: abe
Date: Fri Feb 10 18:42:26 2006
New Revision: 926

Modified:
   trunk/Engine/Control/RTRT.cc
   trunk/Engine/Control/RTRT.h
   trunk/Interface/MantaInterface.h
   trunk/Interface/Material.h
   trunk/Interface/Transaction.cc
   trunk/Interface/Transaction.h
   trunk/StandAlone/manta_path_plot.pl
   trunk/UserInterface/CameraPathAutomator.cc
   trunk/UserInterface/CameraPathAutomator.h
Log:


Added flag to transactions to specify queue operations. For example if 
TransactionBase::CONTINUE is specified Manta will stop processing 
transactions and render the next frame.
M    Engine/Control/RTRT.cc
M    Engine/Control/RTRT.h
M    Interface/Material.h
M    Interface/MantaInterface.h
M    Interface/Transaction.cc
M    Interface/Transaction.h

Updated CameraPathAutomator to avoid timing conditions when -sync 1 is used.
Added sixth column to output for benchmark containing time since the 
beginning of the path.
M    UserInterface/CameraPathAutomator.cc
M    UserInterface/CameraPathAutomator.h
M    StandAlone/manta_path_plot.pl



Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc        (original)
+++ trunk/Engine/Control/RTRT.cc        Fri Feb 10 18:42:26 2006
@@ -547,29 +547,46 @@
   }
 }
 
+///////////////////////////////////////////////////////////////////////////////
+// POST TRANSACTIONS  
+///////////////////////////////////////////////////////////////////////////////
 void RTRT::postTransactions(bool& changed)
 {
   if(transactions.size() > 0){
+
+    // Lock the queue.
     transaction_lock.lock();
     changed = true;
-    for(TransactionListType::iterator iter = transactions.begin();
-        iter != transactions.end(); iter++){
-      TransactionBase* transaction = *iter;
-      if(verbose_transactions){
-        cerr << "Apply transaction: " << transaction->getName() << " : ";
-        transaction->printValue(cerr);
-        cerr << " : ";
-        transaction->printOp(cerr);
-        cerr << " : ";
-      }
+
+    int flag = 0;
+    while (transactions.size()) {
+      // Pop the first transaction from the queue.
+      TransactionBase *transaction = *(transactions.begin());
+      transactions.pop_front();
+
+      // Apply the transaction.
       transaction->apply();
-      if(verbose_transactions){
-        transaction->printValue(cerr);
-        cerr << '\n';
-      }
+      int flag = transaction->getFlag();
+
+      // Delete the transaction.
       delete transaction;
+
+      // Determine if the transaction contains any queue operations.
+      if (flag == TransactionBase::CONTINUE) {
+        // Stop processing transactions and continue the pipeline.
+        break;
+      }
+      else if (flag == TransactionBase::PURGE) {
+        // Remove all remaining transactions from the queue.
+        while (transactions.size()) {
+          transaction = *(transactions.begin());
+          transactions.pop_front();
+          delete transaction;
+        }
+      }
     }
-    transactions.resize(0);
+
+    // Unlock the queue.
     transaction_lock.unlock();
   }
 }

Modified: trunk/Engine/Control/RTRT.h
==============================================================================
--- trunk/Engine/Control/RTRT.h (original)
+++ trunk/Engine/Control/RTRT.h Fri Feb 10 18:42:26 2006
@@ -15,6 +15,7 @@
 #include <map>
 #include <set>
 #include <vector>
+#include <list>
 
 // The following are used by shootOneRay (experimental)
 #include <MantaTypes.h>
@@ -151,7 +152,7 @@
     inline void barrierWait();
 
     // Transactions
-    virtual void addTransaction(TransactionBase*);
+    virtual void addTransaction(TransactionBase* );
                
                // Debug:
                void shootOneRay( Color &result_color, RayPacket 
&result_rays, Real image_x, Real image_y, int channel_index );
@@ -230,7 +231,7 @@
     
 
     // Transactions
-    typedef vector<TransactionBase*> TransactionListType;
+    typedef list<TransactionBase*> TransactionListType;
     TransactionListType transactions;
     SCIRun::Mutex transaction_lock;
     void postTransactions(bool& changed);

Modified: trunk/Interface/MantaInterface.h
==============================================================================
--- trunk/Interface/MantaInterface.h    (original)
+++ trunk/Interface/MantaInterface.h    Fri Feb 10 18:42:26 2006
@@ -165,14 +165,13 @@
     virtual void addTransaction(TransactionBase*) = 0;
                
     template<class T, class Op>
-      void addTransaction(const char* name, TValue<T>& value, Op op)
-      {
-       addTransaction(new Transaction<T, Op>(name, value, op));
-      }
-    void addTransaction(const char* name, CallbackBase_0Data* callback)
-      {
-        addTransaction(new CallbackTransaction(name, callback));
-      }
+    void addTransaction(const char* name, TValue<T>& value, Op op, int flag 
= TransactionBase::DEFAULT ) {
+      addTransaction(new Transaction<T, Op>(name, value, op, flag ));
+    }
+    
+    void addTransaction(const char* name, CallbackBase_0Data* callback, int 
flag = TransactionBase::DEFAULT ) {
+      addTransaction(new CallbackTransaction(name, callback, flag ));
+    }
 
   protected:
     MantaInterface();

Modified: trunk/Interface/Material.h
==============================================================================
--- trunk/Interface/Material.h  (original)
+++ trunk/Interface/Material.h  Fri Feb 10 18:42:26 2006
@@ -41,10 +41,10 @@
   public:
     Material();
     virtual ~Material();
-
     
     virtual void preprocess(const PreprocessContext&) = 0;
     virtual void shade(const RenderContext& context, RayPacket& rays) const 
= 0;
+
   private:
     // Material(const Material&);
     // Material& operator=(const Material&);

Modified: trunk/Interface/Transaction.cc
==============================================================================
--- trunk/Interface/Transaction.cc      (original)
+++ trunk/Interface/Transaction.cc      Fri Feb 10 18:42:26 2006
@@ -3,8 +3,8 @@
 
 using namespace Manta;
 
-TransactionBase::TransactionBase(const char* name)
-  : name(name)
+TransactionBase::TransactionBase(const char* name, int flag_ )
+  : name(name), flag( flag_ )
 {
 }
 

Modified: trunk/Interface/Transaction.h
==============================================================================
--- trunk/Interface/Transaction.h       (original)
+++ trunk/Interface/Transaction.h       Fri Feb 10 18:42:26 2006
@@ -12,30 +12,38 @@
 
   class TransactionBase {
   public:
+    // Queue loop behavior following this transaction.
+    enum {
+      DEFAULT  = 0, // Process this transaction and then the next.
+                    // (Until either all are processed or another flag is 
encountered.)
+      CONTINUE,     // Process this transaction and then continue render.
+                    // (Other transactions processed following the next 
frame.)
+      PURGE         // Process this transaction and then purge all remaining 
from the queue.
+    };
+          
     virtual void apply() = 0;
     virtual void printValue(std::ostream&) = 0;
     virtual void printOp(std::ostream&) = 0;
     virtual ~TransactionBase();
 
-    const char* getName()
-    {
-      return name;
-    }
+    const char* getName() const { return name; }
+    int getFlag() const { return flag; };
+    
   protected:
-    TransactionBase(const char* name);
+    TransactionBase(const char* name, int flag_=TransactionBase::DEFAULT );
   private:
     TransactionBase(const TransactionBase&);
     TransactionBase& operator=(const TransactionBase&);
 
     const char* name;
+    int flag;
   };
 
   template<class T, class Op> class Transaction : public TransactionBase {
   public:
-    Transaction(const char* name, TValue<T>& value, Op op)
+    Transaction(const char* name, TValue<T>& value, Op op, int flag = 
TransactionBase::DEFAULT )
       : TransactionBase(name), value(value), op(op)
-    {
-    }
+    {   }
 
     virtual void apply()
     {
@@ -66,10 +74,9 @@
 
   class CallbackTransaction : public TransactionBase {
   public:
-    CallbackTransaction(const char* name, CallbackBase_0Data* callback)
-      : TransactionBase(name), callback(callback)
-    {
-    }
+    CallbackTransaction(const char* name, CallbackBase_0Data* callback, int 
flag)
+      : TransactionBase(name,flag), callback(callback)
+    { }
 
     virtual void apply()
     {

Modified: trunk/StandAlone/manta_path_plot.pl
==============================================================================
--- trunk/StandAlone/manta_path_plot.pl (original)
+++ trunk/StandAlone/manta_path_plot.pl Fri Feb 10 18:42:26 2006
@@ -20,7 +20,7 @@
 $title         = "Manta Camera Path Benchmark";
 $plot_x        = 2;
 $plot_y        = 5;
-$plot_columns  = 5;
+$plot_columns  = 6;
 $keep          = 1;
 $line          = 0;
 

Modified: trunk/UserInterface/CameraPathAutomator.cc
==============================================================================
--- trunk/UserInterface/CameraPathAutomator.cc  (original)
+++ trunk/UserInterface/CameraPathAutomator.cc  Fri Feb 10 18:42:26 2006
@@ -109,7 +109,7 @@
   // Load the input file.
   FILE *file = fopen( file_name.c_str(), "r" );
   if (file == 0) {
-    throw new ErrnoException( "Cannot open camera path file: " + file_name, 
+    throw  ErrnoException( "Cannot open camera path file: " + file_name, 
                           errno, __FILE__, __LINE__ );
   }
   
@@ -131,7 +131,7 @@
 
   // Check to make sure we got enough control points
   if (total_points < 4) {
-    throw new InternalError( "Didn't find at least 4 control points in the 
file: " + file_name,
+    throw  InternalError( "Didn't find at least 4 control points in the 
file: " + file_name,
                              __FILE__, __LINE__ );
   }
 
@@ -167,13 +167,13 @@
     if (name == "delta_t") {
       if (!getArg(i,args,delta_t)) {
         sprintf(error_message, "CameraPathAutomator input line: %d", 
line_num );
-        throw new IllegalArgument(error_message, i, args);
+        throw  IllegalArgument(error_message, i, args);
       }
     }
     else if (name == "delta_time") {
       if (!getArg(i,args,delta_time)) {
         sprintf(error_message, "CameraPathAutomator input line: %d", 
line_num );
-        throw new IllegalArgument(error_message, i, args);
+        throw  IllegalArgument(error_message, i, args);
       }
     }
     else if (name == "control") {
@@ -190,21 +190,21 @@
         if (args[i] == "-eye") {
           if (!getVectorArg(i,args,eye_)) {
             sprintf(error_message, "CameraPathAutomator -eye input line: 
%d", line_num );
-            throw new IllegalArgument(error_message, i, args);
+            throw  IllegalArgument(error_message, i, args);
           }
           got_eye = true;
         }
         else if (args[i] == "-lookat") {
           if (!getVectorArg(i,args,lookat_)) {
             sprintf(error_message, "CameraPathAutomator -lookat input line: 
%d", line_num );
-            throw new IllegalArgument(error_message, i, args);
+            throw  IllegalArgument(error_message, i, args);
           }
           got_lookat = true;
         }
         else if (args[i] == "-up") {
           if (!getVectorArg(i,args,up_)) {
             sprintf(error_message, "CameraPathAutomator -up input line: %d", 
line_num );
-            throw new IllegalArgument(error_message, i, args);
+            throw  IllegalArgument(error_message, i, args);
           }
           got_up = true;
         }
@@ -220,7 +220,7 @@
       }
       else {
         sprintf(error_message, "CameraPathAutomator incomplete spec input 
line: %d", line_num );
-        throw new IllegalArgument(error_message, line_num, args);
+        throw  IllegalArgument(error_message, line_num, args);
       }
     }
     
@@ -335,7 +335,7 @@
   int first_point = SCIRun::Max(1,SCIRun::Min(interval_start,last_point));
   
   int start_frame = getMantaInterface()->getCurrentFrame();
-  double start_seconds = SCIRun::Time::currentSeconds();
+  start_seconds = SCIRun::Time::currentSeconds();
   
   std::cerr << "Beginning camera path " << total_points 
             << " control points. Using interval " << first_point << ":" << 
last_point << std::endl;
@@ -363,15 +363,16 @@
         catmull_rom_interpolate( &lookat[current_point], t, current_lookat);
         catmull_rom_interpolate( &up[current_point],     t, current_up );
 
+        // Record the time of this transaction before a potential sync
+        double start_time = SCIRun::Time::currentSeconds();
+        
         // Send the transaction to manta.
         getMantaInterface()->addTransaction
           ("CameraPathAutomator",
            Callback::create(this, &CameraPathAutomator::mantaSetCamera,
                             Point(current_eye), Point(current_lookat),
-                            current_up ));
+                            current_up ) );
 
-        // Record the time of this transaction before a potential sync
-        double start_time = SCIRun::Time::currentSeconds();
 
         // Check to see if this is a synchronization point.
         if (sync_frames && ((transaction_number % sync_frames) == 0)) {
@@ -380,7 +381,7 @@
           getMantaInterface()->addTransaction
             ("CameraPathAutomator-Sync",
              Callback::create(this, &CameraPathAutomator::mantaSynchronize,
-                              transaction_number ));
+                              transaction_number ), 
TransactionBase::CONTINUE );
 
           // Wait for the render thread.
           synchronize_barrier.wait( 2 );
@@ -433,6 +434,8 @@
   double current_sync_seconds = SCIRun::Time::currentSeconds();
   int  current_sync_frame   = getMantaInterface()->getCurrentFrame();
 
+  double total_elapse_seconds = current_sync_seconds - start_seconds;
+  
   double elapse_seconds = current_sync_seconds - last_sync_seconds;
   int  elapse_frame   = current_sync_frame   - last_sync_frame;
 
@@ -444,7 +447,10 @@
             << issue_transaction << " "
             << elapse_frame << " "
             << elapse_seconds << " "
-            << elapse_frame/elapse_seconds << std::endl;
+            << elapse_frame/elapse_seconds << " "
+            << total_elapse_seconds
+            << std::endl;
+  // stdout flush is necessary so that output occurs before program 
terminates.
 }
 
 
///////////////////////////////////////////////////////////////////////////////
@@ -456,7 +462,7 @@
 
   FILE *file = fopen( file_name.c_str(), "w" );
   if (file == 0) {
-    throw new ErrnoException( "Cannot open camera path file: " + file_name, 
+    throw  ErrnoException( "Cannot open camera path file: " + file_name, 
                           errno, __FILE__, __LINE__ );
   }
 

Modified: trunk/UserInterface/CameraPathAutomator.h
==============================================================================
--- trunk/UserInterface/CameraPathAutomator.h   (original)
+++ trunk/UserInterface/CameraPathAutomator.h   Fri Feb 10 18:42:26 2006
@@ -75,6 +75,7 @@
 
     double last_sync_seconds;
     int  last_sync_frame;
+    double start_seconds;
 
     // Number of frames between synchronization points.
     int sync_frames;




  • [MANTA] r926 - in trunk: Engine/Control Interface StandAlone UserInterface, abe, 02/10/2006

Archive powered by MHonArc 2.6.16.

Top of page