Changeset 999 for cpp/frams/model
- Timestamp:
- 07/13/20 13:51:43 (4 years ago)
- Location:
- cpp/frams/model
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/model/geometry/modelgeoclass.cpp
r661 r999 74 74 if (m != NULL) 75 75 { 76 if (m->getShapeType() == Model::SHAPE _BALL_AND_STICK)76 if (m->getShapeType() == Model::SHAPETYPE_BALL_AND_STICK) 77 77 { 78 78 Model *converted = new Model; -
cpp/frams/model/model.cpp
r988 r999 17 17 } 18 18 19 void Model::init(ShapeType sh )19 void Model::init(ShapeType shtype) 20 20 { 21 21 partmappingchanged = 0; … … 29 29 f0map = 0; 30 30 f0genoknown = 1; 31 shape = SHAPE_UNKNOWN;32 declared_shape = sh;33 } 34 35 void Model::declareShapeType(ShapeType sh )36 { 37 declared_shape = sh;31 shapetype = SHAPETYPE_UNKNOWN; 32 declared_shapetype = shtype; 33 } 34 35 void Model::declareShapeType(ShapeType shtype) 36 { 37 declared_shapetype = shtype; 38 38 } 39 39 … … 56 56 geno = mod.geno; 57 57 f0genoknown = 0; 58 shape = mod.shape;59 declared_shape = mod.declared_shape;58 shapetype = mod.shapetype; 59 declared_shapetype = mod.declared_shapetype; 60 60 startenergy = mod.startenergy; 61 61 modelfromgenotype = mod.modelfromgenotype; … … 117 117 :autobuildmaps(buildmaps) 118 118 { 119 init(mod.declared_shape );119 init(mod.declared_shapetype); 120 120 open(_using_checkpoints, _is_checkpoint); 121 121 internalCopy(mod); … … 169 169 delMap(); 170 170 delF0Map(); 171 init(declared_shape );171 init(declared_shapetype); 172 172 geno = Geno(); 173 173 f0geno = Geno(); … … 340 340 f0warnposition = -1; 341 341 MultiMap *convmap = autobuildmaps ? new MultiMap() : NULL; 342 if (declared_shape == SHAPE_UNKNOWN)342 if (declared_shapetype == SHAPETYPE_UNKNOWN) 343 343 f0geno = geno.getConverted(Geno::F0_FORMAT_LIST, convmap, using_checkpoints); 344 344 else 345 f0geno = geno.getConverted(genoFormatForShapeType(declared_shape ), convmap, using_checkpoints);345 f0geno = geno.getConverted(genoFormatForShapeType(declared_shapetype), convmap, using_checkpoints); 346 346 f0genoknown = 1; 347 347 if (f0geno.isInvalid()) … … 351 351 return; 352 352 } 353 if (declared_shape == SHAPE_UNKNOWN)353 if (declared_shapetype == SHAPETYPE_UNKNOWN) 354 354 declareShapeType(shapeTypeForGenoFormat(f0geno.getFormat())); 355 355 SString f0txt = f0geno.getGenes(); … … 560 560 switch (st) 561 561 { 562 case SHAPE _BALL_AND_STICK:562 case SHAPETYPE_BALL_AND_STICK: 563 563 return "0"; 564 case SHAPE _SOLIDS:564 case SHAPETYPE_SOLIDS: 565 565 return "0s"; 566 566 default: … … 572 572 { 573 573 if (format == "0") 574 return SHAPE _BALL_AND_STICK;574 return SHAPETYPE_BALL_AND_STICK; 575 575 else if (format == "0s") 576 return SHAPE _SOLIDS;576 return SHAPETYPE_SOLIDS; 577 577 else 578 return SHAPE _UNKNOWN;578 return SHAPETYPE_UNKNOWN; 579 579 580 580 } … … 584 584 switch (sh) 585 585 { 586 case SHAPE _BALL_AND_STICK: return "ball-and-stick";587 case SHAPE _SOLIDS: return "solid shapes";588 case SHAPE _UNKNOWN: return "unknown";589 590 case SHAPE _ILLEGAL:586 case SHAPETYPE_BALL_AND_STICK: return "ball-and-stick"; 587 case SHAPETYPE_SOLIDS: return "solid shapes"; 588 case SHAPETYPE_UNKNOWN: return "unknown"; 589 590 case SHAPETYPE_ILLEGAL: 591 591 default: 592 592 return "illegal"; … … 894 894 int i, k; 895 895 int ret = 1; 896 shape = SHAPE_UNKNOWN;896 shapetype = SHAPETYPE_UNKNOWN; 897 897 updateRefno(); 898 898 if ((parts.size() == 0) && (neurons.size() == 0)) return 0; … … 931 931 if (p->p.y + p->size > bbmax.y) bbmax.y = p->p.y + p->size; 932 932 if (p->p.z + p->size > bbmax.z) bbmax.z = p->p.z + p->size; 933 if (shape == SHAPE_UNKNOWN)934 shape = (p->shape == Part::SHAPE_BALL_AND_STICK) ? SHAPE_BALL_AND_STICK : SHAPE_SOLIDS;935 else if (shape != SHAPE_ILLEGAL)933 if (shapetype == SHAPETYPE_UNKNOWN) 934 shapetype = (p->shape == Part::SHAPE_BALL) ? SHAPETYPE_BALL_AND_STICK : SHAPETYPE_SOLIDS; 935 else if (shapetype != SHAPETYPE_ILLEGAL) 936 936 { 937 if ((p->shape == Part::SHAPE_BALL _AND_STICK) ^ (shape == SHAPE_BALL_AND_STICK))937 if ((p->shape == Part::SHAPE_BALL) ^ (shapetype == SHAPETYPE_BALL_AND_STICK)) 938 938 { 939 shape = SHAPE_ILLEGAL;939 shapetype = SHAPETYPE_ILLEGAL; 940 940 logPrintf("Model", "internalCheck", LOG_WARN, "Inconsistent part shapes (mixed ball-and-stick and solids shape types)%s", nameForErrors().c_str()); 941 941 } … … 1002 1002 if ((check != LIVE_CHECK) && (check != CHECKPOINT_CHECK)) 1003 1003 { 1004 if (j->shape == Joint::SHAPE_ BALL_AND_STICK)1004 if (j->shape == Joint::SHAPE_STICK) 1005 1005 { 1006 1006 if (j->d() > getMaxJoint().d.x) … … 1017 1017 ret = 0; 1018 1018 } 1019 if (shape != SHAPE_ILLEGAL)1019 if (shapetype != SHAPETYPE_ILLEGAL) 1020 1020 { 1021 if ((j->shape == Joint::SHAPE_ BALL_AND_STICK) ^ (shape == SHAPE_BALL_AND_STICK))1021 if ((j->shape == Joint::SHAPE_STICK) ^ (shapetype == SHAPETYPE_BALL_AND_STICK)) 1022 1022 { 1023 shape = SHAPE_ILLEGAL;1023 shapetype = SHAPETYPE_ILLEGAL; 1024 1024 logPrintf("Model", "internalCheck", LOG_WARN, "Inconsistent joint shapes (mixed old and new shapes)%s", nameForErrors().c_str()); 1025 1025 } … … 1109 1109 } 1110 1110 1111 if (shape == SHAPE_ILLEGAL)1111 if (shapetype == SHAPETYPE_ILLEGAL) 1112 1112 ret = 0; 1113 else if ((declared_shape != SHAPE_UNKNOWN) && (declared_shape != shape))1114 { 1115 logPrintf("Model", "internalCheck", LOG_ERROR, "Model shape type '%s' does not match the declared type '%s'", getShapeTypeName(shape ), getShapeTypeName(declared_shape));1113 else if ((declared_shapetype != SHAPETYPE_UNKNOWN) && (declared_shapetype != shapetype)) 1114 { 1115 logPrintf("Model", "internalCheck", LOG_ERROR, "Model shape type '%s' does not match the declared type '%s'", getShapeTypeName(shapetype), getShapeTypeName(declared_shapetype)); 1116 1116 ret = 0; 1117 1117 } … … 1335 1335 { 1336 1336 using_model = converted_model = NULL; 1337 if (m.getShapeType() == Model::SHAPE _BALL_AND_STICK)1337 if (m.getShapeType() == Model::SHAPETYPE_BALL_AND_STICK) 1338 1338 { 1339 1339 converted_model = new Model; -
cpp/frams/model/model.h
r972 r999 101 101 }; 102 102 protected: 103 ShapeType shape ;104 ShapeType declared_shape ;103 ShapeType shapetype; 104 ShapeType declared_shapetype; 105 105 106 106 SString nameForErrors() const; … … 134 134 int isValid() const { return buildstatus == valid; } 135 135 int getErrorPosition(bool includingwarnings = false); 136 ShapeType getShapeType() const { return shape ; }136 ShapeType getShapeType() const { return shapetype; } 137 137 bool isUsingCheckpoints() const { return using_checkpoints; } 138 138 bool isCheckpoint() const { return is_checkpoint; } … … 155 155 156 156 /// Create empty model with invalid empty genotype, declaring the shape type for later operations 157 Model(ShapeType sh = SHAPE _UNKNOWN);157 Model(ShapeType sh = SHAPETYPE_UNKNOWN); 158 158 159 159 /// Change the declared shape type of the Model … … 333 333 334 334 /** create new Part and add it to the model. @see addPart() */ 335 Part *addNewPart(Part::Shape shape = Part::SHAPE_BALL _AND_STICK) { return addPart(new Part(shape)); }335 Part *addNewPart(Part::Shape shape = Part::SHAPE_BALL) { return addPart(new Part(shape)); } 336 336 /** create new Joint and add it to the model. @see addJoint() */ 337 Joint *addNewJoint(Part *p1 = NULL, Part *p2 = NULL, Joint::Shape shape = Joint::SHAPE_ BALL_AND_STICK) { Joint *j = addJoint(new Joint()); j->shape = shape; if ((p1 != NULL) && (p2 != NULL)) j->attachToParts(p1, p2); return j; }337 Joint *addNewJoint(Part *p1 = NULL, Part *p2 = NULL, Joint::Shape shape = Joint::SHAPE_STICK) { Joint *j = addJoint(new Joint()); j->shape = shape; if ((p1 != NULL) && (p2 != NULL)) j->attachToParts(p1, p2); return j; } 338 338 /** create new Neuro and add it to the model. @see addNeuro() */ 339 339 Neuro *addNewNeuro() { return addNeuro(new Neuro()); } -
cpp/frams/model/modelobj.cpp
r972 r999 58 58 void ModelObj::p_newfromstring(ExtValue *args, ExtValue *ret) 59 59 { 60 *ret = makeDynamicObject(new Model(Geno(args[0].getString()), Model::SHAPE _UNKNOWN));60 *ret = makeDynamicObject(new Model(Geno(args[0].getString()), Model::SHAPETYPE_UNKNOWN)); 61 61 } 62 62 … … 65 65 Geno *g = GenoObj::fromObject(args[0].getObject()); 66 66 if (g) 67 *ret = makeDynamicObject(new Model(*g, Model::SHAPE _UNKNOWN));67 *ret = makeDynamicObject(new Model(*g, Model::SHAPETYPE_UNKNOWN)); 68 68 else 69 69 ret->setEmpty(); … … 74 74 Model *m = NULL; 75 75 if (args[0].getType() == TString) 76 m = new Model(Geno(args[0].getString()), Model::SHAPE _UNKNOWN, false, true);76 m = new Model(Geno(args[0].getString()), Model::SHAPETYPE_UNKNOWN, false, true); 77 77 else 78 78 { 79 79 Geno *g = GenoObj::fromObject(args[0].getObject(), false); 80 80 if (g) 81 m = new Model(*g, Model::SHAPE _UNKNOWN, false, true);81 m = new Model(*g, Model::SHAPETYPE_UNKNOWN, false, true); 82 82 else 83 83 logPrintf("Model", "newWithCheckpoints", LOG_ERROR, "Geno or string expected, %s found", args[0].typeDescription().c_str()); … … 178 178 void ModelObj::get_solid_model(ExtValue *ret) 179 179 { 180 if (getShapeType() != Model::SHAPE _BALL_AND_STICK)180 if (getShapeType() != Model::SHAPETYPE_BALL_AND_STICK) 181 181 ret->setEmpty(); 182 182 Model *m = new Model; -
cpp/frams/model/modelparts.cpp
r977 r999 629 629 switch (sh) 630 630 { 631 case SHAPE_BALL _AND_STICK: return "ball-and-stick";631 case SHAPE_BALL: return "ball[-and-stick]"; 632 632 case SHAPE_ELLIPSOID: return "ellipsoid"; 633 633 case SHAPE_CUBOID: return "cuboid"; … … 727 727 switch (sh) 728 728 { 729 case SHAPE_ BALL_AND_STICK: return "ball-and-stick";729 case SHAPE_STICK: return "[ball-and-]stick"; 730 730 case SHAPE_FIXED: return "fixed"; 731 731 case SHAPE_HINGE_X: return "hinge x"; -
cpp/frams/model/modelparts.h
r997 r999 34 34 { 35 35 public: 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 }; 36 enum ShapeType { 37 SHAPETYPE_BALL_AND_STICK = 0, SHAPETYPE_SOLIDS = 1, SHAPETYPE_UNKNOWN, SHAPETYPE_ILLEGAL, ///< 0 and 1 have special significance - these values allow for bit operations. 38 SHAPETYPE_FIRST = SHAPETYPE_BALL_AND_STICK, SHAPETYPE_LAST = SHAPETYPE_SOLIDS // for iteration 39 }; 39 40 }; 40 41 … … 73 74 }; 74 75 75 /// Part is the only real physical object in the Framsticks creature.76 /// Part is the only real physical object in creatures in Framsticks. 76 77 /// You can use this class for querying and adjusting constructed 77 /// model properties 78 /// model properties. 78 79 class Part : public PartBase 79 80 { … … 96 97 /// 97 98 paInt shape;///default=old Framsticks compatible, do not mix with shapes>0 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 99 enum Shape { 100 SHAPE_BALL = 0, ///< for "ball and stick" shape type model only. 101 SHAPE_ELLIPSOID = 1, SHAPE_CUBOID = 2, SHAPE_CYLINDER = 3, 102 SHAPE_FIRST = SHAPE_BALL, SHAPE_LAST = SHAPE_CYLINDER // for iteration 100 103 }; 101 104 static const char* getShapeName(Shape sh); … … 110 113 double vsize; 111 114 112 Part(enum Shape s = SHAPE_BALL _AND_STICK);115 Part(enum Shape s = SHAPE_BALL); 113 116 Part(const Part &src) :PartBase(getDefaultStyle()) { operator=(src); } 114 117 void operator=(const Part &src); … … 151 154 class Pt3D rot; ///< orientation delta between parts expressed as 3 angles 152 155 enum Shape { 153 SHAPE_ BALL_AND_STICK = 0, ///< old Framsticks compatible, creates a physical rod between parts (cylinder or cuboid), do not mix with part.shape>0156 SHAPE_STICK = 0, ///< for "ball and stick" shape type model, creates a physical (cylinder or cuboid) rod between parts. Do not mix with part.shape>0. 154 157 SHAPE_FIXED = 1, ///< merge parts into one physical entity 155 158 SHAPE_HINGE_X = 2, ///< hinge connection, revolving around X axis defined by hinge_pos and hinge_rot 156 159 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 iteration160 SHAPE_FIRST = SHAPE_STICK, SHAPE_LAST = SHAPE_HINGE_XY // for iteration 158 161 }; 159 162 paInt shape;///< values of type Shape (paInt for integration with Param) … … 230 233 paInt preflocation; 231 234 232 enum PrefLocation { PREFER_UNATTACHED =0, PREFER_PART=1, PREFER_JOINT=2 };233 234 static constexpr int SUPPORTED_SHAPE _BALL_AND_STICK = 1;235 static constexpr int SUPPORTED_SHAPE _SOLIDS = 2;236 static constexpr int SUPPORTED_SHAPE _ALL = SUPPORTED_SHAPE_BALL_AND_STICK | SUPPORTED_SHAPE_SOLIDS;235 enum PrefLocation { PREFER_UNATTACHED = 0, PREFER_PART = 1, PREFER_JOINT = 2 }; 236 237 static constexpr int SUPPORTED_SHAPETYPE_BALL_AND_STICK = 1; 238 static constexpr int SUPPORTED_SHAPETYPE_SOLIDS = 2; 239 static constexpr int SUPPORTED_SHAPETYPE_ALL = SUPPORTED_SHAPETYPE_BALL_AND_STICK | SUPPORTED_SHAPETYPE_SOLIDS; 237 240 paInt supported_shape_types; //< bitfield of 'Model::shape' values: NeuroClass::SUPPORTED_SHAPE_xxx = 1 << Model::SHAPE_xxx 238 241 … … 241 244 static constexpr int SUPPORTED_JOINT_HINGE_X = 4; 242 245 static constexpr int SUPPORTED_JOINT_HINGE_XY = 8; 243 static constexpr int SUPPORTED_JOINT _ALL = SUPPORTED_JOINT_BALL_AND_STICK + SUPPORTED_JOINT_FIXED + SUPPORTED_JOINT_HINGE_X + SUPPORTED_JOINT_HINGE_XY;246 static constexpr int SUPPORTED_JOINTSHAPE_ALL = SUPPORTED_JOINT_BALL_AND_STICK + SUPPORTED_JOINT_FIXED + SUPPORTED_JOINT_HINGE_X + SUPPORTED_JOINT_HINGE_XY; 244 247 paInt supported_joint_shapes; //< bitfield of 'Joint::shape' values: NeuroClass::SUPPORTED_JOINT_xxx = 1 << JOINT::SHAPE_xxx 245 248 … … 257 260 NeuroClass(); 258 261 NeuroClass(ParamEntry *_props, SString _description, 259 int _prefinputs, int _prefoutput, int _preflocation, int *_vectordata, bool own_vd = 1, int vhints = 0, int sup_shapes = NeuroClass::SUPPORTED_SHAPE_ALL, int sup_joints = NeuroClass::SUPPORTED_JOINT_ALL);262 int _prefinputs, int _prefoutput, int _preflocation, int *_vectordata, bool own_vd = 1, int vhints = 0, int sup_shapes = NeuroClass::SUPPORTED_SHAPETYPE_ALL, int sup_joints = NeuroClass::SUPPORTED_JOINTSHAPE_ALL); 260 263 /** class name for use in Neuro::setClassName(), Neuro::setDetails() (former 'moredata' field), 261 264 eg. "N","-",G" */ -
cpp/frams/model/similarity/simil_model.cpp
r972 r999 534 534 return NULL; 535 535 } 536 Model *m = new Model(*g, Model::SHAPE _UNKNOWN);536 Model *m = new Model(*g, Model::SHAPETYPE_UNKNOWN); 537 537 if (!m->isValid()) 538 538 {
Note: See TracChangeset
for help on using the changeset viewer.