X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flindenmayersystem.h;h=77c8ec0ec2832934b3854d23c9a113fac1c6eaed;hb=acf054bffd0737f5bef7fc3eba35d6a912e7c801;hp=d71fde6b6530225b9fb471a26a40768ffbe400ad;hpb=526db67540bf69a4c09ed0d0f4d62bad0a37ee70;p=lsystem3d.git diff --git a/src/lindenmayersystem.h b/src/lindenmayersystem.h index d71fde6..77c8ec0 100644 --- a/src/lindenmayersystem.h +++ b/src/lindenmayersystem.h @@ -1,6 +1,6 @@ // Copyright (C) 2006 Erik Dahlberg // -// This file is part of LSystem3d. +// This file is part of LSystem3D. // // LSystem3D is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -22,16 +22,19 @@ #ifndef LINDENMAYERSYSTEM_H #define LINDENMAYERSYSTEM_H -#include #include #include "model.h" #include "turtle.h" +#include "rule.h" +#include "ruleset.h" + +using namespace std; /** - * Lindenmayer System + * Lindenmayer system generator */ class LindenmayerSystem { @@ -48,6 +51,7 @@ public: */ ~LindenmayerSystem(); + /** * Clear all parameters */ @@ -58,18 +62,23 @@ public: */ void generate(); + /** + * Render L-system data + */ + void render(); + + /** * Set the initial rule (the axiom) * @param axiom the axiom */ - void setAxiom(string axiom); + void setAxiom(Rule axiom); /** * Set one rule - * @param name rule name * @param rule the rule */ - void setRule(string name, string rule); + void setRule(Rule rule); /** * Set the turn/pitch/roll angle @@ -78,34 +87,35 @@ public: void setAngle(double degrees); /** - * Set the number of iterations - * @param numIterations number of iterations + * Set recursion depth + * @param depth depth of recursion */ - void setNumIterations(int numIterations); + 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 */ - string getAxiom(); + Rule getAxiom(); /** * Get all rules * @return the rules */ - map getRules(); + RuleSet getRules(); /** * Get the turn/pitch/roll angle @@ -114,44 +124,38 @@ public: double getAngle(); /** - * Get the number of iterations - * @return number of iterations + * Get recursion depth + * @return depth of recursion + */ + int getDepth(); + + /** + * Get initial segment diameter + * @return the diameter */ - int getNumIterations(); + double getDiameter(); /** - * Get the generated model - * @return generated model + * Get segment diameter factor + * @return the diameter factor */ - Model *getModel(); + 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); - /** - * Verify and preprocess one rule string - * @param rule the rule - * @return the preprocessed rule - */ - string verifyAndPreprocessRule(string rule); - - /** - * Unpreprocess one rule string - * @param rule the rule - * @return the unpreprocessed rule - */ - string unpreprocessRule(string rule); // Parameters - string _axiom; - map _rules; // TODO: use unsorted container? - int _numIterations; + Rule _axiom; + RuleSet _rules; + int _depth; + double _segmentDiameter; Model *_model; // The active model Turtle *_turtle; // The rendering turtle