Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1390 - in branches/persistent: . Core/Reflection Interface Model/Materials Model/Primitives scenes
- Date: Wed, 16 May 2007 14:48:51 -0600 (MDT)
Author: sparker
Date: Wed May 16 14:48:49 2007
New Revision: 1390
Modified:
branches/persistent/CMakeLists.txt
branches/persistent/Core/Reflection/Archive.h
branches/persistent/Core/Reflection/XMLArchive.cc
branches/persistent/Core/Reflection/XMLArchive.h
branches/persistent/Core/Reflection/stdClassInfo.h
branches/persistent/Interface/InterfaceClassInfo.h
branches/persistent/Model/Materials/Lambertian.cc
branches/persistent/Model/Materials/Lambertian.h
branches/persistent/Model/Materials/LitMaterial.cc
branches/persistent/Model/Materials/LitMaterial.h
branches/persistent/Model/Materials/OpaqueShadower.cc
branches/persistent/Model/Materials/OpaqueShadower.h
branches/persistent/Model/Primitives/Sphere.cc
branches/persistent/Model/Primitives/Sphere.h
branches/persistent/scenes/0.cc
Log:
Implement serializers for various functions
Modified: branches/persistent/CMakeLists.txt
==============================================================================
--- branches/persistent/CMakeLists.txt (original)
+++ branches/persistent/CMakeLists.txt Wed May 16 14:48:49 2007
@@ -132,3 +132,4 @@
SET(PASSED_FIRST_CONFIGURE ON CACHE INTERNAL "Already Configured once?")
###############################################################################
###############################################################################
+
Modified: branches/persistent/Core/Reflection/Archive.h
==============================================================================
--- branches/persistent/Core/Reflection/Archive.h (original)
+++ branches/persistent/Core/Reflection/Archive.h Wed May 16 14:48:49
2007
@@ -20,10 +20,11 @@
template<class T>
void readwrite(const char* fieldname, const T*& data);
- virtual void readwrite(const char* fieldname, int& data) = 0;
+ virtual void readwrite(const char* fieldname, bool& data) = 0;
+ virtual void readwrite(const char* fieldname, double& data) = 0;
virtual void readwrite(const char* fieldname, float& data) = 0;
virtual void readwrite(const char* fieldname, float* data, int
numElements) = 0;
- virtual void readwrite(const char* fieldname, double& data) = 0;
+ virtual void readwrite(const char* fieldname, int& data) = 0;
bool reading() const {
return isreading;
Modified: branches/persistent/Core/Reflection/XMLArchive.cc
==============================================================================
--- branches/persistent/Core/Reflection/XMLArchive.cc (original)
+++ branches/persistent/Core/Reflection/XMLArchive.cc Wed May 16 14:48:49
2007
@@ -94,12 +94,22 @@
xmlSetProp(node, to_xml_ch_ptr(fieldname), to_xml_ch_ptr(value.c_str()));
}
-void XMLArchive::readwrite(const char* fieldname, int& data)
+void XMLArchive::readwrite(const char* fieldname, bool& data)
+{
+ if(reading()){
+ NOT_FINISHED("XMLArchive::readwrite");
+ } else {
+ writeProperty(fieldname, data?"true":"false");
+ }
+}
+
+void XMLArchive::readwrite(const char* fieldname, double& data)
{
if(reading()){
NOT_FINISHED("XMLArchive::readwrite");
} else {
ostringstream datastring;
+ datastring.precision(17);
datastring << data;
writeProperty(fieldname, datastring.str());
}
@@ -119,14 +129,31 @@
void XMLArchive::readwrite(const char* fieldname, float* data, int
numelements)
{
- NOT_FINISHED("XMLArchive::readwrite");
+ if(reading()){
+ NOT_FINISHED("XMLArchive::readwrite");
+ } else {
+ ostringstream datastring;
+ datastring.precision(8);
+ for(int i=0;i<numelements;i++){
+ if(i != 0)
+ datastring << " ";
+ datastring << data[i];
+ }
+ writeProperty(fieldname, datastring.str());
+ }
}
-void XMLArchive::readwrite(const char* fieldname, double& data)
+void XMLArchive::readwrite(const char* fieldname, int& data)
{
- NOT_FINISHED("XMLArchive::readwrite");
+ if(reading()){
+ NOT_FINISHED("XMLArchive::readwrite");
+ } else {
+ ostringstream datastring;
+ datastring << data;
+ writeProperty(fieldname, datastring.str());
+ }
}
-
+
std::string XMLArchive::getClassname() const
{
return to_char_ptr(node->name);
Modified: branches/persistent/Core/Reflection/XMLArchive.h
==============================================================================
--- branches/persistent/Core/Reflection/XMLArchive.h (original)
+++ branches/persistent/Core/Reflection/XMLArchive.h Wed May 16 14:48:49
2007
@@ -13,10 +13,11 @@
XMLArchive(XMLArchive* archive, xmlNodePtr node);
virtual ~XMLArchive();
- virtual void readwrite(const char* fieldname, int& data);
+ virtual void readwrite(const char* fieldname, bool& data);
+ virtual void readwrite(const char* fieldname, double& data);
virtual void readwrite(const char* fieldname, float& data);
virtual void readwrite(const char* fieldname, float* data, int
numElements);
- virtual void readwrite(const char* fieldname, double& data);
+ virtual void readwrite(const char* fieldname, int& data);
virtual std::string getClassname() const;
Modified: branches/persistent/Core/Reflection/stdClassInfo.h
==============================================================================
--- branches/persistent/Core/Reflection/stdClassInfo.h (original)
+++ branches/persistent/Core/Reflection/stdClassInfo.h Wed May 16 14:48:49
2007
@@ -3,6 +3,7 @@
#define Manta_stdRefl_h
#include <Core/Reflection/ClassInfo.h>
+#include <Core/Reflection/Archive.h>
#include <Core/Util/NotFinished.h>
#include <vector>
@@ -58,7 +59,12 @@
}
static void readwrite(Archive* archive, std::vector<T*>& data) {
init.forceinit();
- NOT_FINISHED("vector readwrite");
+ if(archive->reading()){
+ NOT_FINISHED("vector readwrite");
+ } else {
+ for(typename std::vector<T*>::iterator iter = data.begin(); iter !=
data.end(); iter++)
+ archive->readwrite(0, *iter);
+ }
}
private:
class Initializer {
Modified: branches/persistent/Interface/InterfaceClassInfo.h
==============================================================================
--- branches/persistent/Interface/InterfaceClassInfo.h (original)
+++ branches/persistent/Interface/InterfaceClassInfo.h Wed May 16 14:48:49
2007
@@ -17,6 +17,7 @@
class RenderParameters;
class TexCoordMapper;
class Scene;
+ template<class ValueType> class Texture;
DECLARE_CLASSINFO_BASECLASS(AmbientLight, AbstractClass, readwriteNone);
DECLARE_CLASSINFO_BASECLASS(Light, AbstractClass,readwriteNone);
@@ -30,6 +31,11 @@
DECLARE_CLASSINFO_BASECLASS(RenderParameters, ConcreteClass,
readwriteMethod);
DECLARE_CLASSINFO_DERIVEDCLASS(Interpolable, Clonable, AbstractClass,
readwriteNone);
DECLARE_CLASSINFO_BASECLASS(Clonable, AbstractClass, readwriteNone);
+
+ template<class ValueType>
+ class ClassInfo<Texture<ValueType> > : public
ClassInfo_DerivedClass<Texture<ValueType>, Interpolable>, public
ClassInfo_AbstractClass<Texture<ValueType> >, public
ClassInfo_readwriteNone<Texture<ValueType> > {
+ static bool force_initialize;
+ };
}
#endif
Modified: branches/persistent/Model/Materials/Lambertian.cc
==============================================================================
--- branches/persistent/Model/Materials/Lambertian.cc (original)
+++ branches/persistent/Model/Materials/Lambertian.cc Wed May 16 14:48:49
2007
@@ -34,6 +34,9 @@
#include <Interface/AmbientLight.h>
#include <Interface/Context.h>
#include <Interface/ShadowAlgorithm.h>
+#include <Core/Reflection/ClassInfo.h>
+#include <Core/Reflection/Archive.h>
+#include <Interface/InterfaceClassInfo.h>
#include <Model/Textures/Constant.h>
#include <iostream>
using namespace Manta;
@@ -231,4 +234,15 @@
}
#endif
+}
+
+namespace Manta {
+ DECLARE_CLASSINFO_DERIVEDCLASS(Lambertian, LitMaterial, ConcreteClass,
readwriteMethod);
+ REGISTER_CLASS(Lambertian);
+}
+
+void Lambertian::readwrite(Archive* archive)
+{
+ ClassInfo<LitMaterial>::readwrite(archive, *this);
+ archive->readwrite("color", colortex);
}
Modified: branches/persistent/Model/Materials/Lambertian.h
==============================================================================
--- branches/persistent/Model/Materials/Lambertian.h (original)
+++ branches/persistent/Model/Materials/Lambertian.h Wed May 16 14:48:49
2007
@@ -35,6 +35,7 @@
#include <Interface/Texture.h>
namespace Manta{
+ class Archive;
class LightSet;
class Lambertian : public LitMaterial {
@@ -45,6 +46,7 @@
virtual ~Lambertian();
virtual void shade(const RenderContext& context, RayPacket& rays) const;
+ void readwrite(Archive* archive);
private:
const Texture<Color>* colortex;
};
Modified: branches/persistent/Model/Materials/LitMaterial.cc
==============================================================================
--- branches/persistent/Model/Materials/LitMaterial.cc (original)
+++ branches/persistent/Model/Materials/LitMaterial.cc Wed May 16 14:48:49
2007
@@ -1,7 +1,9 @@
#include <Model/Materials/LitMaterial.h>
+#include <Interface/InterfaceClassInfo.h>
#include <Interface/LightSet.h>
#include <Interface/Context.h>
+#include <Core/Reflection/Archive.h>
using namespace Manta;
@@ -26,4 +28,15 @@
} else {
activeLights = context.globalLights;
}
+}
+
+namespace Manta {
+ REGISTER_CLASS(LitMaterial);
+}
+
+void LitMaterial::readwrite(Archive* archive)
+{
+ ClassInfo<OpaqueShadower>::readwrite(archive, *this);
+ archive->readwrite("localLights", localLights);
+ archive->readwrite("localLightsOverrideGlobal", localLightsOverrideGlobal);
}
Modified: branches/persistent/Model/Materials/LitMaterial.h
==============================================================================
--- branches/persistent/Model/Materials/LitMaterial.h (original)
+++ branches/persistent/Model/Materials/LitMaterial.h Wed May 16 14:48:49
2007
@@ -3,6 +3,7 @@
#define Manta_Model_LitMaterial_h
#include <Model/Materials/OpaqueShadower.h>
+#include <Core/Reflection/ClassInfo.h>
namespace Manta {
class LightSet;
@@ -14,11 +15,14 @@
virtual void preprocess(const PreprocessContext&);
+ void readwrite(Archive* archive);
protected:
const LightSet* activeLights;
LightSet* localLights;
bool localLightsOverrideGlobal;
};
+
+ DECLARE_CLASSINFO_DERIVEDCLASS(LitMaterial, OpaqueShadower, AbstractClass,
readwriteMethod);
}
#endif
Modified: branches/persistent/Model/Materials/OpaqueShadower.cc
==============================================================================
--- branches/persistent/Model/Materials/OpaqueShadower.cc (original)
+++ branches/persistent/Model/Materials/OpaqueShadower.cc Wed May 16
14:48:49 2007
@@ -27,7 +27,7 @@
*/
#include <Model/Materials/OpaqueShadower.h>
-
+#include <Interface/InterfaceClassInfo.h>
#include <MantaSSE.h>
#include <Interface/RayPacket.h>
#include <Interface/Context.h>
@@ -65,4 +65,8 @@
shadowRays.setColor(i, Color::black());
}
#endif
+}
+
+namespace Manta {
+ REGISTER_CLASS(OpaqueShadower);
}
Modified: branches/persistent/Model/Materials/OpaqueShadower.h
==============================================================================
--- branches/persistent/Model/Materials/OpaqueShadower.h (original)
+++ branches/persistent/Model/Materials/OpaqueShadower.h Wed May 16
14:48:49 2007
@@ -30,6 +30,7 @@
*/
#include <Interface/Material.h>
+#include <Core/Reflection/ClassInfo.h>
namespace Manta {
@@ -46,6 +47,8 @@
RayPacket& shadowRays) const;
};
+
+ DECLARE_CLASSINFO_DERIVEDCLASS(OpaqueShadower, Material, AbstractClass,
readwriteNone);
} // end namespace Manta
#endif // #ifndef MODEL_MATERIALS_OPAQUESHADOWER_H__
Modified: branches/persistent/Model/Primitives/Sphere.cc
==============================================================================
--- branches/persistent/Model/Primitives/Sphere.cc (original)
+++ branches/persistent/Model/Primitives/Sphere.cc Wed May 16 14:48:49
2007
@@ -15,6 +15,10 @@
using namespace SCIRun;
using namespace std;
+Sphere::Sphere()
+{
+}
+
Sphere::Sphere(Material* material, const Vector& center, Real radius)
: PrimitiveCommon(material), center(center), radius(radius)
{
@@ -413,16 +417,8 @@
}
namespace Manta {
-template<>
-class ClassInfo<Sphere> : public ClassInfo_DerivedClass<Sphere,
PrimitiveCommon>
-{
- char force_initialize;
-};
-
-#if 0
-template<>
-bool ClassInfo<Sphere>::force_initialize =
ClassInfo<Sphere>::register_class("Manta::Sphere");
-#endif
+ DECLARE_CLASSINFO_DERIVEDCLASS(Sphere, PrimitiveCommon, ConcreteClass,
readwriteMethod);
+ REGISTER_CLASS(Sphere);
}
void Sphere::readwrite(Archive* archive)
Modified: branches/persistent/Model/Primitives/Sphere.h
==============================================================================
--- branches/persistent/Model/Primitives/Sphere.h (original)
+++ branches/persistent/Model/Primitives/Sphere.h Wed May 16 14:48:49
2007
@@ -11,6 +11,7 @@
class Sphere : public PrimitiveCommon {
public:
+ Sphere();
Sphere(Material* material, const Vector& center, Real radius);
virtual ~Sphere();
@@ -38,13 +39,11 @@
return radius;
}
+ void readwrite(Archive* archive);
private:
- Sphere(){};
Vector center;
Real radius;
Real inv_radius;
-
- void readwrite(Archive* archive);
};
}
Modified: branches/persistent/scenes/0.cc
==============================================================================
--- branches/persistent/scenes/0.cc (original)
+++ branches/persistent/scenes/0.cc Wed May 16 14:48:49 2007
@@ -14,7 +14,7 @@
#include <Model/Materials/Lambertian.h>
#include <Model/Materials/MetalMaterial.h>
#include <Model/Primitives/Parallelogram.h>
-#if 1
+#if 0
#include <Model/Primitives/sphere.h>
#define Sphere sphere
#else
- [MANTA] r1390 - in branches/persistent: . Core/Reflection Interface Model/Materials Model/Primitives scenes, sparker, 05/16/2007
Archive powered by MHonArc 2.6.16.