#include "LSystem.h" /*Default Constructor*/ LSystem::LSystem() { init = ""; iterations = 0; } /*sets the initial string */ void LSystem::setInit(string s) { init = s; } /* adds a ruled to the L-System*/ void LSystem::addRule(char c, string s) { rules.insert(map::value_type(c,s)); } /* sets the number of times the grammar will regenerate */ void LSystem::setIterations(int i) { iterations = i; } /* returns the output of the L-System */ string LSystem::output() { string out = init; for(int i =0; i m) { char c; string out = ""; string temp = ""; for(int i = 0 ; i::iterator itr = m.find(c); if(itr != m.end()) out += (*itr).second; else out += c; } return out; } /* returns a Rules String for the Win32 dialog box */ string LSystem::getRulesString() { string value = ""; map::iterator itr; /* go through all the rules and print them */ for(itr = rules.begin() ; itr != rules.end() ; itr++) { value += (*itr).first; value += "="; value += (*itr).second; value += "\r\r\n"; } return value; } /* clears out the rules */ void LSystem::emptyRules() { rules.clear(); } void LSystem::setRules(string s) { emptyRules(); int index=0; while((index =s.find('=',index+1)) > 0) { addRule(s[index-1],s.substr(index+1,(s.find_first_of("\r\0",index)-1))); } }