Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1308 - in trunk: CMake Engine/PixelSamplers Image StandAlone


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1308 - in trunk: CMake Engine/PixelSamplers Image StandAlone
  • Date: Fri, 16 Mar 2007 15:37:50 -0700 (MST)

Author: bigler
Date: Fri Mar 16 15:37:49 2007
New Revision: 1308

Added:
   trunk/Engine/PixelSamplers/TimeViewSampler.cc
   trunk/Engine/PixelSamplers/TimeViewSampler.h
Modified:
   trunk/CMake/FindImageMagick++.cmake
   trunk/Engine/PixelSamplers/CMakeLists.txt
   trunk/Image/CMakeLists.txt
   trunk/StandAlone/manta.cc
Log:

CMake/FindImageMagick++.cmake
Image/CMakeLists.txt

  It now also looks for ImageMagick in the MacPorts directory
  (/opt/local).

  Added support for having ImageMagick in non standard places.
  
Engine/PixelSamplers/CMakeLists.txt
Engine/PixelSamplers/TimeViewSampler.cc
Engine/PixelSamplers/TimeViewSampler.h

  Added new PixelSampler that can display the time it took to render
  the fragment.

StandAlone/manta.cc

  You can now use TimeViewSampler by specifying -t or --timeview with
  optional args to --timeview.


Modified: trunk/CMake/FindImageMagick++.cmake
==============================================================================
--- trunk/CMake/FindImageMagick++.cmake (original)
+++ trunk/CMake/FindImageMagick++.cmake Fri Mar 16 15:37:49 2007
@@ -8,14 +8,31 @@
 #                                 an extra test to make sure that we actually
 #                                 have the development packages around.
 
-FIND_LIBRARY(ImageMagickPP_LIB "Magick++" "/usr/local/lib" "/usr/lib" )
+SET(system_path "/usr/local" "/usr")
+IF (APPLE)
+  SET(system_path ${system_path} "/opt/local")
+ENDIF (APPLE)
+# Append the appropiate lib and include
+SET(library_path "")
+SET(include_path "")
+FOREACH(path ${system_path})
+  SET(library_path ${library_path} "${path}/lib")
+  SET(include_path ${include_path} "${path}/include")
+ENDFOREACH(path)
 
-FIND_FILE(ImageMagickPP_H "Magick++.h" "/usr/local/include" "/usr/include" )
+FIND_LIBRARY(ImageMagickPP_LIB "Magick++" ${library_path} )
+
+FIND_FILE(ImageMagickPP_H "Magick++.h" ${include_path} )
 
 MARK_AS_ADVANCED(ImageMagickPP_LIB ImageMagickPP_H)
 
 IF(ImageMagickPP_H AND ImageMagickPP_LIB)
   SET(ImageMagickPP_FOUND TRUE)
+  GET_FILENAME_COMPONENT(ImageMagickPP_Include_Dir ${ImageMagickPP_H}
+                         PATH)
+  GET_FILENAME_COMPONENT(ImageMagickPP_Lib_Dir ${ImageMagickPP_LIB}
+                         PATH)
 ELSE(ImageMagickPP_H AND ImageMagickPP_LIB)
   SET(ImageMagickPP_FOUND FALSE)
 ENDIF(ImageMagickPP_H AND ImageMagickPP_LIB)
+

Modified: trunk/Engine/PixelSamplers/CMakeLists.txt
==============================================================================
--- trunk/Engine/PixelSamplers/CMakeLists.txt   (original)
+++ trunk/Engine/PixelSamplers/CMakeLists.txt   Fri Mar 16 15:37:49 2007
@@ -8,4 +8,6 @@
      PixelSamplers/NullSampler.cc
      PixelSamplers/SingleSampler.h
      PixelSamplers/SingleSampler.cc
+     PixelSamplers/TimeViewSampler.h
+     PixelSamplers/TimeViewSampler.cc
      )

Added: trunk/Engine/PixelSamplers/TimeViewSampler.cc
==============================================================================
--- (empty file)
+++ trunk/Engine/PixelSamplers/TimeViewSampler.cc       Fri Mar 16 15:37:49 
2007
@@ -0,0 +1,101 @@
+
+#include <Engine/PixelSamplers/TimeViewSampler.h>
+#include <Interface/Context.h>
+#include <Interface/Fragment.h>
+#include <Interface/RayPacket.h>
+#include <Interface/Renderer.h>
+#include <MantaSSE.h>
+#include <Core/Util/Args.h>
+#include <Core/Exceptions/IllegalArgument.h>
+
+#include <SCIRun/Core/Thread/Time.h>
+
+#include <iostream>
+
+using namespace Manta;
+
+PixelSampler* TimeViewSampler::create(const vector<string>& args)
+{
+  return new TimeViewSampler(args);
+}
+
+TimeViewSampler::TimeViewSampler(const vector<string>& args)
+  : child(0),
+    scale(1.e4),
+    active(true)
+{
+  int argc = static_cast<int>(args.size());
+  for(int i = 0; i<argc;i++){
+    string arg = args[i];
+    if(arg == "-scale"){
+      if(!getArg<Real>(i, args, scale))
+        throw IllegalArgument("TimeViewSampler -scale", i, args);
+    } else if (arg == "-help") {
+      usage();
+    }
+    else {
+      usage();
+      throw IllegalArgument("TimeViewSampler", i, args);
+    }
+  }
+}
+
+void TimeViewSampler::usage()
+{
+  cerr << "TimeViewSampler args:\n";
+  cerr << "\t-scale <Real>      - defaults to 10000 (1e4)\n";
+}
+
+TimeViewSampler::~TimeViewSampler()
+{
+}
+
+void TimeViewSampler::setupBegin(const SetupContext& context, int 
numChannels)
+{
+  if (child) child->setupBegin(context, numChannels);
+}
+
+void TimeViewSampler::setupDisplayChannel(SetupContext& context)
+{
+  if (child) child->setupDisplayChannel(context);
+}
+
+void TimeViewSampler::setupFrame(const RenderContext& context)
+{
+  if (child) child->setupFrame(context);
+}
+
+void TimeViewSampler::renderFragment(const RenderContext& context,
+                                     Fragment& fragment)
+{
+  double startTime;
+  if (active) {
+    startTime = SCIRun::Time::currentSeconds();
+  }
+  if (child) child->renderFragment(context, fragment);
+  if (active) {
+    double endTime = SCIRun::Time::currentSeconds();
+    double deltaTime = (endTime - startTime);
+    ColorComponent color = deltaTime*scale;
+    for(int i=fragment.begin();i<fragment.end();++i) {
+      for ( int c = 0; c < Color::NumComponents; c++ )
+        fragment.color[c][i] = color;
+    }
+  }
+}
+
+void TimeViewSampler::setPixelSampler(PixelSampler* new_child)
+{
+  child = new_child;
+}
+    
+void TimeViewSampler::setScale(ColorComponent new_scale)
+{
+  scale = new_scale;
+}
+
+void TimeViewSampler::setActive(bool activeOn)
+{
+  active = activeOn;
+}
+

Added: trunk/Engine/PixelSamplers/TimeViewSampler.h
==============================================================================
--- (empty file)
+++ trunk/Engine/PixelSamplers/TimeViewSampler.h        Fri Mar 16 15:37:49 
2007
@@ -0,0 +1,53 @@
+#ifndef MANTA_ENGINE_TIMEVIEWSAMPLER_H
+#define MANTA_ENGINE_TIMEVIEWSAMPLER_H
+
+#include <MantaTypes.h>
+#include <Interface/PixelSampler.h>
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <vector>
+#include <sgi_stl_warnings_on.h>
+
+namespace Manta {
+  using namespace std;
+  class TimeViewSampler : public PixelSampler {
+  public:
+    TimeViewSampler(const vector<string>& args);
+    virtual ~TimeViewSampler();
+
+    // From PixelSampler
+    virtual void setupBegin(const SetupContext&, int numChannels);
+    virtual void setupDisplayChannel(SetupContext&);
+    virtual void setupFrame(const RenderContext& context);
+    virtual void renderFragment(const RenderContext& context,
+                                Fragment& fragment);
+
+    // For the factory interface, but it shouldn't really be called
+    // from the factory anyway, since there isn't a mechanism in the
+    // factory for child classes.
+    static PixelSampler* create(const vector<string>& args);
+
+    // New methods
+    void setPixelSampler(PixelSampler* new_child);
+    PixelSampler* getPixelSampler() { return child; }
+    
+    void setScale(ColorComponent new_scale);
+    ColorComponent getScale() { return scale; }
+
+    void setActive(bool activeOn);
+    bool getActive() { return active; }
+  private:
+    TimeViewSampler(const TimeViewSampler&);
+    TimeViewSampler& operator=(const TimeViewSampler&);
+
+    // Prints out the usage
+    void usage();
+    
+    PixelSampler* child;
+    ColorComponent scale;
+    bool active;
+  };
+}
+
+
+#endif // #ifndef MANTA_ENGINE_TIMEVIEWSAMPLER_H

Modified: trunk/Image/CMakeLists.txt
==============================================================================
--- trunk/Image/CMakeLists.txt  (original)
+++ trunk/Image/CMakeLists.txt  Fri Mar 16 15:37:49 2007
@@ -30,6 +30,10 @@
 IF (ImageMagickPP_FOUND)
   # Add the ImageMagick files
   SET (ImageMagick_SRC ImageMagickFile.h ImageMagickFile.cc)
+  INCLUDE_DIRECTORIES(${ImageMagickPP_Include_Dir})
+  GET_SOURCE_FILE_PROPERTY(prop ImageMagickFile.cc COMPILE_FLAGS)
+#  SET_SOURCE_FILES_PROPERTIES(ImageMagickFile.cc
+#                              PROPERTIES INCLUDE_DIRECTORIES 
${ImageMagickPP_Include_Dir})
 ELSE(ImageMagickPP_FOUND)
   SET (ImageMagick_SRC ImageMagickFile.h ImageMagickFile-stub.cc)
 ENDIF(ImageMagickPP_FOUND)

Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc   (original)
+++ trunk/StandAlone/manta.cc   Fri Mar 16 15:37:49 2007
@@ -45,6 +45,7 @@
 #include <Core/Exceptions/UnknownComponent.h>
 #include <Core/Thread/Time.h>
 #include <Core/Util/About.h>
+#include <Engine/PixelSamplers/TimeViewSampler.h>
 
 // Default scene includes.
 #include <Core/Color/ColorDB.h>
@@ -135,6 +136,7 @@
   cerr << " -renderer S     - Use renderer S, valid renderers are:\n";
   printList(cerr, rtrt->listRenderers(), 2);
   cerr << " -scene S        - Render Scene S\n";
+  cerr << " -t, --timeview[=\"args\"] - Display a scaled view of the time it 
took to render some pixels.\n";
   
   Thread::exitAll(1);
 }
@@ -228,6 +230,9 @@
     bool channelCreated=false;
     bool stereo = false;
     bool compute_bb_camera = false;
+    bool timeView = false;
+    vector<string> timeViewArgs;
+    
 
     // Parse command line args.
     try {
@@ -360,6 +365,17 @@
           if (!getStringArg(i,args,stack_file))
             usage(factory);
         }
+        else if (arg == "-t") {
+          timeView = true;
+        }
+        else if (arg.find("--timeview") == 0) {
+          timeView = true;
+          // Pull out the args
+          if (arg.size() > 10) {
+            string argString(arg, 11, arg.size()-9);
+            parseArgs(argString, timeViewArgs);
+          }
+        }
       }
     }
     catch (SCIRun::Exception& e) {
@@ -414,7 +430,14 @@
       ReadContext context( rtrt );
       make_stack( context, args );
     }
-    
+
+    if (timeView) {
+      // Pull out the current pixel sampler and replace it.
+      PixelSampler* currentPixelSampler = rtrt->getPixelSampler();
+      TimeViewSampler* tvs = new TimeViewSampler(timeViewArgs);
+      tvs->setPixelSampler(currentPixelSampler);
+      rtrt->setPixelSampler(tvs);
+    }
 
     rtrt->beginRendering(true);
     delete rtrt;




  • [MANTA] r1308 - in trunk: CMake Engine/PixelSamplers Image StandAlone, bigler, 03/16/2007

Archive powered by MHonArc 2.6.16.

Top of page