Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1801 - in trunk: . CMake Core Core/Color Core/Exceptions Core/Geometry Core/Persistent Engine/Factory Interface Model/AmbientLights Model/Backgrounds Model/Groups Model/Lights Model/Materials Model/Primitives Model/TexCoordMappers Model/Textures StandAlone
- Date: Fri, 2 Nov 2007 00:46:06 -0600 (MDT)
Author: sparker
Date: Fri Nov 2 00:45:48 2007
New Revision: 1801
Added:
trunk/CMake/FindLibXML2.cmake
- copied unchanged from r1800,
branches/persistent/CMake/FindLibXML2.cmake
trunk/Core/Color/RGBTraits.cc
- copied unchanged from r1800,
branches/persistent/Core/Color/RGBTraits.cc
trunk/Core/Exceptions/SerializationError.cc
- copied unchanged from r1800,
branches/persistent/Core/Exceptions/SerializationError.cc
trunk/Core/Exceptions/SerializationError.h
- copied unchanged from r1800,
branches/persistent/Core/Exceptions/SerializationError.h
trunk/Core/Persistent/
- copied from r1800, branches/persistent/Core/Persistent/
trunk/Core/Persistent/Archive.cc
- copied unchanged from r1800,
branches/persistent/Core/Persistent/Archive.cc
trunk/Core/Persistent/Archive.h
- copied unchanged from r1800,
branches/persistent/Core/Persistent/Archive.h
trunk/Core/Persistent/ArchiveElement.cc
- copied unchanged from r1800,
branches/persistent/Core/Persistent/ArchiveElement.cc
trunk/Core/Persistent/ArchiveElement.h
- copied, changed from r1800,
branches/persistent/Core/Persistent/ArchiveElement.h
trunk/Core/Persistent/MantaRTTI.cc
- copied unchanged from r1800,
branches/persistent/Core/Persistent/MantaRTTI.cc
trunk/Core/Persistent/MantaRTTI.h
- copied unchanged from r1800,
branches/persistent/Core/Persistent/MantaRTTI.h
trunk/Core/Persistent/XMLArchive.cc
- copied, changed from r1800,
branches/persistent/Core/Persistent/XMLArchive.cc
trunk/Core/Persistent/stdRTTI.h
- copied unchanged from r1800,
branches/persistent/Core/Persistent/stdRTTI.h
trunk/Interface/Clonable.cc
- copied unchanged from r1800, branches/persistent/Interface/Clonable.cc
trunk/Interface/InterfaceRTTI.cc
- copied unchanged from r1800,
branches/persistent/Interface/InterfaceRTTI.cc
trunk/Interface/InterfaceRTTI.h
- copied unchanged from r1800,
branches/persistent/Interface/InterfaceRTTI.h
trunk/Interface/Interpolable.cc
- copied unchanged from r1800,
branches/persistent/Interface/Interpolable.cc
trunk/Interface/RenderParameters.cc
- copied unchanged from r1800,
branches/persistent/Interface/RenderParameters.cc
trunk/StandAlone/savescene.cc
- copied, changed from r1800,
branches/persistent/StandAlone/savescene.cc
Modified:
trunk/CMakeLists.txt
trunk/Core/CMakeLists.txt
trunk/Core/Color/ColorSpace.h
trunk/Core/Color/RGBTraits.h
trunk/Core/Geometry/Vector.cc
trunk/Core/Geometry/Vector.h
trunk/Engine/Factory/Factory.cc
trunk/Engine/Factory/Factory.h
trunk/Interface/CMakeLists.txt
trunk/Interface/Camera.cc
trunk/Interface/Camera.h
trunk/Interface/Clonable.h
trunk/Interface/Interpolable.h
trunk/Interface/Light.h
trunk/Interface/LightSet.cc
trunk/Interface/LightSet.h
trunk/Interface/Object.h
trunk/Interface/RenderParameters.h
trunk/Interface/Scene.cc
trunk/Interface/Scene.h
trunk/Interface/TexCoordMapper.h
trunk/Interface/Texture.h
trunk/Model/AmbientLights/ArcAmbient.cc
trunk/Model/AmbientLights/ArcAmbient.h
trunk/Model/Backgrounds/LinearBackground.cc
trunk/Model/Backgrounds/LinearBackground.h
trunk/Model/Groups/Group.cc
trunk/Model/Groups/Group.h
trunk/Model/Groups/Mesh.cc
trunk/Model/Lights/PointLight.cc
trunk/Model/Lights/PointLight.h
trunk/Model/Materials/Lambertian.cc
trunk/Model/Materials/Lambertian.h
trunk/Model/Materials/LitMaterial.cc
trunk/Model/Materials/LitMaterial.h
trunk/Model/Materials/MetalMaterial.cc
trunk/Model/Materials/MetalMaterial.h
trunk/Model/Materials/OpaqueShadower.cc
trunk/Model/Materials/OpaqueShadower.h
trunk/Model/Primitives/Heightfield.cc
trunk/Model/Primitives/KenslerShirleyTriangle.cc
trunk/Model/Primitives/Parallelogram.cc
trunk/Model/Primitives/Parallelogram.h
trunk/Model/Primitives/PrimitiveCommon.cc
trunk/Model/Primitives/PrimitiveCommon.h
trunk/Model/Primitives/Sphere.cc
trunk/Model/Primitives/Sphere.h
trunk/Model/Primitives/WaldTriangle.cc
trunk/Model/TexCoordMappers/UniformMapper.cc
trunk/Model/TexCoordMappers/UniformMapper.h
trunk/Model/Textures/CheckerTexture.h
trunk/Model/Textures/Constant.h
trunk/StandAlone/CMakeLists.txt
trunk/TODO
Log:
Groundwork persistent object functionality. Improvements are still needed
and documentation will be forthcoming.
Try this:
bin/savescene lib/libscene_0.dylib s0.rtml
bin/manta -scene s0.rtml
Modified: trunk/CMakeLists.txt
==============================================================================
--- trunk/CMakeLists.txt (original)
+++ trunk/CMakeLists.txt Fri Nov 2 00:45:48 2007
@@ -73,6 +73,8 @@
INCLUDE (${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindTeem.cmake)
# Locate pabst
INCLUDE (${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindPabst.cmake)
+# Locate libxml2
+INCLUDE (${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindLibXML2.cmake)
## We need SCI_NOPERSISTENT to be defined
FORCE_ADD_FLAGS(CMAKE_CXX_FLAGS "-DSCI_NOPERSISTENT")
Modified: trunk/Core/CMakeLists.txt
==============================================================================
--- trunk/Core/CMakeLists.txt (original)
+++ trunk/Core/CMakeLists.txt Fri Nov 2 00:45:48 2007
@@ -6,6 +6,8 @@
Color/ColorSpace.h
Color/RGBColor.h
Color/RGBColor.cc
+ Color/RGBTraits.h
+ Color/RGBTraits.cc
Color/GrayColor.h
Color/GrayColor.cc
Color/RegularColorMap.h
@@ -25,6 +27,8 @@
Exceptions/InputError.cc
Exceptions/OutputError.h
Exceptions/OutputError.cc
+ Exceptions/SerializationError.h
+ Exceptions/SerializationError.cc
)
SET (CORE_SOURCES ${CORE_SOURCES}
Geometry/AffineTransform.h
@@ -62,6 +66,22 @@
Math/ipow.h
)
SET (CORE_SOURCES ${CORE_SOURCES}
+ Persistent/Archive.h
+ Persistent/Archive.cc
+ Persistent/ArchiveElement.h
+ Persistent/ArchiveElement.cc
+ Persistent/MantaRTTI.h
+ Persistent/MantaRTTI.cc
+ )
+
+IF (LIBXML2_INCLUDE)
+ SET (CORE_SOURCES ${CORE_SOURCES}
+ Persistent/XMLArchive.cc
+ )
+ INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE})
+ENDIF (LIBXML2_INCLUDE)
+
+SET (CORE_SOURCES ${CORE_SOURCES}
Util/AlignedAllocator.h
Util/AlignedAllocator.cc
Util/ApproximatePriorityQueue.h
@@ -87,9 +107,9 @@
ADD_LIBRARY (Manta_Core ${CORE_SOURCES})
TARGET_LINK_LIBRARIES(Manta_Core SCIRun_Core)
+TARGET_LINK_LIBRARIES(Manta_Core ${LIBXML2_LIBRARY})
# The Manta_Core_XUtils library
ADD_LIBRARY (Manta_Core_XUtils XUtils/XHelper.cc)
TARGET_LINK_LIBRARIES(Manta_Core_XUtils Manta_Core SCIRun_Core)
TARGET_LINK_LIBRARIES(Manta_Core_XUtils ${OPENGL_LIBRARIES} ${X11_LIBRARIES})
-
Modified: trunk/Core/Color/ColorSpace.h
==============================================================================
--- trunk/Core/Color/ColorSpace.h (original)
+++ trunk/Core/Color/ColorSpace.h Fri Nov 2 00:45:48 2007
@@ -7,10 +7,14 @@
#include <Core/Color/RGBColor.h>
#include <Core/Color/RGBTraits.h>
#include <Core/Math/Expon.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/MantaRTTI.h>
#include <sgi_stl_warnings_off.h>
+#include <sstream>
#include <string>
#include <sgi_stl_warnings_on.h>
+#include <ctype.h>
namespace Manta {
template<typename Traits> class ColorSpace {
@@ -247,12 +251,15 @@
ComponentType data[NumComponents];
#endif
+ void readwrite(ArchiveElement*);
+
protected:
// DO NOT MAKE THIS PUBLIC!
ColorSpace(ComponentType fillValue) {
for(int i=0;i<NumComponents;i++)
data[i] = fillValue;
}
+ friend class MantaRTTI<ColorSpace<Traits> >;
};
template<typename Traits, typename Scalar>
@@ -263,6 +270,82 @@
returnValue[i] = scale * s[i];
return returnValue;
}
+
+ template<typename Traits>
+ class MantaRTTI<ColorSpace<Traits> >
+ : public MantaRTTI_ConcreteClass<ColorSpace<Traits> >,
+ public MantaRTTI_BaseClass<ColorSpace<Traits> >
+ {
+ public:
+ static std::string getPublicClassname() {
+ return "Color";
+ }
+ static inline int hexvalue(char c){
+ if(c >= '0' && c <= '9')
+ return c-'0';
+ else if(c >= 'a' && c <= 'f')
+ return c-'a';
+ else if(c >= 'A' && c <= 'F')
+ return c-'A';
+ else
+ return 0;
+ }
+ static void readwrite(ArchiveElement* archive, ColorSpace<Traits>& data)
{
+ if(archive->reading()){
+ // Read a number of different color representations
+ std::string str;
+ archive->readwrite("data", str);
+ if(str[0] == '#'){
+ // Parse html style hex string
+ std::string::size_type idx = 1;
+ while(idx < str.size() && ((str[idx] >= '0' && str[idx] <= '9') ||
(str[idx] >= 'a' && str[idx] <= 'f') || (str[idx] >= 'A' && str[idx] <= 'F')))
+ idx++;
+
+ int r, g, b;
+ if(idx == 7){
+ r = (hexvalue(str[1])<<4) + hexvalue(str[2]);
+ g = (hexvalue(str[3])<<4) + hexvalue(str[4]);
+ b = (hexvalue(str[5])<<4) + hexvalue(str[6]);
+ } else if(idx == 4){
+ r = (hexvalue(str[1])<<4) + hexvalue(str[1]);
+ g = (hexvalue(str[2])<<4) + hexvalue(str[2]);
+ b = (hexvalue(str[3])<<4) + hexvalue(str[3]);
+ } else {
+ throw SerializationError("Error parsing rgb triple: " + str);
+ }
+ while(idx < str.size() && !isspace(str[idx]))
+ idx++;
+ if(idx != str.size())
+ throw SerializationError("Error parsing rgb triple: " + str);
+
+ Traits::convertFrom(data.data, RGB(r/255., g/255., b/255.));
+ } else if(str.substr(0, 4) == "rgb:"){
+ // RGB triple
+ std::istringstream in(str.substr(4));
+ float r,g,b;
+ in >> r >> g >> b;
+ if(!in)
+ throw SerializationError("Error parsing rgb value: " + str);
+ Traits::convertFrom(data.data, RGB(r, g, b));
+ } else {
+ // Try to parse as an rgb triple
+ std::istringstream in(str);
+ float r,g,b;
+ in >> r >> g >> b;
+ if(!in)
+ throw SerializationError("Unknown color value: " + str);
+ Traits::convertFrom(data.data, RGB(r, g, b));
+ }
+ } else {
+ Traits::readwrite(archive, data.data);
+ }
+ }
+ static PersistentStorage::StorageHint storageHint() {
+ return PersistentStorage::Lightweight;
+ }
+ static bool force_initialize;
+ };
+
}
#endif
Modified: trunk/Core/Color/RGBTraits.h
==============================================================================
--- trunk/Core/Color/RGBTraits.h (original)
+++ trunk/Core/Color/RGBTraits.h Fri Nov 2 00:45:48 2007
@@ -4,8 +4,10 @@
#include <Core/Color/RGBColor.h>
#include <Core/Color/Conversion.h>
+#include <Core/Persistent/MantaRTTI.h>
namespace Manta {
+ class ArchiveElement;
class RGBTraits {
public:
typedef float ComponentType;
@@ -39,6 +41,9 @@
static ComponentType luminance(const ComponentType data[3]) {
return data[0] * ComponentType(0.3) + data[1] * ComponentType(0.59) +
data[2] * ComponentType(0.11);
}
+
+ static void readwrite(ArchiveElement* archive, ComponentType data[3]);
+
};
}
Modified: trunk/Core/Geometry/Vector.cc
==============================================================================
--- trunk/Core/Geometry/Vector.cc (original)
+++ trunk/Core/Geometry/Vector.cc Fri Nov 2 00:45:48 2007
@@ -28,11 +28,14 @@
*/
#include <Core/Geometry/Vector.h>
+#include <Core/Persistent/ArchiveElement.h>
#include <sgi_stl_warnings_off.h>
#include <iostream>
#include <sgi_stl_warnings_on.h>
+using namespace Manta;
+
namespace Manta {
std::ostream& operator<< (std::ostream& os, const Vector& v) {
os << v[0] << " ";
@@ -48,3 +51,11 @@
return is;
}
}
+
+MANTA_REGISTER_CLASS(Vector);
+
+void Vector::readwrite(ArchiveElement* archive)
+{
+ archive->readwrite("data", data, 3);
+}
+
Modified: trunk/Core/Geometry/Vector.h
==============================================================================
--- trunk/Core/Geometry/Vector.h (original)
+++ trunk/Core/Geometry/Vector.h Fri Nov 2 00:45:48 2007
@@ -42,6 +42,7 @@
#include <Core/Math/Expon.h>
#include <Core/Math/MinMax.h>
#include <Core/Math/MiscMath.h>
+#include <Core/Persistent/MantaRTTI.h>
#include <sgi_stl_warnings_off.h>
#include <iosfwd>
@@ -479,8 +480,10 @@
friend Vector Min(const Vector& v1, const Vector& v2);
friend Vector Max(const Vector& v1, const Vector& v2);
friend Vector Interpolate(const Vector& v1, const Vector& v2, Real
weight);
+ friend Vector Interpolate(const Vector& v1, const Vector& v2, const
Vector& weight);
#endif
+ void readwrite(ArchiveElement*);
//private:
Real data[3];
@@ -576,6 +579,8 @@
std::ostream& operator<< (std::ostream& os, const Vector& v);
std::istream& operator>> (std::istream& is, Vector& v);
+
+ MANTA_DECLARE_RTTI_BASECLASS(Vector, ConcreteClass,
readwriteMethod_lightweight);
}
namespace SCIRun {
Copied: trunk/Core/Persistent/ArchiveElement.h (from r1800,
branches/persistent/Core/Persistent/ArchiveElement.h)
==============================================================================
--- branches/persistent/Core/Persistent/ArchiveElement.h (original)
+++ trunk/Core/Persistent/ArchiveElement.h Fri Nov 2 00:45:48 2007
@@ -25,13 +25,39 @@
void readwrite(const std::string& fieldname, const T*& data);
virtual void readwrite(const std::string& fieldname, bool& data) = 0;
- virtual void readwrite(const std::string& fieldname, double& data) = 0;
+ virtual void readwrite(const std::string& fieldname, signed char& data)
= 0;
+ virtual void readwrite(const std::string& fieldname, unsigned char&
data) = 0;
+ virtual void readwrite(const std::string& fieldname, short& data) = 0;
+ virtual void readwrite(const std::string& fieldname, unsigned short&
data) = 0;
+ virtual void readwrite(const std::string& fieldname, int& data) = 0;
+ virtual void readwrite(const std::string& fieldname, unsigned int& data)
= 0;
+ virtual void readwrite(const std::string& fieldname, long& data) = 0;
+ virtual void readwrite(const std::string& fieldname, unsigned long&
data) = 0;
+ virtual void readwrite(const std::string& fieldname, long long& data) =
0;
+ virtual void readwrite(const std::string& fieldname, unsigned long long&
data) = 0;
virtual void readwrite(const std::string& fieldname, float& data) = 0;
+ virtual void readwrite(const std::string& fieldname, double& data) = 0;
+ virtual void readwrite(const std::string& fieldname, long double& data)
= 0;
+
+ virtual void readwrite(const std::string& fieldname, bool* data, int
numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, signed char* data,
int numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, unsigned char*
data, int numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, short* data, int
numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, unsigned short*
data, int numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, int* data, int
numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, unsigned int* data,
int numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, long* data, int
numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, unsigned long*
data, int numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, long long* data,
int numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, unsigned long long*
data, int numElements) = 0;
virtual void readwrite(const std::string& fieldname, float* data, int
numElements) = 0;
- virtual void readwrite(const std::string& fieldname, int& data) = 0;
+ virtual void readwrite(const std::string& fieldname, double* data, int
numElements) = 0;
+ virtual void readwrite(const std::string& fieldname, long double* data,
int numElements) = 0;
+
virtual void readwrite(const std::string& fieldname, std::string& data)
= 0;
virtual bool nextContainerElement() = 0;
+ virtual bool hasField(const std::string& fieldname) const = 0;
protected:
virtual void readwrite(const std::string& fieldname,
PointerWrapperInterface& ptr, bool isPointer) = 0;
Copied: trunk/Core/Persistent/XMLArchive.cc (from r1800,
branches/persistent/Core/Persistent/XMLArchive.cc)
==============================================================================
--- branches/persistent/Core/Persistent/XMLArchive.cc (original)
+++ trunk/Core/Persistent/XMLArchive.cc Fri Nov 2 00:45:48 2007
@@ -31,16 +31,42 @@
virtual ~XMLArchiveElement();
virtual void readwrite(const std::string& fieldname, bool& data);
- virtual void readwrite(const std::string& fieldname, double& data);
+ virtual void readwrite(const std::string& fieldname, signed char& data);
+ virtual void readwrite(const std::string& fieldname, unsigned char&
data);
+ virtual void readwrite(const std::string& fieldname, short& data);
+ virtual void readwrite(const std::string& fieldname, unsigned short&
data);
+ virtual void readwrite(const std::string& fieldname, int& data);
+ virtual void readwrite(const std::string& fieldname, unsigned int& data);
+ virtual void readwrite(const std::string& fieldname, long& data);
+ virtual void readwrite(const std::string& fieldname, unsigned long&
data);
+ virtual void readwrite(const std::string& fieldname, long long& data);
+ virtual void readwrite(const std::string& fieldname, unsigned long long&
data);
virtual void readwrite(const std::string& fieldname, float& data);
+ virtual void readwrite(const std::string& fieldname, double& data);
+ virtual void readwrite(const std::string& fieldname, long double& data);
+
+ virtual void readwrite(const std::string& fieldname, bool* data, int
numElements);
+ virtual void readwrite(const std::string& fieldname, signed char* data,
int numElements);
+ virtual void readwrite(const std::string& fieldname, unsigned char*
data, int numElements);
+ virtual void readwrite(const std::string& fieldname, short* data, int
numElements);
+ virtual void readwrite(const std::string& fieldname, unsigned short*
data, int numElements);
+ virtual void readwrite(const std::string& fieldname, int* data, int
numElements);
+ virtual void readwrite(const std::string& fieldname, unsigned int* data,
int numElements);
+ virtual void readwrite(const std::string& fieldname, long* data, int
numElements);
+ virtual void readwrite(const std::string& fieldname, unsigned long*
data, int numElements);
+ virtual void readwrite(const std::string& fieldname, long long* data,
int numElements);
+ virtual void readwrite(const std::string& fieldname, unsigned long long*
data, int numElements);
virtual void readwrite(const std::string& fieldname, float* data, int
numElements);
- virtual void readwrite(const std::string& fieldname, int& data);
+ virtual void readwrite(const std::string& fieldname, double* data, int
numElements);
+ virtual void readwrite(const std::string& fieldname, long double* data,
int numElements);
+
virtual void readwrite(const std::string& fieldname, std::string& data);
virtual void readwrite(const std::string& fieldname,
PointerWrapperInterface& ptr, bool isPointer);
virtual bool nextContainerElement();
+ virtual bool hasField(const std::string& fieldname) const;
typedef std::map<std::string, PointerWrapperInterface*> pointermaptype;
protected:
XMLArchive* archive;
@@ -50,6 +76,11 @@
string tagname;
void writeProperty(const std::string& fieldname, const std::string&
value);
std::string readProperty(const std::string& fieldname);
+
+ template<class T>
+ void XMLArchiveElement::readwriteInteger(const std::string& fieldname,
T& data);
+ template<class T>
+ void XMLArchiveElement::readwriteIntegerArray(const std::string&
fieldname, T* data, int numElements);
};
typedef std::map<void*, RefInfo> refmaptype;
@@ -270,6 +301,41 @@
}
}
+template<class T>
+void XMLArchiveElement::readwriteInteger(const std::string& fieldname, T&
data)
+{
+ if(reading()){
+ istringstream in(readProperty(fieldname));
+ in >> data;
+ if(!in)
+ throw SerializationError(std::string("Error parsing ") +
typeid(T).name() + ": " + in.str());
+ } else {
+ ostringstream datastring;
+ datastring << data;
+ writeProperty(fieldname, datastring.str());
+ }
+}
+
+template<class T>
+void XMLArchiveElement::readwriteIntegerArray(const std::string& fieldname,
T* data, int numElements)
+{
+ if(reading()){
+ istringstream in(readProperty(fieldname));
+ for(int i=0;i<numElements;i++)
+ in >> data[i];
+ if(!in)
+ throw SerializationError("Error parsing float array: " + in.str());
+ } else {
+ ostringstream datastring;
+ for(int i=0;i<numElements;i++){
+ if(i != 0)
+ datastring << " ";
+ datastring << data[i];
+ }
+ writeProperty(fieldname, datastring.str());
+ }
+}
+
void XMLArchiveElement::readwrite(const std::string& fieldname, bool& data)
{
if(reading()){
@@ -285,13 +351,78 @@
}
}
+void XMLArchiveElement::readwrite(const std::string& fieldname, signed char&
data)
+{
+ readwriteInteger(fieldname, data);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, unsigned
char& data)
+{
+ readwriteInteger(fieldname, data);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, short& data)
+{
+ readwriteInteger(fieldname, data);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, unsigned
short& data)
+{
+ readwriteInteger(fieldname, data);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, int& data)
+{
+ readwriteInteger(fieldname, data);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, unsigned
int& data)
+{
+ readwriteInteger(fieldname, data);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, long& data)
+{
+ readwriteInteger(fieldname, data);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, unsigned
long& data)
+{
+ readwriteInteger(fieldname, data);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, long long&
data)
+{
+ readwriteInteger(fieldname, data);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, unsigned
long long& data)
+{
+ readwriteInteger(fieldname, data);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, float& data)
+{
+ if(reading()){
+ istringstream in(readProperty(fieldname));
+ in >> data;
+ if(!in)
+ throw SerializationError("Error parsing float: " + in.str());
+ } else {
+ ostringstream datastring;
+ datastring.precision(8);
+ datastring << data;
+ writeProperty(fieldname, datastring.str());
+ }
+}
+
void XMLArchiveElement::readwrite(const std::string& fieldname, double& data)
{
if(reading()){
istringstream in(readProperty(fieldname));
in >> data;
if(!in)
- throw SerializationError("Error parsing double: " + in.str());
+ throw SerializationError("Error parsing float: " + in.str());
} else {
ostringstream datastring;
datastring.precision(17);
@@ -300,7 +431,7 @@
}
}
-void XMLArchiveElement::readwrite(const std::string& fieldname, float& data)
+void XMLArchiveElement::readwrite(const std::string& fieldname, long double&
data)
{
if(reading()){
istringstream in(readProperty(fieldname));
@@ -309,12 +440,89 @@
throw SerializationError("Error parsing float: " + in.str());
} else {
ostringstream datastring;
- datastring.precision(8);
+ datastring.precision(34);
datastring << data;
writeProperty(fieldname, datastring.str());
}
}
+void XMLArchiveElement::readwrite(const std::string& fieldname, bool* data,
int numElements)
+{
+ if(reading()){
+ istringstream in(readProperty(fieldname));
+ for(int i=0;i<numElements;i++){
+ string str;
+ in >> str;
+ if(!in)
+ throw SerializationError("Error parsing float array: " + in.str());
+ if(str == "true" || str == "1" || str == "TRUE" || str == "yes")
+ data[i] = true;
+ else if(str == "false" || str == "0" || str == "FALSE" || str == "no")
+ data[i] = false;
+ else
+ throw SerializationError("Unknown boolean value: " + str);
+ }
+ } else {
+ ostringstream datastring;
+ for(int i=0;i<numElements;i++){
+ if(i != 0)
+ datastring << " ";
+ datastring << (data[i]?"true":"false");
+ }
+ writeProperty(fieldname, datastring.str());
+ }
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, signed char*
data, int numElements)
+{
+ readwriteIntegerArray(fieldname, data, numElements);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, unsigned
char* data, int numElements)
+{
+ readwriteIntegerArray(fieldname, data, numElements);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, short* data,
int numElements)
+{
+ readwriteIntegerArray(fieldname, data, numElements);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, unsigned
short* data, int numElements)
+{
+ readwriteIntegerArray(fieldname, data, numElements);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, int* data,
int numElements)
+{
+ readwriteIntegerArray(fieldname, data, numElements);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, unsigned
int* data, int numElements)
+{
+ readwriteIntegerArray(fieldname, data, numElements);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, long* data,
int numElements)
+{
+ readwriteIntegerArray(fieldname, data, numElements);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, unsigned
long* data, int numElements)
+{
+ readwriteIntegerArray(fieldname, data, numElements);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, long long*
data, int numElements)
+{
+ readwriteIntegerArray(fieldname, data, numElements);
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, unsigned
long long* data, int numElements)
+{
+ readwriteIntegerArray(fieldname, data, numElements);
+}
+
void XMLArchiveElement::readwrite(const std::string& fieldname, float* data,
int numelements)
{
if(reading()){
@@ -335,16 +543,42 @@
}
}
-void XMLArchiveElement::readwrite(const std::string& fieldname, int& data)
+void XMLArchiveElement::readwrite(const std::string& fieldname, double*
data, int numelements)
{
if(reading()){
istringstream in(readProperty(fieldname));
- in >> data;
+ for(int i=0;i<numelements;i++)
+ in >> data[i];
if(!in)
- throw SerializationError("Error parsing integer: " + in.str());
+ throw SerializationError("Error parsing double array: " + in.str());
} else {
ostringstream datastring;
- datastring << data;
+ datastring.precision(17);
+ for(int i=0;i<numelements;i++){
+ if(i != 0)
+ datastring << " ";
+ datastring << data[i];
+ }
+ writeProperty(fieldname, datastring.str());
+ }
+}
+
+void XMLArchiveElement::readwrite(const std::string& fieldname, long double*
data, int numelements)
+{
+ if(reading()){
+ istringstream in(readProperty(fieldname));
+ for(int i=0;i<numelements;i++)
+ in >> data[i];
+ if(!in)
+ throw SerializationError("Error parsing long double array: " +
in.str());
+ } else {
+ ostringstream datastring;
+ datastring.precision(34);
+ for(int i=0;i<numelements;i++){
+ if(i != 0)
+ datastring << " ";
+ datastring << data[i];
+ }
writeProperty(fieldname, datastring.str());
}
}
@@ -379,6 +613,23 @@
return true;
}
}
+
+bool XMLArchiveElement::hasField(const std::string& fieldname) const
+{
+ if(!reading())
+ return true;
+
+ if(xmlHasProp(node, to_xml_ch_ptr(fieldname.c_str())))
+ return true;
+ xmlNodePtr child = node->children;
+ while(child && (child->type != XML_ELEMENT_NODE ||
strcmp(to_char_ptr(child->name), fieldname.c_str()) != 0))
+ child = child->next;
+ if(child)
+ return true;
+
+ return false;
+}
+
void XMLArchiveElement::readwrite(const std::string& fieldname,
PointerWrapperInterface& ptr, bool isPointer)
{
Modified: trunk/Engine/Factory/Factory.cc
==============================================================================
--- trunk/Engine/Factory/Factory.cc (original)
+++ trunk/Engine/Factory/Factory.cc Fri Nov 2 00:45:48 2007
@@ -27,17 +27,20 @@
*/
#include <Engine/Factory/Factory.h>
-#include <Engine/Factory/RegisterKnownComponents.h>
-#include <Interface/MantaInterface.h>
-#include <Interface/Context.h>
-
-#include <Core/Util/Args.h>
+#include <Core/Containers/StringUtil.h>
#include <Core/Exceptions/UnknownComponent.h>
#include <Core/Exceptions/IllegalValue.h>
#include <Core/Exceptions/InputError.h>
-
-#include <Core/Containers/StringUtil.h>
+#include <Core/Exceptions/InternalError.h>
+#include <Core/Persistent/Archive.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Util/Args.h>
+#include <Engine/Factory/RegisterKnownComponents.h>
+#include <Interface/Context.h>
+#include <Interface/MantaInterface.h>
+#include <Interface/InterfaceRTTI.h>
+#include <Interface/Scene.h>
#include <errno.h>
#include <sys/types.h>
@@ -49,6 +52,9 @@
using namespace Manta;
using namespace SCIRun;
+Factory::~Factory()
+{
+}
ImageDisplay *Factory::createImageDisplay(const string& spec ) const
{
@@ -372,7 +378,9 @@
system_suffix = "so";
#endif
- if((suffix == "mo") || (suffix == "so") || (suffix == "dylib") ||
+ if(suffix == "rtml" || suffix == "xml"){
+ newScene = readArchiveScene(name, args);
+ } else if((suffix == "mo") || (suffix == "so") || (suffix == "dylib") ||
(suffix == "dll")) {
// Do this twice - once silently and once printing errors
newScene = readMOScene(name, args, true);
@@ -429,8 +437,40 @@
return list;
}
+Scene* Factory::readArchiveScene(const string& name, const vector<string>&
args) const
+{
+ using SCIRun::split_string;
+
+ // Determine which directories to search for the scene library.
+ string fullname = name;
+ vector<string> dirs = split_string(scenePath, ':');
+ for(vector<string>::iterator dir = dirs.begin(); dir != dirs.end(); dir++){
+
+ fullname = *dir + "/" + name;
+
+ // Check to see if the file exists.
+ struct stat statbuf;
+ if(stat(fullname.c_str(), &statbuf) == 0){
+ break;
+ }
+ }
+
+ Archive* archive = Archive::openForReading(fullname);
+ if(!archive)
+ throw InputError("Could not open Archive: " + fullname);
+
+ ArchiveElement* root = archive->getRoot();
+ if(!root)
+ throw InputError("Cannot find scene in file: " + fullname);
+ Scene* scene = 0;
+ root->readwrite("scene", scene);
+ if(!scene)
+ throw InternalError("Error reading file: " + fullname, __FILE__,
__LINE__);
+ return scene;
+}
+
Scene* Factory::readMOScene(const string& name, const vector<string>& args,
- bool printErrors) const
+ bool printErrors) const
{
using SCIRun::split_string;
@@ -550,5 +590,3 @@
list.push_back(iter->first);
return list;
}
-
-
Modified: trunk/Engine/Factory/Factory.h
==============================================================================
--- trunk/Engine/Factory/Factory.h (original)
+++ trunk/Engine/Factory/Factory.h Fri Nov 2 00:45:48 2007
@@ -65,7 +65,7 @@
manta_interface( interface_ ) {
if (AutoRegisterKnownComponents) registerKnownComponents( this );
}
- virtual ~Factory() {}
+ virtual ~Factory();
typedef vector<string> listType;
@@ -199,6 +199,7 @@
string scenePath;
+ Scene* Factory::readArchiveScene(const string& name, const
vector<string>& args) const;
Scene* readMOScene(const string& name, const vector<string>& args, bool
printErrors) const;
void readMOStack(const string& name, const vector<string>& args, bool
printErrors ) const;
Modified: trunk/Interface/CMakeLists.txt
==============================================================================
--- trunk/Interface/CMakeLists.txt (original)
+++ trunk/Interface/CMakeLists.txt Fri Nov 2 00:45:48 2007
@@ -13,6 +13,7 @@
Camera.cc
Camera.h
Clonable.h
+ Clonable.cc
Context.h
Context.cc
Fragment.h
@@ -24,6 +25,9 @@
ImageDisplay.h
ImageTraverser.cc
ImageTraverser.h
+ InterfaceRTTI.cc
+ InterfaceRTTI.h
+ Interpolable.cc
Interpolable.h
Light.cc
Light.h
@@ -52,6 +56,7 @@
Scene.cc
Scene.h
SetupCallback.cc
+ RenderParameters.cc
SetupCallback.h
ShadowAlgorithm.cc
ShadowAlgorithm.h
Modified: trunk/Interface/Camera.cc
==============================================================================
--- trunk/Interface/Camera.cc (original)
+++ trunk/Interface/Camera.cc Fri Nov 2 00:45:48 2007
@@ -1,5 +1,6 @@
#include <Interface/Camera.h>
+#include <Core/Persistent/ArchiveElement.h>
using namespace Manta;
@@ -17,3 +18,16 @@
{
}
+MANTA_REGISTER_CLASS(BasicCameraData);
+
+void BasicCameraData::readwrite(ArchiveElement* archive)
+{
+ archive->readwrite("eye", eye);
+ archive->readwrite("lookat", lookat);
+ archive->readwrite("up", up);
+ archive->readwrite("hfov", hfov);
+ if(archive->reading() && !archive->hasField("vfov"))
+ vfov = hfov;
+ else
+ archive->readwrite("vfov", vfov);
+}
Modified: trunk/Interface/Camera.h
==============================================================================
--- trunk/Interface/Camera.h (original)
+++ trunk/Interface/Camera.h Fri Nov 2 00:45:48 2007
@@ -41,7 +41,11 @@
// Someday, it may be nice to add extra space with an identifier for
camera that
// want to store other parameters here.
+
+ void readwrite(ArchiveElement* archive);
};
+
+ MANTA_DECLARE_RTTI_BASECLASS(BasicCameraData, ConcreteClass,
readwriteMethod);
class Camera : public Interpolable {
public:
Modified: trunk/Interface/Clonable.h
==============================================================================
--- trunk/Interface/Clonable.h (original)
+++ trunk/Interface/Clonable.h Fri Nov 2 00:45:48 2007
@@ -4,6 +4,7 @@
namespace Manta {
class Clonable {
public:
+ virtual ~Clonable();
enum CloneDepth {shallow //
};
virtual Clonable* clone(CloneDepth depth, Clonable* incoming=0)
@@ -13,7 +14,6 @@
else
return this;
}
- virtual ~Clonable() { }
};
}
#endif //Manta_Interface_Clonable_h
Modified: trunk/Interface/Interpolable.h
==============================================================================
--- trunk/Interface/Interpolable.h (original)
+++ trunk/Interface/Interpolable.h Fri Nov 2 00:45:48 2007
@@ -14,10 +14,9 @@
class Interpolable : public Clonable {
public:
+ virtual ~Interpolable();
enum InterpErr{success,
notInterpolable}; //cannot interpolate. No interpolation
performed.
-
- virtual ~Interpolable() { }
// Swig doesn't like nested classes, so I pulled it out. I'm
// defining a typedef here, so that I don't have to change all the
Modified: trunk/Interface/Light.h
==============================================================================
--- trunk/Interface/Light.h (original)
+++ trunk/Interface/Light.h Fri Nov 2 00:45:48 2007
@@ -8,6 +8,7 @@
namespace Manta {
+ class Archive;
class PreprocessContext;
class RenderContext;
@@ -31,6 +32,7 @@
const RenderContext &context,
RayPacket& sourceRays) const = 0;
+ void readwrite(Archive* archive);
private:
// Lights may not be copied.
Light( const Light & );
Modified: trunk/Interface/LightSet.cc
==============================================================================
--- trunk/Interface/LightSet.cc (original)
+++ trunk/Interface/LightSet.cc Fri Nov 2 00:45:48 2007
@@ -2,6 +2,9 @@
#include <Interface/LightSet.h>
#include <Interface/AmbientLight.h>
#include <Interface/Light.h>
+#include <Interface/InterfaceRTTI.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/stdRTTI.h>
#include <Core/Util/Assert.h>
#include <sgi_stl_warnings_off.h>
@@ -49,4 +52,10 @@
out << "lights["<<i<<"] = "<<lights[i]<<"\n";
}
return out.str();
+}
+
+void LightSet::readwrite(ArchiveElement* archive)
+{
+ archive->readwrite("lights", lights);
+ archive->readwrite("ambientLight", ambientLight);
}
Modified: trunk/Interface/LightSet.h
==============================================================================
--- trunk/Interface/LightSet.h (original)
+++ trunk/Interface/LightSet.h Fri Nov 2 00:45:48 2007
@@ -43,6 +43,7 @@
string toString() const;
+ void readwrite(ArchiveElement* archive);
private:
LightSet(const LightSet&);
LightSet& operator=(const LightSet&);
Modified: trunk/Interface/Object.h
==============================================================================
--- trunk/Interface/Object.h (original)
+++ trunk/Interface/Object.h Fri Nov 2 00:45:48 2007
@@ -19,7 +19,7 @@
typedef UpdateGraphNode<Object*> ObjectUpdateGraphNode;
- class Object : public Interpolable {
+ class Object : virtual public Interpolable {
public:
Object();
virtual ~Object();
Modified: trunk/Interface/RenderParameters.h
==============================================================================
--- trunk/Interface/RenderParameters.h (original)
+++ trunk/Interface/RenderParameters.h Fri Nov 2 00:45:48 2007
@@ -5,6 +5,7 @@
#include <MantaTypes.h>
namespace Manta {
+ class ArchiveElement;
class RenderParameters {
public:
RenderParameters() {
@@ -28,6 +29,8 @@
if (new_importanceCutoff >= 0)
importanceCutoff = new_importanceCutoff;
}
+
+ void readwrite(ArchiveElement* archive);
private:
};
}
Modified: trunk/Interface/Scene.cc
==============================================================================
--- trunk/Interface/Scene.cc (original)
+++ trunk/Interface/Scene.cc Fri Nov 2 00:45:48 2007
@@ -1,5 +1,11 @@
#include <Interface/Scene.h>
+#include <Core/Persistent/stdRTTI.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Interface/Background.h>
+#include <Interface/InterfaceRTTI.h>
+#include <Interface/LightSet.h>
+
using namespace Manta;
int Scene::addBookmark(const std::string& name, const Vector& eye, const
Vector& lookat,
@@ -45,3 +51,23 @@
return &bookmarks[currentBookmark_id]->cameradata;
}
+void Scene::readwrite(ArchiveElement* archive)
+{
+ archive->readwrite("object", object);
+ archive->readwrite("bg", bg);
+ archive->readwrite("lights", lights);
+ archive->readwrite("renderParameters", renderParameters);
+ archive->readwrite("bookmarks", bookmarks);
+ archive->readwrite("currentBookmark", currentBookmark_id);
+}
+
+namespace Manta {
+ MANTA_DECLARE_RTTI_BASECLASS(Scene::Bookmark, ConcreteClass,
readwriteMethod);
+ MANTA_REGISTER_CLASS(Scene::Bookmark);
+}
+
+void Scene::Bookmark::readwrite(ArchiveElement* archive)
+{
+ archive->readwrite("name", name);
+ archive->readwrite("cameradata", cameradata);
+}
Modified: trunk/Interface/Scene.h
==============================================================================
--- trunk/Interface/Scene.h (original)
+++ trunk/Interface/Scene.h Fri Nov 2 00:45:48 2007
@@ -8,6 +8,7 @@
#include <vector>
namespace Manta {
+ class Archive;
class Background;
class LightSet;
class Object;
@@ -74,15 +75,19 @@
const BasicCameraData* nextBookmark();
const BasicCameraData* currentBookmark();
+ void readwrite(ArchiveElement*);
+ struct Bookmark {
+ void readwrite(ArchiveElement* archive);
+ private:
+ friend class Scene;
+ std::string name;
+ BasicCameraData cameradata;
+ };
private:
Object* object;
Background* bg;
LightSet* lights;
RenderParameters renderParameters;
- struct Bookmark {
- std::string name;
- BasicCameraData cameradata;
- };
std::vector<Bookmark*> bookmarks;
unsigned int currentBookmark_id;
};
Modified: trunk/Interface/TexCoordMapper.h
==============================================================================
--- trunk/Interface/TexCoordMapper.h (original)
+++ trunk/Interface/TexCoordMapper.h Fri Nov 2 00:45:48 2007
@@ -5,10 +5,11 @@
#include <Interface/Interpolable.h>
namespace Manta {
+ class ArchiveElement;
class RayPacket;
class RenderContext;
- class TexCoordMapper {
+ class TexCoordMapper : virtual public Interpolable {
public:
TexCoordMapper();
virtual ~TexCoordMapper();
@@ -17,6 +18,8 @@
RayPacket& rays) const = 0;
virtual void computeTexCoords3(const RenderContext& context,
RayPacket& rays) const = 0;
+
+ void readwrite(ArchiveElement* archive);
private:
TexCoordMapper(const TexCoordMapper&);
TexCoordMapper& operator=(const TexCoordMapper&);
Modified: trunk/Interface/Texture.h
==============================================================================
--- trunk/Interface/Texture.h (original)
+++ trunk/Interface/Texture.h Fri Nov 2 00:45:48 2007
@@ -9,10 +9,10 @@
class RayPacket;
class RenderContext;
template<typename ValueType>
- class Texture : public Interpolable {
+ class Texture : virtual public Interpolable {
public:
- Texture() {};
- virtual ~Texture() {};
+ Texture() {}
+ virtual ~Texture() {}
virtual void mapValues(Packet<ValueType>& results,
const RenderContext&,
Modified: trunk/Model/AmbientLights/ArcAmbient.cc
==============================================================================
--- trunk/Model/AmbientLights/ArcAmbient.cc (original)
+++ trunk/Model/AmbientLights/ArcAmbient.cc Fri Nov 2 00:45:48 2007
@@ -1,6 +1,8 @@
#include <Model/AmbientLights/ArcAmbient.h>
#include <Interface/RayPacket.h>
+#include <Interface/InterfaceRTTI.h>
+#include <Core/Persistent/ArchiveElement.h>
#include <sgi_stl_warnings_off.h>
#include <sstream>
@@ -12,6 +14,10 @@
using namespace std;
using namespace SCIRun;
+ArcAmbient::ArcAmbient()
+{
+}
+
ArcAmbient::ArcAmbient(const Color& cup, const Color& cdown,
const Vector& up)
: cup(cup), cdown(cdown), up(up)
@@ -65,4 +71,17 @@
out << "("<<cd.r()<<", "<<cd.g()<<", "<<cd.b()<<")\n";
out << "up = "<<up<<"\n";
return out.str();
+}
+
+namespace Manta {
+MANTA_DECLARE_RTTI_DERIVEDCLASS(ArcAmbient, AmbientLight, ConcreteClass,
readwriteMethod);
+MANTA_REGISTER_CLASS(ArcAmbient);
+}
+
+void ArcAmbient::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<AmbientLight>::readwrite(archive, *this);
+ archive->readwrite("cup", cup);
+ archive->readwrite("cdown", cdown);
+ archive->readwrite("up", up);
}
Modified: trunk/Model/AmbientLights/ArcAmbient.h
==============================================================================
--- trunk/Model/AmbientLights/ArcAmbient.h (original)
+++ trunk/Model/AmbientLights/ArcAmbient.h Fri Nov 2 00:45:48 2007
@@ -14,6 +14,7 @@
class ArcAmbient : public AmbientLight {
public:
+ ArcAmbient();
ArcAmbient(const Color& cup, const Color& cdown,
const Vector& up);
virtual ~ArcAmbient();
@@ -22,6 +23,7 @@
virtual void computeAmbient(const RenderContext& context, RayPacket&
rays, ColorArray ambient) const;
virtual std::string toString() const;
+ virtual void readwrite(ArchiveElement*);
private:
Color cup;
Color cdown;
Modified: trunk/Model/Backgrounds/LinearBackground.cc
==============================================================================
--- trunk/Model/Backgrounds/LinearBackground.cc (original)
+++ trunk/Model/Backgrounds/LinearBackground.cc Fri Nov 2 00:45:48 2007
@@ -1,10 +1,16 @@
#include <Model/Backgrounds/LinearBackground.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Interface/InterfaceRTTI.h>
#include <Interface/RayPacket.h>
#include <MantaTypes.h>
using namespace Manta;
+LinearBackground::LinearBackground()
+{
+}
+
LinearBackground::LinearBackground(const Color& cup, const Color& cdown,
const Vector& in_up)
: cup(cup), cdown(cdown), up(in_up)
@@ -31,4 +37,17 @@
ColorComponent t = (Real)0.5 * (1 + Dot(rays.getDirection(i), up));
rays.setColor(i, cup*t+cdown*(1-t));
}
+}
+
+namespace Manta {
+MANTA_DECLARE_RTTI_DERIVEDCLASS(LinearBackground, Background, ConcreteClass,
readwriteMethod);
+MANTA_REGISTER_CLASS(LinearBackground);
+}
+
+void LinearBackground::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<Background>::readwrite(archive, *this);
+ archive->readwrite("cup", cup);
+ archive->readwrite("cdown", cdown);
+ archive->readwrite("up", up);
}
Modified: trunk/Model/Backgrounds/LinearBackground.h
==============================================================================
--- trunk/Model/Backgrounds/LinearBackground.h (original)
+++ trunk/Model/Backgrounds/LinearBackground.h Fri Nov 2 00:45:48 2007
@@ -5,16 +5,20 @@
#include <Interface/Background.h>
#include <Core/Color/Color.h>
#include <Core/Geometry/Vector.h>
+#include <Core/Persistent/MantaRTTI.h>
namespace Manta {
class LinearBackground : public Background {
public:
+ LinearBackground();
LinearBackground(const Color& cup, const Color& cdown, const Vector& up);
virtual ~LinearBackground();
virtual void preprocess(const PreprocessContext& context);
virtual void shade(const RenderContext& context, RayPacket& rays) const;
+
+ void readwrite(ArchiveElement* archive);
private:
Color cup;
Color cdown;
Modified: trunk/Model/Groups/Group.cc
==============================================================================
--- trunk/Model/Groups/Group.cc (original)
+++ trunk/Model/Groups/Group.cc Fri Nov 2 00:45:48 2007
@@ -3,6 +3,9 @@
#include <Core/Util/UpdateGraph.h>
#include <Interface/Context.h>
#include <Model/Groups/Group.h>
+#include <Interface/InterfaceRTTI.h>
+#include <Core/Persistent/stdRTTI.h>
+#include <Core/Persistent/ArchiveElement.h>
#include <SCIRun/Core/Util/Assert.h>
#include <algorithm>
#include <iostream>
@@ -38,7 +41,7 @@
{
Group* copy;
if (incoming)
- copy = static_cast<Group*>(incoming);
+ copy = dynamic_cast<Group*>(incoming);
else
copy = new Group();
@@ -46,7 +49,7 @@
//we can't just do copy->objs = objs;
for(vector<Object*>::iterator iter = objs.begin(); iter != objs.end();
++iter) {
Object* obj = *iter;
- copy->objs.push_back(static_cast<Object*>(obj->clone(depth)));
+ copy->objs.push_back(dynamic_cast<Object*>(obj->clone(depth)));
}
copy->bbox = bbox;
@@ -70,7 +73,7 @@
InterpErr worstError = success;
vector<keyframe_t> keyframes(group_keyframes);
-
+
Group* groups[group_keyframes.size()];
for(size_t frame=0; frame < keyframes.size(); ++frame) {
Group *group = dynamic_cast<Group*>(group_keyframes[frame].keyframe);
@@ -228,3 +231,15 @@
objs[i]->addToUpdateGraph(graph, node);
}
}
+
+namespace Manta {
+MANTA_DECLARE_RTTI_DERIVEDCLASS(Group, Object, ConcreteClass,
readwriteMethod);
+MANTA_REGISTER_CLASS(Group);
+}
+
+void Group::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<Object>::readwrite(archive, *this);
+ archive->readwrite("objs", objs);
+}
+
Modified: trunk/Model/Groups/Group.h
==============================================================================
--- trunk/Model/Groups/Group.h (original)
+++ trunk/Model/Groups/Group.h Fri Nov 2 00:45:48 2007
@@ -35,6 +35,7 @@
#include <Core/Thread/Barrier.h>
#include <SCIRun/Core/Thread/Mutex.h>
#include <Core/Geometry/BBox.h>
+#include <Core/Persistent/MantaRTTI.h>
#include <sgi_stl_warnings_off.h>
#include <vector>
#include <string>
@@ -87,6 +88,7 @@
virtual void addToUpdateGraph(ObjectUpdateGraph* graph,
ObjectUpdateGraphNode* parent);
+ void readwrite(ArchiveElement* archive);
protected:
vector<Object*> objs;
vector<Object*>::iterator parallelSplit; //point to the start of the
parallel objects
Modified: trunk/Model/Groups/Mesh.cc
==============================================================================
--- trunk/Model/Groups/Mesh.cc (original)
+++ trunk/Model/Groups/Mesh.cc Fri Nov 2 00:45:48 2007
@@ -16,7 +16,7 @@
{
Mesh *copy;
if (incoming)
- copy = static_cast<Mesh*>(incoming);
+ copy = dynamic_cast<Mesh*>(incoming);
else
copy = new Mesh();
Modified: trunk/Model/Lights/PointLight.cc
==============================================================================
--- trunk/Model/Lights/PointLight.cc (original)
+++ trunk/Model/Lights/PointLight.cc Fri Nov 2 00:45:48 2007
@@ -1,9 +1,16 @@
#include <Model/Lights/PointLight.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/MantaRTTI.h>
+#include <Interface/InterfaceRTTI.h>
#include <MantaSSE.h>
using namespace Manta;
+PointLight::PointLight()
+{
+}
+
PointLight::PointLight(const Vector& position, const Color& color)
: position(position), color(color)
{
@@ -61,4 +68,16 @@
destRays.overrideMinT(i, 1 - T_EPSILON);
}
#endif
+}
+
+namespace Manta {
+ MANTA_DECLARE_RTTI_DERIVEDCLASS(PointLight, Light, ConcreteClass,
readwriteMethod);
+ MANTA_REGISTER_CLASS(PointLight);
+}
+
+void PointLight::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<Light>::readwrite(archive, *this);
+ archive->readwrite("position", position);
+ archive->readwrite("color", color);
}
Modified: trunk/Model/Lights/PointLight.h
==============================================================================
--- trunk/Model/Lights/PointLight.h (original)
+++ trunk/Model/Lights/PointLight.h Fri Nov 2 00:45:48 2007
@@ -7,8 +7,11 @@
#include <Core/Color/Color.h>
namespace Manta {
+ class Archive;
+
class PointLight : public Light {
public:
+ PointLight();
PointLight(const Vector& position, const Color& color);
virtual ~PointLight();
@@ -23,7 +26,8 @@
Color getColor() const { return color; }
void setColor(Color new_c) { color = new_c; }
-
+
+ void readwrite(ArchiveElement* archive);
private:
Vector position;
Color color;
Modified: trunk/Model/Materials/Lambertian.cc
==============================================================================
--- trunk/Model/Materials/Lambertian.cc (original)
+++ trunk/Model/Materials/Lambertian.cc Fri Nov 2 00:45:48 2007
@@ -34,6 +34,9 @@
#include <Interface/AmbientLight.h>
#include <Interface/Context.h>
#include <Interface/ShadowAlgorithm.h>
+#include <Core/Persistent/MantaRTTI.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Interface/InterfaceRTTI.h>
#include <Model/Textures/Constant.h>
#include <iostream>
using namespace Manta;
@@ -231,4 +234,15 @@
}
#endif
+}
+
+namespace Manta {
+ MANTA_DECLARE_RTTI_DERIVEDCLASS(Lambertian, LitMaterial, ConcreteClass,
readwriteMethod);
+ MANTA_REGISTER_CLASS(Lambertian);
+}
+
+void Lambertian::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<LitMaterial>::readwrite(archive, *this);
+ archive->readwrite("color", colortex);
}
Modified: trunk/Model/Materials/Lambertian.h
==============================================================================
--- trunk/Model/Materials/Lambertian.h (original)
+++ trunk/Model/Materials/Lambertian.h Fri Nov 2 00:45:48 2007
@@ -35,6 +35,7 @@
#include <Interface/Texture.h>
namespace Manta{
+ class ArchiveElement;
class LightSet;
class Lambertian : public LitMaterial {
@@ -45,6 +46,7 @@
virtual ~Lambertian();
virtual void shade(const RenderContext& context, RayPacket& rays) const;
+ void readwrite(ArchiveElement* archive);
private:
const Texture<Color>* colortex;
Modified: trunk/Model/Materials/LitMaterial.cc
==============================================================================
--- trunk/Model/Materials/LitMaterial.cc (original)
+++ trunk/Model/Materials/LitMaterial.cc Fri Nov 2 00:45:48 2007
@@ -1,7 +1,9 @@
#include <Model/Materials/LitMaterial.h>
+#include <Interface/InterfaceRTTI.h>
#include <Interface/LightSet.h>
#include <Interface/Context.h>
+#include <Core/Persistent/ArchiveElement.h>
using namespace Manta;
@@ -32,4 +34,15 @@
activeLights = context.globalLights;
}
context.done();
+}
+
+namespace Manta {
+ MANTA_REGISTER_CLASS(LitMaterial);
+}
+
+void LitMaterial::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<OpaqueShadower>::readwrite(archive, *this);
+ archive->readwrite("localLights", localLights);
+ archive->readwrite("localLightsOverrideGlobal", localLightsOverrideGlobal);
}
Modified: trunk/Model/Materials/LitMaterial.h
==============================================================================
--- trunk/Model/Materials/LitMaterial.h (original)
+++ trunk/Model/Materials/LitMaterial.h Fri Nov 2 00:45:48 2007
@@ -3,6 +3,7 @@
#define Manta_Model_LitMaterial_h
#include <Model/Materials/OpaqueShadower.h>
+#include <Core/Persistent/MantaRTTI.h>
namespace Manta {
class LightSet;
@@ -17,11 +18,14 @@
// Pure virtual methods.
virtual void shade(const RenderContext& context, RayPacket& rays) const
= 0;
+ void readwrite(ArchiveElement* archive);
protected:
const LightSet* activeLights;
LightSet* localLights;
bool localLightsOverrideGlobal;
};
+
+ MANTA_DECLARE_RTTI_DERIVEDCLASS(LitMaterial, OpaqueShadower,
AbstractClass, readwriteMethod);
}
#endif
Modified: trunk/Model/Materials/MetalMaterial.cc
==============================================================================
--- trunk/Model/Materials/MetalMaterial.cc (original)
+++ trunk/Model/Materials/MetalMaterial.cc Fri Nov 2 00:45:48 2007
@@ -1,6 +1,8 @@
#include <Model/Materials/MetalMaterial.h>
#include <Core/Math/ipow.h>
+#include <Core/Persistent/MantaRTTI.h>
+#include <Core/Persistent/ArchiveElement.h>
#include <Interface/Context.h>
#include <Interface/Light.h>
#include <Interface/LightSet.h>
@@ -13,6 +15,11 @@
using namespace Manta;
+MetalMaterial::MetalMaterial()
+{
+ specular_reflectance = 0;
+}
+
MetalMaterial::MetalMaterial(const Color& specular, int phong_exponent)
: phong_exponent(phong_exponent)
{
@@ -74,4 +81,16 @@
for(int i=rays.begin();i<rays.end();i++)
rays.setColor(i, Color::black());
}
+}
+
+namespace Manta {
+ MANTA_DECLARE_RTTI_DERIVEDCLASS(MetalMaterial, LitMaterial, ConcreteClass,
readwriteMethod);
+ MANTA_REGISTER_CLASS(MetalMaterial);
+}
+
+void MetalMaterial::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<LitMaterial>::readwrite(archive, *this);
+ archive->readwrite("reflectance", specular_reflectance);
+ archive->readwrite("phong_exponent", phong_exponent);
}
Modified: trunk/Model/Materials/MetalMaterial.h
==============================================================================
--- trunk/Model/Materials/MetalMaterial.h (original)
+++ trunk/Model/Materials/MetalMaterial.h Fri Nov 2 00:45:48 2007
@@ -7,17 +7,19 @@
#include <Interface/Texture.h>
namespace Manta{
+ class Archive;
class LightSet;
class MetalMaterial : public LitMaterial {
public:
-
+ MetalMaterial();
MetalMaterial(const Color& specular_reflectance, int phong_exponent =
100);
MetalMaterial(const Texture<Color>* specular_reflectance,
int phong_exponent = 100);
virtual ~MetalMaterial();
virtual void shade(const RenderContext& context, RayPacket& rays) const;
+ void readwrite(ArchiveElement* archive);
private:
const Texture<Color>* specular_reflectance;
int phong_exponent;
Modified: trunk/Model/Materials/OpaqueShadower.cc
==============================================================================
--- trunk/Model/Materials/OpaqueShadower.cc (original)
+++ trunk/Model/Materials/OpaqueShadower.cc Fri Nov 2 00:45:48 2007
@@ -27,7 +27,7 @@
*/
#include <Model/Materials/OpaqueShadower.h>
-
+#include <Interface/InterfaceRTTI.h>
#include <MantaSSE.h>
#include <Interface/RayPacket.h>
#include <Interface/Context.h>
@@ -65,4 +65,8 @@
shadowRays.setColor(i, Color::black());
}
#endif
+}
+
+namespace Manta {
+ MANTA_REGISTER_CLASS(OpaqueShadower);
}
Modified: trunk/Model/Materials/OpaqueShadower.h
==============================================================================
--- trunk/Model/Materials/OpaqueShadower.h (original)
+++ trunk/Model/Materials/OpaqueShadower.h Fri Nov 2 00:45:48 2007
@@ -30,6 +30,7 @@
*/
#include <Interface/Material.h>
+#include <Core/Persistent/MantaRTTI.h>
namespace Manta {
@@ -47,6 +48,8 @@
// Pure virtual methods.
virtual void shade(const RenderContext& context, RayPacket& rays) const
= 0;
};
+
+ MANTA_DECLARE_RTTI_DERIVEDCLASS(OpaqueShadower, Material, AbstractClass,
readwriteNone);
} // end namespace Manta
#endif // #ifndef MODEL_MATERIALS_OPAQUESHADOWER_H__
Modified: trunk/Model/Primitives/Heightfield.cc
==============================================================================
--- trunk/Model/Primitives/Heightfield.cc (original)
+++ trunk/Model/Primitives/Heightfield.cc Fri Nov 2 00:45:48 2007
@@ -71,7 +71,7 @@
{
Heightfield *h;
if (incoming)
- h = static_cast<Heightfield*>(incoming);
+ h = dynamic_cast<Heightfield*>(incoming);
else
h = new Heightfield();
Modified: trunk/Model/Primitives/KenslerShirleyTriangle.cc
==============================================================================
--- trunk/Model/Primitives/KenslerShirleyTriangle.cc (original)
+++ trunk/Model/Primitives/KenslerShirleyTriangle.cc Fri Nov 2 00:45:48
2007
@@ -20,7 +20,7 @@
{
KenslerShirleyTriangle *copy;
if (incoming)
- copy = static_cast<KenslerShirleyTriangle*>(incoming);
+ copy = dynamic_cast<KenslerShirleyTriangle*>(incoming);
else
return new KenslerShirleyTriangle(mesh, myID);
Modified: trunk/Model/Primitives/Parallelogram.cc
==============================================================================
--- trunk/Model/Primitives/Parallelogram.cc (original)
+++ trunk/Model/Primitives/Parallelogram.cc Fri Nov 2 00:45:48 2007
@@ -1,5 +1,8 @@
#include <Model/Primitives/Parallelogram.h>
+#include <Interface/InterfaceRTTI.h>
#include <Interface/RayPacket.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/MantaRTTI.h>
#include <Core/Geometry/BBox.h>
#include <Core/Math/MiscMath.h>
#include <MantaSSE.h>
@@ -17,6 +20,10 @@
_mm_or_ps(_mm_and_ps(mask, newD), \
_mm_andnot_ps(mask, _mm_load_ps(oldD))))
+Parallelogram::Parallelogram()
+{
+}
+
Parallelogram::Parallelogram(Material* material, const Vector& anchor,
const Vector& in_v1, const Vector& in_v2)
: PrimitiveCommon(material, this), anchor(anchor), v1(in_v1), v2(in_v2),
@@ -613,3 +620,24 @@
}
#endif
}
+
+namespace Manta {
+ MANTA_DECLARE_RTTI_DERIVEDCLASS2(Parallelogram, PrimitiveCommon,
TexCoordMapper, ConcreteClass, readwriteMethod);
+ MANTA_REGISTER_CLASS(Parallelogram);
+}
+
+void Parallelogram::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<PrimitiveCommon>::readwrite(archive, *this);
+ MantaRTTI<TexCoordMapper>::readwrite(archive, *this);
+ archive->readwrite("anchor", anchor);
+ archive->readwrite("v1", v1);
+ archive->readwrite("v2", v2);
+ archive->readwrite("normal", normal);
+ archive->readwrite("offset", d);
+ if(archive->reading()){
+ double len = normal.normalize();
+ d *= len;
+ }
+}
+
Modified: trunk/Model/Primitives/Parallelogram.h
==============================================================================
--- trunk/Model/Primitives/Parallelogram.h (original)
+++ trunk/Model/Primitives/Parallelogram.h Fri Nov 2 00:45:48 2007
@@ -7,8 +7,11 @@
#include <Core/Geometry/Vector.h>
namespace Manta {
+ class ArchiveElement;
+
class Parallelogram : public PrimitiveCommon, public TexCoordMapper {
public:
+ Parallelogram();
Parallelogram(Material* material, const Vector& anchor,
const Vector& v1, const Vector& v2);
virtual ~Parallelogram();
@@ -33,6 +36,8 @@
Packet<Real>& pdfs,
const RenderContext& context,
RayPacket& rays) const;
+
+ void readwrite(ArchiveElement* archive);
private:
Vector anchor;
Vector v1, v2;
Modified: trunk/Model/Primitives/PrimitiveCommon.cc
==============================================================================
--- trunk/Model/Primitives/PrimitiveCommon.cc (original)
+++ trunk/Model/Primitives/PrimitiveCommon.cc Fri Nov 2 00:45:48 2007
@@ -1,6 +1,9 @@
#include <Model/Primitives/PrimitiveCommon.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/MantaRTTI.h>
#include <Interface/Material.h>
+#include <Interface/InterfaceRTTI.h>
#include <Model/TexCoordMappers/UniformMapper.h>
#include <assert.h>
@@ -24,7 +27,7 @@
{
PrimitiveCommon *copy;
assert (incoming); //PrimitiveCommon is an abstract base class, can't new
it.
- copy = static_cast<PrimitiveCommon*>(incoming);
+ copy = dynamic_cast<PrimitiveCommon*>(incoming);
copy->material = material;
copy->tex = tex;
@@ -67,4 +70,13 @@
tex = pc->tex;
return success;
+}
+
+MANTA_REGISTER_CLASS(PrimitiveCommon);
+
+void PrimitiveCommon::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<Primitive>::readwrite(archive, *this);
+ archive->readwrite("material", material);
+ archive->readwrite("tex", tex);
}
Modified: trunk/Model/Primitives/PrimitiveCommon.h
==============================================================================
--- trunk/Model/Primitives/PrimitiveCommon.h (original)
+++ trunk/Model/Primitives/PrimitiveCommon.h Fri Nov 2 00:45:48 2007
@@ -4,8 +4,10 @@
#include <Interface/Interpolable.h>
#include <Interface/Primitive.h>
+#include <Core/Persistent/MantaRTTI.h>
namespace Manta {
+ class ArchiveElement;
class Material;
class PrimitiveCommon : public Primitive {
public:
@@ -32,6 +34,8 @@
virtual InterpErr interpolate(const std::vector<keyframe_t> &keyframes);
#endif
+ void readwrite(ArchiveElement* archive);
+
private:
Material* material;
const TexCoordMapper* tex;
@@ -39,6 +43,9 @@
PrimitiveCommon( const PrimitiveCommon & );
PrimitiveCommon &operator = ( const PrimitiveCommon & );
};
+
+ MANTA_DECLARE_RTTI_DERIVEDCLASS(PrimitiveCommon, Primitive, AbstractClass,
readwriteMethod);
+
}
#endif
Modified: trunk/Model/Primitives/Sphere.cc
==============================================================================
--- trunk/Model/Primitives/Sphere.cc (original)
+++ trunk/Model/Primitives/Sphere.cc Fri Nov 2 00:45:48 2007
@@ -1,17 +1,24 @@
#include <Model/Primitives/Sphere.h>
-#include <Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/Trig.h>
#include <Core/Math/Expon.h>
-#include <MantaSSE.h>
#include <Core/Math/SSEDefs.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Core/Persistent/MantaRTTI.h>
+#include <Interface/RayPacket.h>
+#include <Interface/InterfaceRTTI.h>
+#include <MantaSSE.h>
using namespace Manta;
using namespace SCIRun;
using namespace std;
+Sphere::Sphere()
+{
+}
+
Sphere::Sphere(Material* material, const Vector& center, Real radius)
: PrimitiveCommon(material), center(center), radius(radius)
{
@@ -26,7 +33,7 @@
{
Sphere *copy;
if (incoming)
- copy = static_cast<Sphere*>(incoming);
+ copy = dynamic_cast<Sphere*>(incoming);
else
copy = new Sphere();
@@ -407,4 +414,18 @@
inv_radius = 1/radius;
return success;
+}
+
+namespace Manta {
+ MANTA_DECLARE_RTTI_DERIVEDCLASS(Sphere, PrimitiveCommon, ConcreteClass,
readwriteMethod);
+ MANTA_REGISTER_CLASS(Sphere);
+}
+
+void Sphere::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<PrimitiveCommon>::readwrite(archive, *this);
+ archive->readwrite("center", center);
+ archive->readwrite("radius", radius);
+ if(archive->reading())
+ inv_radius = 1./radius;
}
Modified: trunk/Model/Primitives/Sphere.h
==============================================================================
--- trunk/Model/Primitives/Sphere.h (original)
+++ trunk/Model/Primitives/Sphere.h Fri Nov 2 00:45:48 2007
@@ -7,8 +7,11 @@
#include <Core/Geometry/Vector.h>
namespace Manta {
- class Sphere : public PrimitiveCommon {
+ class ArchiveElement;
+
+ class Sphere : public PrimitiveCommon, public TexCoordMapper {
public:
+ Sphere();
Sphere(Material* material, const Vector& center, Real radius);
virtual ~Sphere();
@@ -36,8 +39,8 @@
return radius;
}
+ void readwrite(ArchiveElement* archive);
private:
- Sphere(){};
Vector center;
Real radius;
Real inv_radius;
Modified: trunk/Model/Primitives/WaldTriangle.cc
==============================================================================
--- trunk/Model/Primitives/WaldTriangle.cc (original)
+++ trunk/Model/Primitives/WaldTriangle.cc Fri Nov 2 00:45:48 2007
@@ -30,7 +30,7 @@
{
WaldTriangle *copy;
if (incoming)
- copy = static_cast<WaldTriangle*>(incoming);
+ copy = dynamic_cast<WaldTriangle*>(incoming);
else
copy = new WaldTriangle();
Modified: trunk/Model/TexCoordMappers/UniformMapper.cc
==============================================================================
--- trunk/Model/TexCoordMappers/UniformMapper.cc (original)
+++ trunk/Model/TexCoordMappers/UniformMapper.cc Fri Nov 2 00:45:48
2007
@@ -1,5 +1,6 @@
#include <Model/TexCoordMappers/UniformMapper.h>
+#include <Interface/InterfaceRTTI.h>
#include <Interface/RayPacket.h>
using namespace Manta;
@@ -80,3 +81,12 @@
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
+namespace Manta {
+ MANTA_DECLARE_RTTI_DERIVEDCLASS(UniformMapper, TexCoordMapper,
ConcreteClass, readwriteMethod);
+ MANTA_REGISTER_CLASS(UniformMapper);
+};
+
+void UniformMapper::readwrite(ArchiveElement* archive)
+{
+ MantaRTTI<TexCoordMapper>::readwrite(archive, *this);
+}
Modified: trunk/Model/TexCoordMappers/UniformMapper.h
==============================================================================
--- trunk/Model/TexCoordMappers/UniformMapper.h (original)
+++ trunk/Model/TexCoordMappers/UniformMapper.h Fri Nov 2 00:45:48 2007
@@ -5,6 +5,8 @@
#include <Interface/TexCoordMapper.h>
namespace Manta {
+ class ArchiveElement;
+
class UniformMapper : public TexCoordMapper {
public:
UniformMapper();
@@ -14,6 +16,8 @@
RayPacket& rays) const;
virtual void computeTexCoords3(const RenderContext& context,
RayPacket& rays) const;
+
+ void readwrite(ArchiveElement* archive);
private:
UniformMapper(const UniformMapper&);
UniformMapper& operator=(const UniformMapper&);
Modified: trunk/Model/Textures/CheckerTexture.h
==============================================================================
--- trunk/Model/Textures/CheckerTexture.h (original)
+++ trunk/Model/Textures/CheckerTexture.h Fri Nov 2 00:45:48 2007
@@ -5,6 +5,8 @@
#include <Interface/Texture.h>
#include <Core/Color/Color.h>
#include <Core/Geometry/Vector.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Interface/InterfaceRTTI.h>
#include <Interface/RayPacket.h>
#include <MantaSSE.h>
@@ -14,12 +16,14 @@
template<typename ValueType>
class CheckerTexture : public Texture<ValueType> {
public:
+ CheckerTexture();
CheckerTexture(const ValueType& value1,
const ValueType& value2,
const Vector& v1, const Vector& v2);
virtual ~CheckerTexture();
virtual void mapValues(Packet<ValueType>&, const RenderContext& context,
RayPacket& rays) const;
+ void readwrite(ArchiveElement* archive);
private:
CheckerTexture(const CheckerTexture&);
CheckerTexture& operator=(const CheckerTexture&);
@@ -31,6 +35,11 @@
};
template<class ValueType>
+ CheckerTexture<ValueType>::CheckerTexture()
+ {
+ }
+
+ template<class ValueType>
CheckerTexture<ValueType>::CheckerTexture(const ValueType& value1,
const ValueType& value2,
const Vector& v1,
@@ -46,11 +55,6 @@
}
template<class ValueType>
- CheckerTexture<ValueType>::~CheckerTexture()
- {
- }
-
- template<class ValueType>
void CheckerTexture<ValueType>::mapValues(Packet<ValueType>& results,
const RenderContext& context,
RayPacket& rays) const
@@ -84,6 +88,52 @@
RayPacket& rays) const;
#endif
+ template<class ValueType>
+ class MantaRTTI<CheckerTexture<ValueType> > : public
MantaRTTI_DerivedClass<CheckerTexture<ValueType>, Texture<ValueType> >,
public MantaRTTI_ConcreteClass<CheckerTexture<ValueType> >, public
MantaRTTI_readwriteMethod<CheckerTexture<ValueType> > {
+ public:
+ class Initializer {
+ public:
+ Initializer() {
+ MantaRTTI<CheckerTexture<ValueType>
>
::registerClass("CheckerTexture<"+MantaRTTI<ValueType>::getPublicClassname()+">");
+ }
+ void forceinit() {
+ }
+ };
+ static Initializer init;
+ };
+
+ template<class ValueType>
+ typename MantaRTTI<CheckerTexture<ValueType> >::Initializer
MantaRTTI<CheckerTexture<ValueType> >::init;
+
+ template<class ValueType>
+ void CheckerTexture<ValueType>::readwrite(ArchiveElement* archive)
+ {
+ archive->readwrite("value1", values[0]);
+ archive->readwrite("value2", values[1]);
+ archive->readwrite("v1", v1);
+ archive->readwrite("v2", v2);
+ if(archive->reading()){
+ if(v1.z() == 0 && v2.z() == 0)
+ need_w = false;
+ else
+ need_w = true;
+ }
+ }
+
+ template<class ValueType>
+ CheckerTexture<ValueType>::~CheckerTexture()
+ {
+ MantaRTTI<CheckerTexture<ValueType> >::init.forceinit();
+ }
+
+ template<>
+ void CheckerTexture<Color>::mapValues(Packet<Color>& results,
+ const RenderContext& context,
+ RayPacket& rays) const;
+ template<>
+ void CheckerTexture<float>::mapValues(Packet<float>& results,
+ const RenderContext& context,
+ RayPacket& rays) const;
}
Modified: trunk/Model/Textures/Constant.h
==============================================================================
--- trunk/Model/Textures/Constant.h (original)
+++ trunk/Model/Textures/Constant.h Fri Nov 2 00:45:48 2007
@@ -4,6 +4,9 @@
#include <Interface/Texture.h>
#include <Interface/RayPacket.h>
+
+#include <Interface/InterfaceRTTI.h>
+#include <Core/Persistent/ArchiveElement.h>
#include <MantaSSE.h>
namespace Manta {
@@ -12,6 +15,7 @@
template<typename ValueType>
class Constant : public Texture<ValueType> {
public:
+ Constant();
Constant(const ValueType& value);
virtual ~Constant();
@@ -21,6 +25,7 @@
ValueType getValue() const { return value; }
void setValue( const ValueType value_ ) { value = value_; }
+ void readwrite(ArchiveElement* archive);
private:
Constant(const Constant&);
Constant& operator=(const Constant&);
@@ -29,14 +34,37 @@
};
template<class ValueType>
+ class MantaRTTI<Constant<ValueType> > : public
MantaRTTI_DerivedClass<Constant<ValueType>, Texture<ValueType> >, public
MantaRTTI_ConcreteClass<Constant<ValueType> >, public
MantaRTTI_readwriteMethod<Constant<ValueType> > {
+ public:
+ class Initializer {
+ public:
+ Initializer() {
+ MantaRTTI<Constant<ValueType>
>
::registerClass("Constant<"+MantaRTTI<ValueType>::getPublicClassname()+">");
+ }
+ void forceinit() {
+ }
+ };
+ static Initializer init;
+ };
+
+ template<class ValueType>
+ typename MantaRTTI<Constant<ValueType> >::Initializer
MantaRTTI<Constant<ValueType> >::init;
+
+ template<class ValueType>
Constant<ValueType>::Constant(const ValueType& value)
: value(value)
{
}
template<class ValueType>
+ Constant<ValueType>::Constant()
+ {
+ }
+
+ template<class ValueType>
Constant<ValueType>::~Constant()
{
+ MantaRTTI<Constant<ValueType> >::init.forceinit();
}
template<class ValueType>
@@ -46,6 +74,12 @@
{
for(int i=rays.begin();i<rays.end();i++)
results.set(i, value);
+ }
+
+ template<class ValueType>
+ void Constant<ValueType>::readwrite(ArchiveElement* archive)
+ {
+ archive->readwrite("value", value);
}
template<>
Modified: trunk/StandAlone/CMakeLists.txt
==============================================================================
--- trunk/StandAlone/CMakeLists.txt (original)
+++ trunk/StandAlone/CMakeLists.txt Fri Nov 2 00:45:48 2007
@@ -21,14 +21,13 @@
${CMAKE_THREAD_LIBS_INIT} -lm)
ENDIF(BUILD_OCTVOL_BUILD)
+SET (BUILD_SAVESCENE FALSE CACHE BOOL "Build the scene read/write program
(savescene)")
+IF (BUILD_SAVESCENE)
+ ADD_EXECUTABLE(savescene savescene.cc)
+ TARGET_LINK_LIBRARIES(savescene ${MANTA_TARGET_LINK_LIBRARIES})
+ENDIF (BUILD_SAVESCENE)
-#ADD_EXECUTABLE(frust-test frust-test.cc)
-#TARGET_LINK_LIBRARIES(frust-test ${MANTA_TARGET_LINK_LIBRARIES}
-# ${CMAKE_THREAD_LIBS_INIT}
-# )
-
-
-SET (BUILD_DISPLAY_TEST FALSE CACHE BOOL "Build the Display Test program")
+SET (BUILD_DISPLAY_TEST FALSE CACHE BOOL "Build the Display Test program
(displaytest)")
IF (BUILD_DISPLAY_TEST)
# Check for GLUT
INCLUDE (${CMAKE_ROOT}/Modules/FindGLUT.cmake)
Copied: trunk/StandAlone/savescene.cc (from r1800,
branches/persistent/StandAlone/savescene.cc)
==============================================================================
--- branches/persistent/StandAlone/savescene.cc (original)
+++ trunk/StandAlone/savescene.cc Fri Nov 2 00:45:48 2007
@@ -76,7 +76,8 @@
factory->setScenePath("");
if(args.size() != 2)
usage();
- int i=-1;
+ size_t i=0;
+ i--;
string scenename;
if(!getStringArg(i, args, scenename))
usage();
Modified: trunk/TODO
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Fri Nov 2 00:45:48 2007
@@ -1,36 +1,11 @@
-#ifdef MANTA_SSE
- int b = (rays.rayBegin + 3) & (~3);
- int e = rays.rayEnd & (~3);
- if(b == e){
- for(int i = rays.begin(); i < rays.end(); i++){
- }
- } else {
- int i = rays.rayBegin;
- for(;i<b;i++){
- }
- RayPacketData* data = rays.data;
- for(;i<e;i+=4){
- }
- for(;i<rays.rayEnd;i++){
- }
- }
-#else
- for(int i = rays.begin(); i < rays.end(); i++){
- }
-#endif
-
-
-namespace std {
- std::ostream& operator<< (std::ostream& os, __m128 d)
- {
- float* data = (float*)&d;
- cerr << '[' << data[0] << ", " << data[1] << ", " << data[2] << ", " <<
data[3] << ']';;
- }
-}
-
-
-Point/Vector:
- - double-check const-correctness
+Persistent:
+ - Detect self references?
+ - Error checking in xmlarchive (err codes from libxml2)
+properly handlenamespaces in:
+ - read
+ - write
+ - register
+style-sheet like facility for defaults and other things
Cmake:
- Class rtrt fix
@@ -38,17 +13,12 @@
- New point/vector? - templated on type and dimensionality
- Nix vector2d...
- circular dependency from rtrt master to UI - move UI in Engine???
- - mechanism to configure sci_defs files
- - build shared libraries
- - build scenes
- configure threads/time classes properly
Color:
- Special class for just RGB (more efficient???)
- - Class for black/white - more efficient?
Code review:
- - Dielectric
- MetalMaterial
- Box/Cube
- Sampling
- [Manta] r1801 - in trunk: . CMake Core Core/Color Core/Exceptions Core/Geometry Core/Persistent Engine/Factory Interface Model/AmbientLights Model/Backgrounds Model/Groups Model/Lights Model/Materials Model/Primitives Model/TexCoordMappers Model/Textures StandAlone, sparker, 11/02/2007
Archive powered by MHonArc 2.6.16.