71fe8484 |
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 RULE_H |
23 | #define RULE_H |
24 | |
25 | #include <string> |
26 | |
27 | using namespace std; |
28 | |
29 | |
30 | |
31 | /** |
32 | * L-system rule |
33 | */ |
34 | class Rule |
35 | { |
36 | public: |
37 | |
38 | /** |
39 | * Constructor |
40 | */ |
41 | Rule(); |
42 | |
43 | /** |
44 | * Constructor |
45 | * @param name name of rule |
46 | * @param content content of rule |
47 | * @param probability probability of rule |
48 | */ |
49 | Rule(string name, string content, double probability); |
50 | |
51 | /** |
52 | * Constructor |
53 | * @param ruleString the rule string |
54 | */ |
55 | Rule(string ruleString); |
56 | |
57 | /** |
58 | * Destructor |
59 | */ |
60 | ~Rule(); |
61 | |
62 | /** |
63 | * Clear rule |
64 | */ |
65 | void clear(); |
66 | |
67 | /** |
68 | * Construct rule from string |
69 | * @param ruleString the rule string |
70 | */ |
71 | void fromString(string ruleString); |
72 | |
73 | /** |
74 | * Construct rule string |
75 | * @return the rule string |
76 | */ |
77 | string toString(); |
78 | |
79 | /** |
80 | * Set rule name |
81 | * @param name the name |
82 | */ |
83 | void setName(string name); |
84 | |
85 | /** |
86 | * Set rule content |
87 | * @param content the content |
88 | */ |
89 | void setContent(string content); |
90 | |
91 | /** |
92 | * Set rule probability |
93 | * @param probability the probability factor |
94 | */ |
95 | void setProbability(double probability); |
96 | |
97 | /** |
98 | * Get rule name |
99 | * @return the rule name |
100 | */ |
101 | string getName(); |
102 | |
103 | /** |
104 | * Get rule content |
105 | * @return the rule content |
106 | */ |
107 | string getContent(); |
108 | |
109 | /** |
110 | * Get rule probability |
111 | * @return the probability |
112 | */ |
113 | double getProbability(); |
114 | |
115 | /** |
116 | * Get preprocessed content |
117 | * @return the preprocessed content |
118 | */ |
119 | string getPreprocessedContent(); |
120 | |
121 | protected: |
122 | |
123 | string _name; |
124 | string _content; |
125 | double _probability; |
126 | }; |
127 | |
128 | |
129 | |
130 | #endif |