Changeset 977 for cpp


Ignore:
Timestamp:
07/06/20 23:39:36 (4 years ago)
Author:
Maciej Komosinski
Message:

Renamed functions for consistency; added an example of using getSupportedShapeTypes() and getSupportedJointShapes()

Location:
cpp/frams
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/_demos/genomanipulation.cpp

    r972 r977  
    195195                        printf(" (getPreferredInputs()) ");
    196196                        printf(cl->getPreferredOutput() ? "and provides meaningful output signal (getPreferredOutput()==1).\n" : "and doesn't provide useful output signal (getPreferredOutput()==0).\n");
     197                        printf("Instances of '%s' can be used in models having ", cl->getName().c_str());
     198                        if (cl->getSupportedShapeTypes() == NeuroClass::SUPPORTED_SHAPE_ALL)
     199                                printf("any shape types.\n");
     200                        else
     201                                {
     202                                printf("shape types:");
     203                                for(int i=Model::SHAPE_FIRST; i<= Model::SHAPE_LAST; i++)
     204                                        if (cl->isShapeTypeSupported((Model::ShapeType)i))
     205                                                printf(" '%s'",Model::getShapeTypeName((Model::ShapeType)i));
     206                                printf(".\n");
     207                                }
     208                        if (cl->preflocation == NeuroClass::PREFER_JOINT)
     209                                {
     210                                printf("Instances of '%s' can be attached to Joints having ", cl->getName().c_str());
     211                                if (cl->getSupportedJointShapes() == NeuroClass::SUPPORTED_JOINT_ALL)
     212                                        printf("any shapes");
     213                                else
     214                                        {
     215                                        printf("shapes:");
     216                                        for(int i=Joint::SHAPE_FIRST; i<= Joint::SHAPE_LAST; i++)
     217                                                if (cl->isJointShapeSupported((Joint::Shape)i))
     218                                                        printf(" '%s'",Joint::getShapeName((Joint::Shape)i));
     219                                        }
     220                                printf(".\n");
     221                                }
     222                        else if (cl->preflocation == NeuroClass::PREFER_PART)
     223                                printf("Instances of '%s' can be attached to Parts.\n", cl->getName().c_str());
    197224
    198225                        SyntParam p = n->classProperties();
  • cpp/frams/genetics/genman.cpp

    r966 r977  
    2020#ifdef USE_GENMAN_f0
    2121#include "f0/f0_oper.h"
     22#endif
     23#ifdef USE_GENMAN_f0s
     24#include "f0s/f0s_oper.h"
    2225#endif
    2326#ifdef USE_GENMAN_f0FUZZY
     
    132135#ifdef USE_GENMAN_f0
    133136        oper_fx_list.push_back(new Geno_f0);
     137#endif
     138#ifdef USE_GENMAN_f0s
     139        oper_fx_list.push_back(new Geno_f0s);
    134140#endif
    135141#ifdef USE_GENMAN_f0FUZZY
  • cpp/frams/model/modelparts.cpp

    r975 r977  
    107107        preflocation(_preflocation),
    108108        supported_shape_types(sup_shapes),
     109        supported_joint_shapes(sup_joints),
    109110        vectordata(_vectordata),
    110111        visualhints(vhints), impl_count(0),/*impl(0),*/active(1), genactive(0)
     
    624625}
    625626
     627const char* Part::getShapeName(Shape sh)
     628{
     629        switch (sh)
     630        {
     631        case SHAPE_BALL_AND_STICK: return "ball-and-stick";
     632        case SHAPE_ELLIPSOID: return "ellipsoid";
     633        case SHAPE_CUBOID: return "cuboid";
     634        case SHAPE_CYLINDER: return "cylinder";
     635
     636        default:
     637                return "unknown shape";
     638        }
     639}
    626640
    627641///////////////////////////
     
    709723}
    710724
     725const char* Joint::getShapeName(Shape sh)
     726{
     727        switch (sh)
     728        {
     729        case SHAPE_BALL_AND_STICK: return "ball-and-stick";
     730        case SHAPE_FIXED: return "fixed";
     731        case SHAPE_HINGE_X: return "hinge x";
     732        case SHAPE_HINGE_XY: return "hinge xy";
     733
     734        default:
     735                return "unknown shape";
     736        }
     737}
     738
     739
    711740/////////////////////////////////////////////////////////////////
    712741
  • cpp/frams/model/modelparts.h

    r975 r977  
    3434{
    3535public:
    36         enum ShapeType { SHAPE_BALL_AND_STICK = 0, SHAPE_SOLIDS = 1, SHAPE_UNKNOWN, SHAPE_ILLEGAL }; ///< 0 and 1 have special significance - these values allow for bit operations.
    37 };
    38 
     36        enum ShapeType { SHAPE_BALL_AND_STICK = 0, SHAPE_SOLIDS = 1, SHAPE_UNKNOWN, SHAPE_ILLEGAL, ///< 0 and 1 have special significance - these values allow for bit operations.
     37                         SHAPE_FIRST = SHAPE_BALL_AND_STICK, SHAPE_LAST = SHAPE_SOLIDS // for iteration
     38        };
     39};
    3940
    4041/** Common base for model elements. */
     
    9596        ///
    9697        paInt shape;///default=old Framsticks compatible, do not mix with shapes>0
    97         enum Shape { SHAPE_BALL_AND_STICK = 0, SHAPE_ELLIPSOID = 1, SHAPE_CUBOID = 2, SHAPE_CYLINDER = 3 };
     98        enum Shape { SHAPE_BALL_AND_STICK = 0, SHAPE_ELLIPSOID = 1, SHAPE_CUBOID = 2, SHAPE_CYLINDER = 3,
     99                     SHAPE_FIRST = SHAPE_BALL_AND_STICK, SHAPE_LAST = SHAPE_CYLINDER // for iteration
     100        };
     101        static const char* getShapeName(Shape sh);
     102
    98103        double mass, size, density, friction, ingest, assim, hollow;
    99104        Pt3D scale;
     
    149154                SHAPE_FIXED = 1, ///< merge parts into one physical entity
    150155                SHAPE_HINGE_X = 2, ///< hinge connection, revolving around X axis defined by hinge_pos and hinge_rot
    151                 SHAPE_HINGE_XY = 3 ///< double hinge connection, revolving around X and Y axes defined by hinge_pos and hinge_rot
     156                SHAPE_HINGE_XY = 3, ///< double hinge connection, revolving around X and Y axes defined by hinge_pos and hinge_rot
     157                SHAPE_FIRST = SHAPE_BALL_AND_STICK, SHAPE_LAST = SHAPE_HINGE_XY // for iteration
    152158        };
    153159        paInt shape;///< values of type Shape (paInt for integration with Param)
     160        static const char* getShapeName(Shape sh);
    154161        class Pt3D hinge_pos; ///< hinge position (relative to part1) for HINGE_X and HINGE_XY
    155162        class Pt3D hinge_rot; ///< hinge orientation (relative to part1) for HINGE_X and HINGE_XY
     
    223230        paInt preflocation;
    224231
     232        enum PrefLocation { PREFER_UNATTACHED=0, PREFER_PART=1, PREFER_JOINT=2 };
     233       
    225234        static constexpr int SUPPORTED_SHAPE_BALL_AND_STICK = 1;
    226235        static constexpr int SUPPORTED_SHAPE_SOLIDS = 2;
     
    233242        static constexpr int SUPPORTED_JOINT_HINGE_XY = 8;
    234243        static constexpr int SUPPORTED_JOINT_ALL = SUPPORTED_JOINT_BALL_AND_STICK + SUPPORTED_JOINT_FIXED + SUPPORTED_JOINT_HINGE_X + SUPPORTED_JOINT_HINGE_XY;
    235         paInt supported_joint_types; //< bitfield of 'Joint::shape' values: NeuroClass::SUPPORTED_JOINT_xxx = 1 << JOINT::SHAPE_xxx
     244        paInt supported_joint_shapes; //< bitfield of 'Joint::shape' values: NeuroClass::SUPPORTED_JOINT_xxx = 1 << JOINT::SHAPE_xxx
    236245
    237246        int *vectordata;
     
    286295        int getSupportedShapeTypes() { return (int)supported_shape_types; }
    287296        bool isShapeTypeSupported(ModelEnum::ShapeType t) { return (1 << (int)t) & supported_shape_types; }
    288         int getSupportedJointTypes() { return (int)supported_joint_types; }
    289         bool isJointTypeSupported(Joint::Shape t) { return (1 << (int)t) & supported_joint_types; }
     297        int getSupportedJointShapes() { return (int)supported_joint_shapes; }
     298        bool isJointShapeSupported(Joint::Shape t) { return (1 << (int)t) & supported_joint_shapes; }
    290299        int *getSymbolGlyph()
    291300        {
Note: See TracChangeset for help on using the changeset viewer.