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
36 class LindenmayerSystem
42 * @param model empty model
44 LindenmayerSystem(Model
*model
);
52 * Clear all parameters
57 * Generate L-system data
62 * Set the initial rule (the axiom)
63 * @param axiom the axiom
65 void setAxiom(string axiom
);
69 * @param name rule name
70 * @param rule the rule
72 void setRule(string name
, string rule
);
75 * Set the turn/pitch/roll angle
76 * @param degrees the angle, in degrees
78 void setAngle(double degrees
);
81 * Set the number of iterations
82 * @param numIterations number of iterations
84 void setNumIterations(int numIterations
);
87 * Set diameter of segment
88 * @param diameter the diameter
90 void setDiameter(double diameter
);
94 * @param diameterFactor the diameter factor
96 void setDiameterFactor(double diameterFactor
);
99 * Get the initial rule (the axiom)
108 map
<string
,string
> getRules();
111 * Get the turn/pitch/roll angle
112 * @return the angle, in degrees
117 * Get the number of iterations
118 * @return number of iterations
120 int getNumIterations();
123 * Get the generated model
124 * @return generated model
131 * Recursively apply the replacement rules
133 * @param level recursion level
135 void recursiveWalk(string rule
, int level
);
138 * Verify and preprocess one rule string
139 * @param rule the rule
140 * @return the preprocessed rule
142 string
verifyAndPreprocessRule(string rule
);
145 * Unpreprocess one rule string
146 * @param rule the rule
147 * @return the unpreprocessed rule
149 string
unpreprocessRule(string rule
);
153 map
<string
,string
> _rules
; // TODO: use unsorted container?
156 Model
*_model
; // The active model
157 Turtle
*_turtle
; // The rendering turtle