Changeset 934 for cpp


Ignore:
Timestamp:
05/29/20 15:18:48 (2 months ago)
Author:
Maciej Komosinski
Message:

Introduced 'volume' field available by getMinPart(), getMaxPart(), getDefPart() for genetic operators to limit the range of volumes (~mass) in simulation of solids

Location:
cpp/frams
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/config/f0-SDK.def

    r932 r934  
    3232XPROP(vg,2,1024,green component,f,0.0,1.0,1.0,vcolor.y)
    3333XPROP(vb,2,1024,blue component,f,0.0,1.0,1.0,vcolor.z)
     34ENDCLASS
     35
     36CLASS(Part_MinMaxDef,f0_part_minmaxdef,p)
     37GROUP(Geometry)
     38PROP(f,0,0,volume,f,0.1,10,1,volume)
    3439ENDCLASS
    3540
  • cpp/frams/config/f0.def

    r932 r934  
    3232XPROP(vg,2,1024,green component,f,0.0,1.0,1.0,vcolor.y)
    3333XPROP(vb,2,1024,blue component,f,0.0,1.0,1.0,vcolor.z)
     34ENDCLASS
     35
     36CLASS(Part_MinMaxDef,f0_part_minmaxdef,p)
     37GROUP(Geometry)
     38PROP(f,0,0,volume,f,0.1,10,1,volume)
    3439ENDCLASS
    3540
  • cpp/frams/model/defassign-f0-SDK.h

    r932 r934  
    2525vcolor.z=1.0;
    2626}
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63void Part_MinMaxDef::defassign()
     64{
     65volume=1;
     66}
     67
     68
    2769
    2870
     
    121163
    122164
     165
     166
    123167void Neuro::defassign()
    124168{
     
    128172vis_style="neuro";
    129173}
     174
     175
    130176
    131177
  • cpp/frams/model/f0-SDK-classes.h

    r932 r934  
    6363 {"vg",0,1024,"green component","f 0.0 1.0 1.0",FIELD(vcolor.y),},
    6464 {"vb",0,1024,"blue component","f 0.0 1.0 1.0",FIELD(vcolor.z),},
     65 {0,0,0,}
     66};
     67#undef FIELDSTRUCT
     68
     69
     70#define FIELDSTRUCT Part_MinMaxDef
     71ParamEntry f0_part_minmaxdef_paramtab[]=
     72{
     73 {"Geometry",1,1,"p" },
     74 {"f",0,0,"volume","f 0.1 10 1",FIELD(volume),},
     75 {0,0,0,}
     76};
     77ParamEntry f0_part_minmaxdef_xtra_paramtab[]=
     78{
     79 {"Extra properties",1,0,"p"},
    6580 {0,0,0,}
    6681};
  • cpp/frams/model/model.cpp

    r915 r934  
    13281328//////////////////////
    13291329
    1330 class MinPart : public Part { public: MinPart() { Param par(f0_part_paramtab, this); par.setMin(); } };
    1331 class MaxPart : public Part { public: MaxPart() { Param par(f0_part_paramtab, this); par.setMax(); } };
     1330class MinPart : public Part_MinMaxDef { public: MinPart() { Param par(f0_part_paramtab, this); par.setMin(); Param par2(f0_part_minmaxdef_paramtab, this); par2.setMin(); } };
     1331class MaxPart : public Part_MinMaxDef { public: MaxPart() { Param par(f0_part_paramtab, this); par.setMax(); Param par2(f0_part_minmaxdef_paramtab, this); par2.setMax(); } };
    13321332class MinJoint : public Joint { public: MinJoint() { Param par(f0_joint_paramtab, this); par.setMin(); } };
    13331333class MaxJoint : public Joint { public: MaxJoint() { Param par(f0_joint_paramtab, this); par.setMax(); } };
     
    13351335class MaxNeuro : public Neuro { public: MaxNeuro() { Param par(f0_neuro_paramtab, this); par.setMax(); } };
    13361336
    1337 Part &Model::getMinPart() { static MinPart part; return part; }
    1338 Part &Model::getMaxPart() { static MaxPart part; return part; }
    1339 Part &Model::getDefPart() { static Part part; return part; }
     1337Part_MinMaxDef &Model::getMinPart() { static MinPart part; return part; }
     1338Part_MinMaxDef &Model::getMaxPart() { static MaxPart part; return part; }
     1339Part_MinMaxDef &Model::getDefPart() { static Part_MinMaxDef part; return part; }
    13401340Joint &Model::getMinJoint() { static MinJoint joint; return joint; }
    13411341Joint &Model::getMaxJoint() { static MaxJoint joint; return joint; }
  • cpp/frams/model/modelparts.h

    r932 r934  
    2626typedef UserTags<Model, void *, 5> ModelUserTags;
    2727
     28
     29/// Introduced only because we can't have a forward declaration of enum in the Model class,
     30/// and we would need a forward declaration because of mutual (cyclic) dependence of declarations of Model and NeuroClass.
     31/// https://stackoverflow.com/questions/27019292/is-in-class-enum-forward-declaration-possible
     32/// Use Model::... instead of ModelEnum::...
     33class ModelEnum
     34{
     35public:
     36        enum ShapeType { SHAPE_BALL_AND_STICK, SHAPE_SOLIDS, SHAPE_UNKNOWN, SHAPE_ILLEGAL };
     37};
     38
     39
    2840/** Common base for model elements. */
    2941class PartBase
     
    102114
    103115        static Param &getStaticParam();
     116};
     117
     118class Part_MinMaxDef : public Part //contains additional information for Model::getMinPart()/getMaxPart()/getDefPart()
     119{
     120public:
     121        double volume; ///< Introduced to limit the range of volumes (~mass) in simulation of solids. Genetic operators should observe this min,max volume by calculating and limiting the volume of Parts based on their type and sx,sy,sz.
     122
     123        void defassign();
     124        Part_MinMaxDef() { defassign(); }
    104125};
    105126
     
    256277                */
    257278        int getSupportedShapeTypes() { return (int)supported_shape_types; }
     279        bool isShapeTypeSupported(ModelEnum::ShapeType t) { return (1 << (int)t) & supported_shape_types; }
    258280        int *getSymbolGlyph()
    259281        {
     
    511533};
    512534
    513 extern ParamEntry f0_part_paramtab[], f0_joint_paramtab[], f0_nodeltajoint_paramtab[], f0_neuro_paramtab[], f0_neuroconn_paramtab[], f0_neuroitem_paramtab[];
     535extern ParamEntry f0_part_paramtab[], f0_part_minmaxdef_paramtab[], f0_joint_paramtab[], f0_nodeltajoint_paramtab[], f0_neuro_paramtab[], f0_neuroconn_paramtab[], f0_neuroitem_paramtab[];
    514536
    515537#endif
  • cpp/frams/neuro/neurocls-f0-SDK-factory.h

    r921 r934  
    66// do not edit - generated automatically from "f0.def"
    77// (to be included in "neurofactory.cpp")
     8
    89
    910
  • cpp/frams/neuro/neurocls-f0-SDK-library.h

    r932 r934  
    66// do not edit - generated automatically from "f0.def"
    77// (to be included in "neurolibrary.cpp")
     8
    89
    910
Note: See TracChangeset for help on using the changeset viewer.