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