Ignore:
Timestamp:
11/26/20 01:30:40 (3 years ago)
Author:
Maciej Komosinski
Message:

fS: refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/fS/fS_general.h

    r1017 r1030  
    4343#define FRICTION "f"
    4444#define STIFFNESS "st"
    45 #define SIZE "s"
    46 #define SIZE_X "x"
    47 #define SIZE_Y "y"
    48 #define SIZE_Z "z"
     45#define SCALE "s"
     46#define SCALE_X "x"
     47#define SCALE_Y "y"
     48#define SCALE_Z "z"
    4949#define ROT_X "tx"
    5050#define ROT_Y "ty"
     
    8383const int JOINT_COUNT = JOINTS.length();
    8484const string MODIFIERS = "IFS";
    85 const char SIZE_MODIFIER = 's';
    86 const vector<string> PARAMS {INGESTION, FRICTION, ROT_X, ROT_Y, ROT_Z, RX, RY, RZ, SIZE, SIZE_X, SIZE_Y, SIZE_Z};
    87 const vector<string> SIZE_PARAMS {SIZE, SIZE_X, SIZE_Y, SIZE_Z};
     85const char SCALE_MODIFIER = 's';
     86const vector<string> PARAMS {INGESTION, FRICTION, ROT_X, ROT_Y, ROT_Z, RX, RY, RZ, SCALE, SCALE_X, SCALE_Y, SCALE_Z};
     87const vector<string> SCALE_PARAMS {SCALE, SCALE_X, SCALE_Y, SCALE_Z};
    8888
    8989/** @name Default values of node parameters*/
     
    247247struct GenotypeParams{
    248248        double modifierMultiplier;      // Every modifier changes the underlying value by this multiplier
     249        /// When calculating the distance between parts, the internal result is a range of numbers
     250        /// distanceTolerance is the maximal allowed size of this range
     251        double distanceTolerance;
     252        /// Used for deriving density for MeshBuilder
     253        double relativeDensity;
     254        ///
     255        bool turnWithRotation;
     256        ///
     257        double paramMutationStrength;
    249258};
    250259
     
    265274        Part *part;     /// A part object built from node. Used in building the Model
    266275        int partCodeLen; /// The length of substring that directly describes the corresponding part
    267         GenotypeParams genotypeParams;
     276        static std::map<string, double> minValues;      /// Min parameter values
     277        static std::map<string, double> defaultValues;  /// Default parameter values
     278        static std::map<string, double> maxValues;      /// Max parameter values
    268279
    269280        vector<Node *> children;    /// Vector of all direct children
     
    273284        void prepareParams();
    274285
    275         double getDistance();
    276 
    277286        void cleanUp();
    278287
     288        /// Get part's  rotation
    279289        Pt3D getRotation();
    280290
     291        /// Get the rotation of vector
    281292        Pt3D getVectorRotation();
    282293
    283         bool isPartSizeValid();
    284 
    285         bool hasPartSizeParam();
     294        bool isPartScaleValid();
    286295
    287296        /**
     
    362371
    363372public:
    364         static std::map<string, double> minValues;
    365         static std::map<string, double> defaultValues;
    366         static std::map<string, double> maxValues;
    367373        char joint = DEFAULT_JOINT;           /// Set of all joints
    368         Part::Shape partType;  /// The type of the part
     374        Part::Shape partShape;  /// The type of the part
    369375        State *state = nullptr; /// The phenotypic state that inherits from ancestors
    370376        std::map<string, double> params; /// The map of all the node params
     377        GenotypeParams genotypeParams; /// Parameters that affect the whole genotype
    371378
    372379        Node(Substring &genotype, Node *parent, GenotypeParams genotypeParams);
     
    381388
    382389        /**
    383          * Calculate the effective size of the part (after applying all multipliers and params)
    384          * @return The effective size
    385          */
    386         void calculateSize(Pt3D &scale);
     390         * Calculate the effective scale of the part (after applying all multipliers and params)
     391         * @return The effective scales
     392         */
     393        void calculateScale(Pt3D &scale);
    387394
    388395        /**
     
    404411        double getParam(const string &key);
    405412        double getParam(const string &key, double defaultValue);
     413
     414        /// Calculate distance between the part its parent
     415        double calculateDistanceFromParent();
    406416};
    407417
     
    439449
    440450
    441         static int precision;
    442         static bool TURN_WITH_ROTATION;
     451        static int precision; /// Number of decimal places for numbers in genotype
    443452
    444453        /**
     
    450459        ~fS_Genotype();
    451460
     461        /// Calculate the State field for all the nodes
    452462        void getState(bool calculateLocation);
    453463
     
    495505
    496506        /**
    497          * Check if sizes of all parts in genotype are valid
     507         * Check if scales of all parts in genotype are valid
    498508        \retval error_position 1-based
    499509        \retval 0 when all part sizes are valid
Note: See TracChangeset for help on using the changeset viewer.