Changeset 732 for cpp/frams/model/model.h
- Timestamp:
- 02/15/18 00:42:07 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/model/model.h
r726 r732 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 15 15 16 16 extern ParamEntry f0_model_paramtab[]; 17 18 //#define EASYMAPDEBUG19 17 20 18 enum ModelBuildStatus { empty, building, invalid, valid }; … … 64 62 /// make model map in build() 65 63 bool autobuildmaps; 64 /// supports adding checkpoints 65 bool using_checkpoints; 66 /// means less strict validation 67 bool is_checkpoint; 66 68 /// valid if build from f0 genotype 67 69 int f0errorposition; … … 75 77 SList parts, joints, neurons; 76 78 char partmappingchanged; 79 vector<Model*> checkpoints; 77 80 78 81 void internalCopy(const Model &mod); … … 95 98 EDITING_CHECK, ///< Used in Model::validate(). Default validation - does not modify elements of the Model. 96 99 FINAL_CHECK, ///< Used in Model::close() when a Model is built from a genotype. Like EDITING_CHECK, but also calculates Joint::d and Joint::rot. 97 LIVE_CHECK ///< used in Model::close() when a Model is built from a Creature. Like FINAL_CHECK but does not limit joint length which could make some liveModels invalid. 100 LIVE_CHECK, ///< used in Model::close() when a Model is built from a Creature. Like FINAL_CHECK but does not limit joint length which could make some liveModels invalid. 101 CHECKPOINT_CHECK ///< used when storing checkpoint models. Like LIVE_CHECK, excluding consistency check (disjoint parts are acceptable) 98 102 }; 99 103 protected: 100 104 ShapeType shape; 101 105 102 void updateNeuroRefno(); // set Neuro::refno for all neurons103 106 SString nameForErrors() const; 104 107 int internalcheck(CheckType check); 105 108 106 void moveNeuro(int oldpos, int newpos); 107 108 void init(const Geno &srcgen); 109 void init(const Geno &srcgen, bool _using_checkpoints, bool _is_checkpoint); 109 110 void init(); 110 111 … … 134 135 int getErrorPosition(bool includingwarnings = false); 135 136 ShapeType getShapeType() const { return shape; } 137 bool isUsingCheckpoints() const { return using_checkpoints; } 138 bool isCheckpoint() const { return is_checkpoint; } 136 139 137 140 void updateRefno(); // set ::refno for all elements 141 142 int getCheckpointCount(); 143 Model* getCheckpoint(int i); 138 144 139 145 /// The bounding box size. Valid if the model is valid. Read only. … … 153 159 @see getMap() 154 160 */ 155 Model(const Geno &src, bool buildmaps = false );156 Model(const Model &mod, bool buildmaps = false );161 Model(const Geno &src, bool buildmaps = false, bool _using_checkpoints = false, bool _is_checkpoint = false); 162 Model(const Model &mod, bool buildmaps = false, bool _using_checkpoints = false, bool _is_checkpoint = false); 157 163 /** duplicate the model. 158 164 the resulting object's status is 'building' (opened). … … 255 261 void clear(); 256 262 257 enum ItemType { UnknownType, ModelType,PartType,JointType,NeuronType,NeuronConnectionType };263 enum ItemType { UnknownType, ModelType, PartType, JointType, NeuronType, NeuronConnectionType, CheckpointType }; 258 264 static ItemType itemTypeFromLinePrefix(const char* line); 259 265 /** Execute single line of <B>f0</B> genotype. … … 264 270 @param srcrange source genotype range which will be mapped to this element 265 271 */ 266 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); 267 273 /** Execute single line of <B>f0</B> genotype - compatiblity variant */ 268 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); 269 275 /** Execute single line of <B>f0</B> genotype - low level variant, used by Model::build(), error messages returned as string instead of calling logger */ 270 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); 271 277 272 278 /// separate build stages (for future use) … … 289 295 /// or modify the model created from the genotype. 290 296 /// Between open() and close() the model is not fully usable. 291 void open( );297 void open(bool _using_checkpoints = false, bool _is_checkpoint = false); 292 298 293 299 /// Current model written as f0 genotype while building … … 379 385 void buildUsingSolidShapeTypes(const Model& src_ballandstick_shapes, Part::Shape use_shape = Part::SHAPE_CYLINDER, float thickness = 0.2); 380 386 381 #ifdef EASYMAPDEBUG 382 static int partToMap(int i) {return 0+i;} 383 static int jointToMap(int i) {return 10+i;} 384 static int neuroToMap(int i) {return 20+i;} 385 static int mapToPart(int i) {return i-0;} 386 static int mapToJoint(int i) {return i-10;} 387 static int mapToNeuro(int i) {return i-20;} 388 #else 389 static int partToMap(int i) { return 0x10000000 + i; } 390 static int jointToMap(int i) { return 0x20000000 + i; } 391 static int neuroToMap(int i) { return 0x30000000 + i; } 392 static int mapToPart(int i) { return i - 0x10000000; } 393 static int mapToJoint(int i) { return i - 0x20000000; } 394 static int mapToNeuro(int i) { return i - 0x30000000; } 395 #endif 387 protected: 388 static const int MODEL_MAPPING_OFFSET = 0x10000000; 389 public: 390 static int elementToMap(ItemType t, int i); 391 struct TypeAndIndex 392 { 393 ItemType type; int index; 394 TypeAndIndex() :type(UnknownType), index(0) {} 395 TypeAndIndex(ItemType _type, int _index) :type(_type), index(_index) {} 396 }; 397 static TypeAndIndex mapToElement(int i); 398 static int partToMap(int i); 399 static int jointToMap(int i); 400 static int neuroToMap(int i); 401 static int mapToPart(int i); 402 static int mapToJoint(int i); 403 static int mapToNeuro(int i); 396 404 397 405 static void makeGenToGenMap(MultiMap& result, const MultiMap& gen1tomodel, const MultiMap& gen2tomodel);
Note: See TracChangeset
for help on using the changeset viewer.