HyperspaceExplorer 0.7.1
|
00001 00002 // project: hyperspace explorer 00003 // module: 00004 // contains: 00005 // compile with: 00006 // author: helge preuss (scout@hyperspace-travel.de) 00007 // license: GPL (see License.txt) 00008 00009 00010 #if(!defined LSYSTEM_OLD_H) 00011 #define LSYSTEM_OLD_H 00012 00013 #include "Vector.h" 00014 #include "Matrix.h" 00015 00016 #include <string> 00017 #include <map> 00018 #include <vector> 00019 00020 using namespace std; 00021 00022 typedef VecMath::Vector<3, double> Vector; 00023 using VecMath::Matrix; 00024 00027 class LSystem_old { 00028 public: 00030 LSystem_old (unsigned = 2); 00032 LSystem_old (string, map<string, string>, unsigned = 2); 00034 virtual ~LSystem_old (); 00035 00037 void level (unsigned n) { m_level = n; } 00039 unsigned level () { return m_level; } 00040 00042 void axiom (string a) { m_axiom = a; } 00044 string axiom () { return m_axiom; } 00045 00047 void set_rule (string key, string rule) { m_rules[key] = rule; } 00049 void rules (map<string, string> rules) {m_rules = rules; } 00051 map<string, string> rules (void) { return m_rules; } 00052 00054 void angle (double angle) { m_angle = angle; } 00056 double angle () { return m_angle; } 00057 00059 void object (string key, string object) { m_object[key] = object; } 00061 void object (map<string, string> object); 00063 map<string, string> object () { return m_object; } 00065 string object (string key) { return m_object[key]; } 00066 00068 virtual string Expand (); 00069 00071 virtual string POV_Source (); 00073 virtual void Draw () { throw "nyi!"; } 00074 00075 protected: 00077 string POV_Header (const string &); 00079 string POV_Footer (const Vector &, const Vector &); 00081 virtual string POV_Atom (const string &, const string &); // one element of the l-system, pov-style 00082 00084 virtual string Expand (string, unsigned); 00085 00086 string m_axiom; 00087 map<string, string> m_rules; 00088 unsigned m_level; 00089 double m_scale; 00090 double m_angle; 00091 map<string, string> m_object; 00092 }; 00093 00094 // functions defined in LSys_aux.C 00095 00096 string str_replace (string, string, string); 00097 string str_replace (string, map<string, string>); 00098 string matrix_outstr (Matrix<3> M); 00099 string vector_outstr (const Vector &V); 00100 string dtos (const double &); 00101 void state_push (vector<Matrix<3> >&, const Matrix<3>&, 00102 vector<Vector>&, const Vector &, 00103 vector<string>&, const string &, 00104 vector<double>&, const double &); 00105 void state_pop (vector<Matrix<3> >&, Matrix<3>&, 00106 vector<Vector>&, Vector &, 00107 vector<string>&, string &, 00108 vector<double>&, double &); 00109 void read_file (const string &, unsigned &, string &, map<string, string> &, map<string, string> &); 00110 void help (const string &); 00111 double atof(const char *); 00112 int atoi(const char *); 00113 00114 00115 #endif