+/**
+ * Render L-system data
+ */
+void LindenmayerSystem::render()
+{
+ _model->draw();
+}
+
+
+
/**
* Set the initial rule (the axiom)
* @param axiom the axiom
/**
- * Set depth of recursion
+ * Set recursion depth
* @param depth depth of recursion
*/
void LindenmayerSystem::setDepth(int depth)
/**
- * Set diameter of segment
+ * Set initial segment diameter
* @param diameter the diameter
*/
void LindenmayerSystem::setDiameter(double diameter)
{
+ _segmentDiameter = diameter;
_model->setDiameter(diameter);
}
/**
- * Set diameter factor
+ * Set segment diameter factor
* @param diameterFactor the diameter factor
*/
void LindenmayerSystem::setDiameterFactor(double diameterFactor)
/**
- * Get depth of recursion
+ * Get recursion depth
* @return depth of recursion
*/
int LindenmayerSystem::getDepth()
/**
- * Get the generated model
- * @return generated model
+ * Get initial segment diameter
+ * @return the diameter
*/
-Model *LindenmayerSystem::getModel()
+double LindenmayerSystem::getDiameter()
{
- return _model;
+ return _segmentDiameter;
+}
+
+
+
+/**
+ * Get segment diameter factor
+ * @return the diameter factor
+ */
+double LindenmayerSystem::getDiameterFactor()
+{
+ return _model->getDiameterFactor();
}
/**
* Recursively apply the replacement rules
- * @param rule rule
+ * @param rule the rule
* @param level recursion level
*/
void LindenmayerSystem::recursiveWalk(string rule, int level)
break;
- // decrement diameter of segment
+ // decrement segment diameter
case '!':
_model->decrementDiameter();
/**
- * Lindenmayer System
+ * Lindenmayer system generator
*/
class LindenmayerSystem
{
*/
~LindenmayerSystem();
+
/**
* Clear all parameters
*/
*/
void generate();
+ /**
+ * Render L-system data
+ */
+ void render();
+
+
/**
* Set the initial rule (the axiom)
* @param axiom the axiom
void setAngle(double degrees);
/**
- * Set depth of recursion
+ * Set recursion depth
* @param depth depth of recursion
*/
void setDepth(int depth);
/**
- * Set diameter of segment
+ * Set initial segment diameter
* @param diameter the diameter
*/
void setDiameter(double diameter);
/**
- * Set diameter factor
+ * Set segment diameter factor
* @param diameterFactor the diameter factor
*/
void setDiameterFactor(double diameterFactor);
+
/**
* Get the initial rule (the axiom)
* @return the axiom
double getAngle();
/**
- * Get depth of recursion
+ * Get recursion depth
* @return depth of recursion
*/
int getDepth();
/**
- * Get the generated model
- * @return generated model
+ * Get initial segment diameter
+ * @return the diameter
*/
- Model *getModel();
+ double getDiameter();
+
+ /**
+ * Get segment diameter factor
+ * @return the diameter factor
+ */
+ double getDiameterFactor();
protected:
/**
* Recursively apply the replacement rules
- * @param rule rule
+ * @param rule the rule
* @param level recursion level
*/
void recursiveWalk(string rule, int level);
+
// Parameters
Rule _axiom;
RuleSet _rules;
int _depth;
+ double _segmentDiameter;
Model *_model; // The active model
Turtle *_turtle; // The rendering turtle
FXApp *application = new FXApp("LSystem3D");
application->init(argc, argv);
+ // create the windows
+ RenderingSurface *surface = new RenderingSurface(application);
Model model;
LindenmayerSystem lsystem(&model);
-
- // create the windows and run the application
- RenderingSurface *surface = new RenderingSurface(application, &lsystem);
+ surface->setLSystem(&lsystem);
new GUI(application, surface, &lsystem);
+
application->create();
application->run();
}
/**
- * Save and load a L-system specification
+ * Saver and loader for L-system parameters
*/
class LSystemParameters : protected XMLStructure
{
public:
+
/**
* Constructor
*/
*/
~LSystemParameters();
+
/**
* Load parameters from xml file
* @param lsystem put parameters into this L-system