LSystem.cpp
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @file LSystem.cpp 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @date December 2006 00005 00006 @brief 00007 Models a Lindenmayer System, which may be used to simulate a varient of 00008 effects in Nature, such as plant growth and fractals. 00009 <!-------------------------------------------------------------------->**/ 00010 00011 #include "LSystem.h" 00012 00013 std::string LSystem::_process(const std::string &state, unsigned depth) { 00014 if (depth <= 0) 00015 return state; 00016 00017 std::string next = ""; 00018 00019 for(unsigned i = 0; i < state.length(); ++i) { 00020 const char cur = state[i]; 00021 00022 if (m_rules.find(cur) != std::string::npos) 00023 next += _processRule(cur); 00024 else next += cur; 00025 } 00026 00027 return _process(next, depth - 1); 00028 } 00029
Generated on 28 Feb 2009 for Milton by
1.5.6