Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r382 - in trunk: Core Core/Color SwigInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r382 - in trunk: Core Core/Color SwigInterface
  • Date: Mon, 13 Jun 2005 21:26:53 -0600 (MDT)

Author: bigler
Date: Mon Jun 13 21:26:50 2005
New Revision: 382

Added:
   trunk/Core/Color/ColorSpace_fancy.h
   trunk/Core/Color/GrayColor.cc
Modified:
   trunk/Core/CMakeLists.txt
   trunk/Core/Color/ColorSpace.h
   trunk/Core/Color/GrayColor.h
   trunk/Core/Color/RGBColor.cc
   trunk/Core/Color/RGBColor.h
   trunk/SwigInterface/manta.i
   trunk/SwigInterface/runmanta.py
Log:

Core/CMakeLists.txt

        Added RGBColor.cc and GrayColor.cc

Core/Color/ColorSpace.h
Core/Color/GrayColor.cc
Core/Color/GrayColor.h
Core/Color/RGBColor.cc
Core/Color/RGBColor.h

        Added toString function.

Core/Color/ColorSpace_fancy.h

        Implementation of ColorSpace<>::toString() function.


SwigInterface/manta.i

        Added __str__ function extensions for ColorSpace<>, RGBColor,
        and GrayColor.  Added extension for ColorSpace<> called scaled
        that returns a scaled version of the color (uses
        operator*(double) function).

SwigInterface/runmanta.py

        Scale the background color by 0.5 in order to match the C
        code.  Change max depth to match the C code.


Modified: trunk/Core/CMakeLists.txt
==============================================================================
--- trunk/Core/CMakeLists.txt   (original)
+++ trunk/Core/CMakeLists.txt   Mon Jun 13 21:26:50 2005
@@ -1,7 +1,9 @@
 
 SET (CORE_SOURCES)
 SET (CORE_SOURCES ${CORE_SOURCES}
-     Color/ColorDB.cc)
+     Color/ColorDB.cc
+     Color/RGBColor.cc
+     Color/GrayColor.cc)
 SET (CORE_SOURCES ${CORE_SOURCES}
      Geometry/PointVector.cc
      )

Modified: trunk/Core/Color/ColorSpace.h
==============================================================================
--- trunk/Core/Color/ColorSpace.h       (original)
+++ trunk/Core/Color/ColorSpace.h       Mon Jun 13 21:26:50 2005
@@ -6,6 +6,10 @@
 #include <Core/Color/RGBColor.h>
 #include <Core/Math/Expon.h>
 
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <sgi_stl_warnings_on.h>
+
 namespace Manta {
   template<typename Traits>
   class ColorSpace {
@@ -158,6 +162,15 @@
         returnValue.data[i] = Exp(scale*data[i]);
       return returnValue;
     }
+
+    // This a nasty function for a templated function that will be
+    // included by the world.  I don't want to have to include sstream
+    // in order to have the implementation here, so I will stick it
+    // (the implementation) in another header file called
+    // ColorSpace_fancy.h.  If you want to use this function include
+    // that header file and it will get instantiated properly.
+    std::string toString() const;
+    
   protected:
     // DO NOT MAKE THIS PUBLIC!
     ComponentType data[NumComponents];

Added: trunk/Core/Color/ColorSpace_fancy.h
==============================================================================
--- (empty file)
+++ trunk/Core/Color/ColorSpace_fancy.h Mon Jun 13 21:26:50 2005
@@ -0,0 +1,24 @@
+#include <Core/Color/ColorSpace.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <sstream>
+#include <sgi_stl_warnings_on.h>
+
+namespace Manta {
+  
+  template<typename Traits>
+  std::string ColorSpace<Traits>::toString() const {
+    ostringstream out;
+    out << "ColorSpace("<<NumComponents<<")(";
+    for(int i=0;i<NumComponents-1;i++)
+      out << data[i] << ", ";
+    if (NumComponents > 0)
+      out << data[NumComponents-1] << ")";
+    return out.str();
+  }
+
+} // end namespace Manta
+
+
+

Added: trunk/Core/Color/GrayColor.cc
==============================================================================
--- (empty file)
+++ trunk/Core/Color/GrayColor.cc       Mon Jun 13 21:26:50 2005
@@ -0,0 +1,16 @@
+
+#include <Core/Color/GrayColor.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <sstream>
+#include <string>
+#include <sgi_stl_warnings_on.h>
+
+using namespace Manta;
+using namespace std;
+
+string GrayColor::toString() const {
+  ostringstream out;
+  out << "GrayColor("<<value<<")";
+  return out.str();
+}

Modified: trunk/Core/Color/GrayColor.h
==============================================================================
--- trunk/Core/Color/GrayColor.h        (original)
+++ trunk/Core/Color/GrayColor.h        Mon Jun 13 21:26:50 2005
@@ -2,6 +2,10 @@
 #ifndef Manta_Core_GrayColor_h
 #define Manta_Core_GrayColor_h
 
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <sgi_stl_warnings_on.h>
+
 namespace Manta {
   class GrayColor {
   public:
@@ -27,6 +31,8 @@
       return value;
     }
 
+    std::string toString() const;
+    
   protected:
     float value;
   };

Modified: trunk/Core/Color/RGBColor.cc
==============================================================================
--- trunk/Core/Color/RGBColor.cc        (original)
+++ trunk/Core/Color/RGBColor.cc        Mon Jun 13 21:26:50 2005
@@ -1,10 +1,16 @@
 
 #include <Core/Color/RGBColor.h>
+
 #include <sgi_stl_warnings_off.h>
-#include <iostream>
-#include <map>
+#include <sstream>
+#include <string>
 #include <sgi_stl_warnings_on.h>
 
 using namespace Manta;
 using namespace std;
 
+string RGBColor::toString() const {
+  ostringstream out;
+  out << "RGBColor("<<data[0]<<", "<<data[1]<<", "<<data[2]<<")";
+  return out.str();
+}

Modified: trunk/Core/Color/RGBColor.h
==============================================================================
--- trunk/Core/Color/RGBColor.h (original)
+++ trunk/Core/Color/RGBColor.h Mon Jun 13 21:26:50 2005
@@ -2,6 +2,10 @@
 #ifndef Manta_Core_RGBColor_h
 #define Manta_Core_RGBColor_h
 
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <sgi_stl_warnings_on.h>
+
 namespace Manta {
   class RGBColor {
   public:
@@ -51,6 +55,8 @@
       return data[i];
     }
 
+    std::string toString() const;
+    
   protected:
     float data[3];
   };

Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Mon Jun 13 21:26:50 2005
@@ -62,6 +62,7 @@
 #include <Core/Color/GrayColor.h>
 #include <Core/Color/Conversion.h>
 #include <Core/Color/ColorSpace.h>
+#include <Core/Color/ColorSpace_fancy.h>
 #include <Core/Color/ColorDB.h>
 %}
 
@@ -71,11 +72,37 @@
 %include <Core/Color/GrayColor.h>
 %include <Core/Color/Conversion.h>
 %include <Core/Color/ColorSpace.h>
+%include <Core/Color/ColorSpace_fancy.h>
 %include <Core/Color/ColorDB.h>
 
 namespace Manta {
   //  typedef ColorSpace<RGBTraits> Color;
   %template(Color) ColorSpace<RGBTraits>;
+
+  %extend ColorSpace<RGBTraits> {
+    %newobject __str__;
+    char* __str__() {
+      return strdup(self->toString().c_str());
+    }
+    ColorSpace<RGBTraits> scaled(double val) {
+      return self->operator*(val);
+    }
+  };
+  
+  
+  %extend RGBColor {
+    %newobject __str__;
+    char* __str__() {
+      return strdup(self->toString().c_str());
+    }
+  };
+  %extend GrayColor {
+    %newobject __str__;
+    char* __str__() {
+      return strdup(self->toString().c_str());
+    }
+  };
+  
 }
 
 %{

Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py     (original)
+++ trunk/SwigInterface/runmanta.py     Mon Jun 13 21:26:50 2005
@@ -16,7 +16,7 @@
 engine.createChannel("opengl", currentCamera, False, xres, yres)
 
 scene = Scene()
-bg = ConstantBackground(ColorDB.getNamedColor("SkyBlue3"))
+bg = ConstantBackground(ColorDB.getNamedColor("SkyBlue3").scaled(0.5))
 #bg = ConstantBackground(ColorDB.getNamedColor("green"))
 scene.setBackground(bg)
 red = Phong(Color(RGBColor(0.6, 0, 0)), Color(RGBColor(0.6,0.6,0.6)), 32, 
0.4)
@@ -45,7 +45,7 @@
 print lights
 
 scene.setLights(lights);
-scene.getRenderParameters().maxDepth = 1;
+scene.getRenderParameters().maxDepth = 5;
 
 
 #engine.setScene(createDefaultScene())




  • [MANTA] r382 - in trunk: Core Core/Color SwigInterface, bigler, 06/13/2005

Archive powered by MHonArc 2.6.16.

Top of page