HyperspaceExplorer 0.7.1
|
00001 /* 00002 * File: ObjectImplementations.h 00003 * Author: lene 00004 * 00005 * Created on December 18, 2011, 5:43 PM 00006 */ 00007 00008 #ifndef OBJECTIMPLEMENTATIONS_H 00009 #define OBJECTIMPLEMENTATIONS_H 00010 00011 #include "Object.h" 00012 #include "FacePolygon.h" 00013 00015 00016 class Hypercube: public Object { 00017 public: 00019 Hypercube (double a = 1., 00020 const VecMath::Vector<4> &_center = VecMath::Vector<4>(0., 0., 0., 0.)); 00021 virtual ~Hypercube() { } 00022 00023 virtual std::string getFunctionName() const { return "Tesseract"; } 00024 00025 virtual void SetParameters(const ParameterMap &parms) { 00026 # if 1 00027 for (ParameterMap::const_iterator i = parms.begin(); 00028 i != parms.end(); ++i) { 00029 if (i->second->getName() == "Size") _a = i->second->toDouble(); 00030 } 00031 # else 00032 setParameter(parms, this->a, "Size"); 00033 # endif 00034 } 00035 00037 virtual std::string description () { 00038 std::ostringstream out; 00039 out << "Tesseract of edge length " << _a << std::ends; 00040 return out.str (); 00041 } 00042 # if !USE_INT_INDICES 00043 00044 virtual void Draw (UI::View *view); 00045 00046 # endif 00047 protected: 00048 virtual void Initialize(); 00049 void DeclareSquare (unsigned, unsigned, unsigned, unsigned, unsigned, unsigned = 0); 00050 00051 double _a; 00052 VecMath::Vector<4> _center; 00053 00054 static constexpr unsigned num_vertices = 16; 00055 static constexpr unsigned num_faces = 24; 00056 00057 # if !USE_INT_INDICES 00058 surface_vec_type Surface; 00059 # endif 00060 }; 00061 00062 namespace { 00063 Displayable *createHypercube() { return new Hypercube; } 00064 const bool registeredH = TheFunctionFactory::Instance().registerFunction(createHypercube, "Object"); 00065 } 00066 00068 00070 00071 class Pyramid: public Object { 00072 public: 00073 Pyramid (); 00074 Pyramid (double _a, 00075 const VecMath::Vector<4> &_Center = VecMath::Vector<4> (0., 0., 0., 0.)); 00076 virtual ~Pyramid() { } 00077 00078 virtual std::string getFunctionName() const { return "Pentachoron"; } 00079 00080 virtual void SetParameters(const ParameterMap &parms) { 00081 # if 1 00082 for (ParameterMap::const_iterator i = parms.begin(); 00083 i != parms.end(); ++i) { 00084 if (i->second->getName() == "Size") a = i->second->toDouble(); 00085 } 00086 # else 00087 setParameter(parms, this->a, "Size"); 00088 # endif 00089 } 00090 00091 protected: 00092 00093 static constexpr unsigned num_vertices = 5; 00094 static constexpr unsigned num_faces = 10; 00095 00096 virtual void Initialize(); 00097 void DeclareTriangle (unsigned, unsigned, unsigned, unsigned); 00098 00099 VecMath::Vector<4> center; 00100 double a; 00101 }; 00102 00103 namespace { 00104 Displayable *createPyramid() { return new Pyramid(); } 00105 const bool registeredP = 00106 TheFunctionFactory::Instance().registerFunction(createPyramid, "Object"); 00107 } 00108 00110 00112 00119 class Gasket: public Pyramid { 00120 public: 00122 Gasket (unsigned level = 1, double rad = 1, 00123 VecMath::Vector<4> Center = VecMath::Vector<4> (0., 0.,0., 0.)); 00124 virtual ~Gasket() { } 00125 00126 virtual std::string getFunctionName() const { return "4D Sierpinski Gasket"; } 00127 00128 virtual void Transform (const VecMath::Rotation<4> &R, 00129 const VecMath::Vector<4> &T, 00130 const VecMath::Vector<4> &scale); 00131 virtual void Project (double ScrW, double CamW, bool DepthCue4D); 00132 virtual void Draw (UI::View *view); 00133 00134 virtual void SetParameters(const ParameterMap &parms) { 00135 # if 1 00136 for (ParameterMap::const_iterator i = parms.begin(); 00137 i != parms.end(); ++i) { 00138 if (i->second->getName() == "Level") 00139 Level = i->second->toUnsigned(); 00140 if (i->second->getName() == "Size") 00141 rad = i->second->toDouble(); 00142 } 00143 # else 00144 setParameter(parms, this->Phase, "Phase"); 00145 # endif 00146 } 00147 00148 virtual void ReInit (double, double, double, 00149 double, double, double, 00150 double, double, double) { 00151 List.clear(); 00152 Object::ReInit(0,0,0,0,0,0,0,0,0); 00153 } 00154 00155 protected: 00156 virtual void Initialize(); 00157 virtual unsigned long MemRequired (void); 00158 unsigned Level; 00159 std::vector<Pyramid *> List; 00160 double rad; 00161 VecMath::Vector<4> center; 00162 }; 00163 00164 namespace { 00165 Displayable *createGasket() { return new Gasket(); } 00166 const bool registeredG = 00167 TheFunctionFactory::Instance().registerFunction(createGasket, "Object"); 00168 } 00169 00170 00171 #endif /* OBJECTIMPLEMENTATIONS_H */ 00172