#ifndef PLANT_HH #define PLANT_HH /* * Katie Lewis * April 2004 * Note: In codeing this referred to code examples from Professor Kuenning * and Matt Gnaizda. */ #include #include "plantiterator.hh" #include "location.hh" #include "node.hh" using namespace std; enum Sun { DOWN, ANGLE, FILTERED, AMBIENT }; enum LeafShape { EASY, CUBE, RECTANGLE, SPHERE, RECTANGLE, TRIANGLE }; enum LeafFunction { A, B, C, D }; enum StructFunction { X, Y, Z, W }; const Sun SUN_DEFAULT = DOWN; const LeafShape SHAPE_DEFAULT = EASY; const LeafFunction L_FUNC_DEFAULT = A; const StructFunction S_FUNC_DEFAULT = X; //string sunTypEE = "down"; //string leafShapEE = "easy"; //string leafFunctionEE = "A"; //string structFunctionEE = "X"; const int MAX_NUM_GPTS_DEFAULT = 1; const int MIN_BING_DEFAULT = 0; const int MAX_BING_DEFAULT = 10; class Node; class Location; class PlantIterator; class Plant { friend class PlantIterator; // let the iterator share // ...the private data public: Plant(); // constructor ~Plant(); // destructor Plant(Sun, LeafShape, LeafFunction, StructFunction, int minBranching, int maxBranching); Plant& operator=(const Plant&); // assignment operator Plant(const Plant&); // copy constructor bool addBranchPoint(const Location& placetoadd, const Location& tobeadded); bool addLeaf(const Location& placetoadd); bool addBetween(const Location& parent, // adds new node between const Location& tobeadded, // ...'parent' & parent's Location& child); // ...child 'child' bool randomAddBranchPoint(); bool randomAddLeaf(); void randomAddAnywhere(); // bool randomRemoveBranchPoint(); // bool randomRemoveLeaf(); // bool randomRemoveAnywhere(): double findFitness(); Plant& cross(Plant&); Plant& mutate1(); void printPovray(); void printStatistics(); void printRawBranchPointLocations(); private: /* Variables */ Node* root; // int numOtherPlants; // Node** otherPlants; Sun suntype; LeafShape shape; LeafFunction leafFunction; StructFunction structFunction; int minBranching; int maxBranching; /* Functions */ bool add(Node* placetoadd, Node* tobeadded); bool addBetween(Node* parent, Node* tobeadded, Location& child); Node* selectRandomNode(); Node* createRandomNode(bool); bool randomAdd(Node*); void randomAddAnywhere(Node*); Node* copy(Node* input); //copies a node and all its subtree void deleteAll(Node* input); Node* findLoc(Node* here, const Location& location); int nodeCount(Node* start); void printPov(Node* here); void printPovBranchPoint(Node* here); void printPovBranch(Node* here, Node* to); void printPovLeaf(Node* here); double leafBenefit(); double structCost(); double totalLength(Node*); double leafCount(Node*); }; #endif