Ignore:
Timestamp:
11/30/19 01:30:22 (4 years ago)
Author:
Maciej Komosinski
Message:

Replaced #defined macros for popular random-related operations with functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/model.h

    r815 r896  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    7777        SList parts, joints, neurons;
    7878        char partmappingchanged;
    79         vector<Model*> checkpoints;
     79        vector<Model *> checkpoints;
    8080
    8181        void internalCopy(const Model &mod);
     
    141141
    142142        int getCheckpointCount();
    143         Model* getCheckpoint(int i);
     143        Model *getCheckpoint(int i);
    144144
    145145        /// The bounding box size. Valid if the model is valid. Read only.
     
    201201
    202202        /// change source genotype
    203         void setGeno(const Geno& newgeno);
     203        void setGeno(const Geno &newgeno);
    204204
    205205        /** @return f0 genotype - generated from current model state
     
    241241                @see convmap
    242242                */
    243         void getCurrentToF0Map(MultiMap& m);
     243        void getCurrentToF0Map(MultiMap &m);
    244244
    245245        void setValidationLevel(int level)
     
    250250        /// calculate location of the new part connected to the existing one
    251251        /// using delta option
    252         Pt3D whereDelta(const Part& start, const Pt3D& rot, const Pt3D& delta);
     252        Pt3D whereDelta(const Part &start, const Pt3D &rot, const Pt3D &delta);
    253253
    254254        /// create the whole model from scratch, using current genotype
     
    256256
    257257        /// setGeno(newgeno); rebuild();
    258         void rebuild(const Geno& newgeno, bool buildmaps) { setGeno(newgeno); rebuild(buildmaps); }
     258        void rebuild(const Geno &newgeno, bool buildmaps) { setGeno(newgeno); rebuild(buildmaps); }
    259259
    260260        /// reuse current model object but discard all model data
     
    262262
    263263        enum ItemType { UnknownType, ModelType, PartType, JointType, NeuronType, NeuronConnectionType, CheckpointType };
    264         static ItemType itemTypeFromLinePrefix(const char* line);
     264        static ItemType itemTypeFromLinePrefix(const char *line);
    265265        /** Execute single line of <B>f0</B> genotype.
    266266                Return value is non-negative reference number of the created item,
     
    270270                @param srcrange source genotype range which will be mapped to this element
    271271                */
    272         int addFromString(ItemType item_type, const SString &singleline, int line_num, const MultiRange* srcrange = NULL);
     272        int addFromString(ItemType item_type, const SString &singleline, int line_num, const MultiRange *srcrange = NULL);
    273273        /** Execute single line of <B>f0</B> genotype - compatiblity variant */
    274         int addFromString(ItemType item_type, const SString &singleline, const MultiRange* srcrange = NULL);
     274        int addFromString(ItemType item_type, const SString &singleline, const MultiRange *srcrange = NULL);
    275275        /** Execute single line of <B>f0</B> genotype - low level variant, used by Model::build(), error messages returned as string instead of calling logger */
    276         int addFromStringNoLog(ItemType item_type, const SString &singleline, SString& error_message, const MultiRange* srcrange = 0);
     276        int addFromStringNoLog(ItemType item_type, const SString &singleline, SString &error_message, const MultiRange *srcrange = 0);
    277277
    278278        /// separate build stages (for future use)
     
    357357
    358358        /// @return part index or -1 if not found in the model
    359         int findPart(Part* p);
     359        int findPart(Part *p);
    360360        /// @return joint index or -1 if not found in the model
    361         int findJoint(Joint* j);
     361        int findJoint(Joint *j);
    362362        /// @return neuro index or -1 if not found in the model
    363         int findNeuro(Neuro* nu);
     363        int findNeuro(Neuro *nu);
    364364        /// @return joint index or -1 if not found in the model
    365365        int findJoint(Part *p1, Part *p2);
     
    368368                @param result objects will be appended here
    369369                @return number of objects found  */
    370         int findNeuros(SList& result, const char* classname = 0, const Part* part = 0, const Joint* joint = 0);
     370        int findNeuros(SList &result, const char *classname = 0, const Part *part = 0, const Joint *joint = 0);
    371371
    372372        /** search for joints connected to the part
    373373                @param result objects will be appended here
    374374                @return number of objects found  */
    375         int findJoints(SList& result, const Part* part = 0);
     375        int findJoints(SList &result, const Part *part = 0);
    376376
    377377        void disturb(double amount);
    378         void move(const Pt3D& shift);
     378        void move(const Pt3D &shift);
    379379        /// rotate around the origin (move-rotate-move to rotate around arbitrary point)
    380         void rotate(const Orient& rotation);
     380        void rotate(const Orient &rotation);
    381381        /// rotate around the origin (move-rotate-move to rotate around arbitrary point)
    382         void rotate(const Pt3D& angles) { Orient o = Orient_1; o.rotate(angles); rotate(o); }
     382        void rotate(const Pt3D &angles) { Orient o = Orient_1; o.rotate(angles); rotate(o); }
    383383
    384384        /// build this model using solid shape types, based on the provided ball-and-stick model. See also shapeconvert.cpp.
    385         void buildUsingSolidShapeTypes(const Model& src_ballandstick_shapes, Part::Shape use_shape = Part::SHAPE_CYLINDER, double thickness = 0.2);
     385        void buildUsingSolidShapeTypes(const Model &src_ballandstick_shapes, Part::Shape use_shape = Part::SHAPE_CYLINDER, double thickness = 0.2);
    386386
    387387protected:
     
    403403        static int mapToNeuro(int i);
    404404
    405         static void makeGenToGenMap(MultiMap& result, const MultiMap& gen1tomodel, const MultiMap& gen2tomodel);
     405        static void makeGenToGenMap(MultiMap &result, const MultiMap &gen1tomodel, const MultiMap &gen2tomodel);
    406406
    407407        ///////////////////////////
    408408
    409         static Part& getMinPart();
    410         static Part& getMaxPart();
    411         static Part& getDefPart();
    412         static Joint& getMinJoint();
    413         static Joint& getMaxJoint();
    414         static Joint& getDefJoint();
    415         static Neuro& getMinNeuro();
    416         static Neuro& getMaxNeuro();
    417         static Neuro& getDefNeuro();
     409        static Part &getMinPart();
     410        static Part &getMaxPart();
     411        static Part &getDefPart();
     412        static Joint &getMinJoint();
     413        static Joint &getMaxJoint();
     414        static Joint &getDefJoint();
     415        static Neuro &getMinNeuro();
     416        static Neuro &getMaxNeuro();
     417        static Neuro &getDefNeuro();
    418418};
    419419
     
    436436        Model *converted_model;
    437437        Model *using_model;
    438         SolidsShapeTypeModel(Model& m, Part::Shape use_shape = Part::SHAPE_CYLINDER, double thickness = 0.2);
    439         operator Model&() { return *using_model; }
    440         Model& getModel() { return *using_model; }
     438        SolidsShapeTypeModel(Model &m, Part::Shape use_shape = Part::SHAPE_CYLINDER, double thickness = 0.2);
     439        operator Model &() { return *using_model; }
     440        Model &getModel() { return *using_model; }
    441441        ~SolidsShapeTypeModel() { if (converted_model) delete converted_model; }
    442442};
Note: See TracChangeset for help on using the changeset viewer.