Minor cleanup.
[lsystem3d.git] / src / lindenmayersystem.h
... / ...
CommitLineData
1// Copyright (C) 2006 Erik Dahlberg
2//
3// This file is part of LSystem3D.
4//
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.
9//
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.
14//
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
18
19
20
21
22#ifndef LINDENMAYERSYSTEM_H
23#define LINDENMAYERSYSTEM_H
24
25#include <string>
26
27#include "model.h"
28#include "turtle.h"
29#include "rule.h"
30#include "ruleset.h"
31
32using namespace std;
33
34
35
36/**
37 * Lindenmayer system generator
38 */
39class LindenmayerSystem
40{
41public:
42
43 /**
44 * Constructor
45 * @param model empty model
46 */
47 LindenmayerSystem(Model *model);
48
49 /**
50 * Destructor
51 */
52 ~LindenmayerSystem();
53
54
55 /**
56 * Clear all parameters
57 */
58 void clear();
59
60 /**
61 * Generate L-system data
62 */
63 void generate();
64
65 /**
66 * Render L-system data
67 */
68 void render();
69
70
71 /**
72 * Set the initial rule (the axiom)
73 * @param axiom the axiom
74 */
75 void setAxiom(Rule axiom);
76
77 /**
78 * Set one rule
79 * @param rule the rule
80 */
81 void setRule(Rule rule);
82
83 /**
84 * Set the turn/pitch/roll angle
85 * @param degrees the angle, in degrees
86 */
87 void setAngle(double degrees);
88
89 /**
90 * Set recursion depth
91 * @param depth depth of recursion
92 */
93 void setDepth(int depth);
94
95 /**
96 * Set initial segment diameter
97 * @param diameter the diameter
98 */
99 void setDiameter(double diameter);
100
101 /**
102 * Set segment diameter factor
103 * @param diameterFactor the diameter factor
104 */
105 void setDiameterFactor(double diameterFactor);
106
107
108 /**
109 * Get the initial rule (the axiom)
110 * @return the axiom
111 */
112 Rule getAxiom();
113
114 /**
115 * Get all rules
116 * @return the rules
117 */
118 RuleSet getRules();
119
120 /**
121 * Get the turn/pitch/roll angle
122 * @return the angle, in degrees
123 */
124 double getAngle();
125
126 /**
127 * Get recursion depth
128 * @return depth of recursion
129 */
130 int getDepth();
131
132 /**
133 * Get initial segment diameter
134 * @return the diameter
135 */
136 double getDiameter();
137
138 /**
139 * Get segment diameter factor
140 * @return the diameter factor
141 */
142 double getDiameterFactor();
143
144protected:
145
146 /**
147 * Recursively apply the replacement rules
148 * @param rule the rule
149 * @param level recursion level
150 */
151 void recursiveWalk(string rule, int level);
152
153
154 // Parameters
155 Rule _axiom;
156 RuleSet _rules;
157 int _depth;
158 double _segmentDiameter;
159
160 Model *_model; // The active model
161 Turtle *_turtle; // The rendering turtle
162};
163
164
165
166#endif