1 // Copyright (C) 2006 Erik Dahlberg
3 // This file is part of LSystem3d.
5 // LSystem3D is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // LSystem3D is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with LSystem3D; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef LINDENMAYERSYSTEM_H
23 #define LINDENMAYERSYSTEM_H
38 class LindenmayerSystem
43 * @param model the model for generation
45 LindenmayerSystem(Model
*model
);
53 * Set the initial rule (the axiom)
54 * @param axiom the axiom
56 void setAxiom(string axiom
);
60 * @param name rule name
61 * @param rule the rule
63 void setRule(string name
, string rule
);
66 * Set the turn/pitch/roll angle
67 * @param degrees the angle, in degrees
69 void setAngle(double degrees
);
72 * Set the number of iterations
73 * @param numIterations number of iterations
75 void setNumIterations(int numIterations
);
78 * Get the initial rule (the axiom)
87 map
<string
,string
> getRules();
90 * Get the turn/pitch/roll angle
91 * @return the angle, in degrees
96 * Get the number of iterations
97 * @return number of iterations
99 int getNumIterations();
102 * Generate l-system data
109 * Walk through the rule string for specified number of levels
110 * @param rule the rule
111 * @param level current iteration level
113 void recursiveWalk(string rule
, int level
);
116 * Verify and preprocess one rule string
117 * @param ruleOrAxiom the rule
118 * @return the preprocessed rule
120 string
verifyAndPreprocessRule(string ruleOrAxiom
);
123 * Unpreprocess one rule string
124 * @param ruleOrAxiom the rule
125 * @return the unpreprocessed rule
127 string
unpreprocessRule(string ruleOrAxiom
);
131 map
<string
,string
> _rules
; // TODO: use unsorted container?
134 Model
*_model
; // The model for generation
135 Turtle
*_turtle
; // The rendering turtle