Changeset 732 for cpp/frams/model/modelobj.cpp
 Timestamp:
 02/15/18 00:42:07 (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

cpp/frams/model/modelobj.cpp
r722 r732 7 7 ParamEntry modelobj_paramtab[] = 8 8 { 9 { "Model", 1, 16, "Model", },9 { "Model", 1, 21, "Model", }, 10 10 { "se", 0, PARAM_NOSTATIC, "startenergy", "f", FIELD(startenergy), }, 11 11 { "Vstyle", 0, PARAM_NOSTATIC, "vis_style", "s", FIELD(vis_style), }, 12 12 13 { "geno", 0, PARAM_NOSTATIC  PARAM_READONLY, "geno", "o Geno", GETONLY(geno), }, 14 { "newFromString", 0, 0, "create new object", "p oModel(s genotype)", PROCEDURE(p_newfromstring), }, 15 { "newFromGeno", 0, 0, "create new object", "p oModel(oGeno)", PROCEDURE(p_newfromgeno), }, 13 { "geno", 0, PARAM_NOSTATIC  PARAM_READONLY, "Geno", "oGeno", GETONLY(geno), }, 14 { "newFromString", 0, 0, "Create a new object", "p oModel(s genotype)", PROCEDURE(p_newfromstring), }, 15 { "newFromGeno", 0, 0, "Create a new object", "p oModel(oGeno)", PROCEDURE(p_newfromgeno), }, 16 { "newWithCheckpoints", 0, 0, "Create a new object", "p oModel(x Geno object or string genotype)", PROCEDURE(p_newwithcheckpoints), "Creates a Model with the \"Checkpoints\" option enabled. Genotype converters supporting Checkpoints provide a sequence of Models that reflects development stages of the creature (this sequence is used purely for debugging and visualization of phenotype growth/development). Checkpoint Models can be accessed using getCheckpoint(i) for i ranging from 0 to numcheckpoints1. Models created without the Checkpoint option and Models coming from unsupported converters have numcheckpoints=0." }, 16 17 17 { "numparts", 0, PARAM_DONTSAVE  PARAM_NOSTATIC  PARAM_READONLY, " number of parts", "d", GETONLY(numparts), },18 { "numjoints", 0, PARAM_DONTSAVE  PARAM_NOSTATIC  PARAM_READONLY, " number of joints", "d", GETONLY(numjoints), },19 { "numneurons", 0, PARAM_DONTSAVE  PARAM_NOSTATIC  PARAM_READONLY, " number of neurons", "d", GETONLY(numneurons), },20 { "numconnections", 0, PARAM_DONTSAVE  PARAM_NOSTATIC  PARAM_READONLY, " number of neuron connections", "d", GETONLY(numconnections), },18 { "numparts", 0, PARAM_DONTSAVE  PARAM_NOSTATIC  PARAM_READONLY, "Number of parts", "d", GETONLY(numparts), }, 19 { "numjoints", 0, PARAM_DONTSAVE  PARAM_NOSTATIC  PARAM_READONLY, "Number of joints", "d", GETONLY(numjoints), }, 20 { "numneurons", 0, PARAM_DONTSAVE  PARAM_NOSTATIC  PARAM_READONLY, "Number of neurons", "d", GETONLY(numneurons), }, 21 { "numconnections", 0, PARAM_DONTSAVE  PARAM_NOSTATIC  PARAM_READONLY, "Number of neuron connections", "d", GETONLY(numconnections), }, 21 22 22 23 { "getPart", 0, PARAM_USERHIDDEN  PARAM_NOSTATIC, "getPart (static model information)", "p oPart(d index)", PROCEDURE(p_getpart), }, … … 24 25 { "getNeuroDef", 0, PARAM_USERHIDDEN  PARAM_NOSTATIC, "getNeuroDef", "p oNeuroDef(d index)", PROCEDURE(p_getneuro), }, 25 26 26 { "size_x", 0, PARAM_READONLY  PARAM_NOSTATIC  PARAM_DEPRECATED, " bounding box x size", "f", FIELD(size.x), "(size_x,size_y,size_z) are dimensions of the axisaligned bounding box of the creature, including imaginary Part sizes (Part.s, usually 1.0). A creature consisting of a single default part has the size of (2.0,2.0,2.0)  twice the Part.s value (like a sphere diameter is twice its radius).\nSee also: Creature.moveAbs" },27 { "size_y", 0, PARAM_READONLY  PARAM_NOSTATIC  PARAM_DEPRECATED, " bounding box y size", "f", FIELD(size.y), "See Model.size_x" },28 { "size_z", 0, PARAM_READONLY  PARAM_NOSTATIC  PARAM_DEPRECATED, " bounding box z size", "f", FIELD(size.z), "See Model.size_x" },27 { "size_x", 0, PARAM_READONLY  PARAM_NOSTATIC  PARAM_DEPRECATED, "Bounding box x size", "f", FIELD(size.x), "(size_x,size_y,size_z) are dimensions of the axisaligned bounding box of the creature, including imaginary Part sizes (Part.s, usually 1.0). A creature consisting of a single default part has the size of (2.0,2.0,2.0)  twice the Part.s value (like a sphere diameter is twice its radius).\nSee also: Creature.moveAbs" }, 28 { "size_y", 0, PARAM_READONLY  PARAM_NOSTATIC  PARAM_DEPRECATED, "Bounding box y size", "f", FIELD(size.y), "See Model.size_x" }, 29 { "size_z", 0, PARAM_READONLY  PARAM_NOSTATIC  PARAM_DEPRECATED, "Bounding box z size", "f", FIELD(size.z), "See Model.size_x" }, 29 30 { "bboxSize", 0, PARAM_READONLY  PARAM_NOSTATIC, "Bounding box size", "oXYZ", GETONLY(bboxsize) }, 31 { "numcheckpoints", 0, PARAM_DONTSAVE  PARAM_READONLY  PARAM_NOSTATIC, "Number of checkpoints", "d", GETONLY(numcheckpoints) }, 32 { "getCheckpoint", 0, PARAM_USERHIDDEN  PARAM_NOSTATIC, "getCheckpoint", "p oModel(d index)", PROCEDURE(p_getcheckpoint), 33 "Checkpoint Model objects are only valid as long as the parent Model object exists.\n" 34 "See also: Model.newWithCheckpoints()\n\n" 35 "// incorrect usage  calling getCheckpoint() on a temporary object:\n" 36 "var c=Model.newWithCheckpoints(\"XXX\").getCheckpoint(1).genotype.geno;\n\n" 37 "// correct usage  keeping the parent Model reference in 'm':\n" 38 "var m=Model.newWithCheckpoints(\"XXX\");\n" 39 "var c=m.getCheckpoint(1).genotype.geno;\n" 40 }, 41 { "shape_type", 0, PARAM_DONTSAVE  PARAM_NOSTATIC  PARAM_READONLY, "Shape type", "d 0 3 ~Unknown~Illegal~Ballandstick~Solids", GETONLY(shape_type) }, 42 { "solid_model", 0, PARAM_DONTSAVE  PARAM_NOSTATIC  PARAM_READONLY, "Solid shapes model", "oModel", GETONLY(solid_model), "Conversion of this Model to solid shapes. Note! Only available when this Model has shape_type==2 (Ballandstick)." }, 30 43 31 44 { 0, 0, 0, }, … … 57 70 } 58 71 72 void ModelObj::p_newwithcheckpoints(ExtValue *args, ExtValue *ret) 73 { 74 Model *m = NULL; 75 if (args[0].getType() == TString) 76 m = new Model(Geno(args[0].getString()), false, true); 77 else 78 { 79 Geno *g = GenoObj::fromObject(args[0].getObject(), false); 80 if (g) 81 m = new Model(*g, false, true); 82 else 83 logPrintf("Model", "newWithCheckpoints", LOG_ERROR, "Geno or string expected, %s found", args[0].typeDescription().c_str()); 84 } 85 86 if (m != NULL) 87 *ret = makeDynamicObject(m); 88 else 89 ret>setEmpty(); 90 } 91 59 92 Param& ModelObj::getStaticParam() 60 93 { 61 94 #ifdef __CODEGUARD__ 62 95 static ModelObj static_modelobj; 63 static Param static_modelparam(modelobj_paramtab, &static_modelobj);96 static Param static_modelparam(modelobj_paramtab, &static_modelobj); 64 97 #else 65 98 static Param static_modelparam(modelobj_paramtab); … … 131 164 *ret = Pt3D_Ext::makeDynamicObject(new Pt3D_Ext(size)); 132 165 } 166 167 void ModelObj::p_getcheckpoint(PARAMPROCARGS) 168 { 169 int i = args>getInt(); 170 if ((i < 0)  (i >= getCheckpointCount())) 171 { 172 ret>setEmpty(); 173 return; 174 } 175 ret>setObject(makeStaticObject(getCheckpoint(i))); 176 } 177 178 void ModelObj::get_solid_model(ExtValue *ret) 179 { 180 if (getShapeType() != Model::SHAPE_BALL_AND_STICK) 181 ret>setEmpty(); 182 Model *m = new Model; 183 m>open(); 184 m>buildUsingSolidShapeTypes(*this); 185 m>close(); 186 *ret = makeDynamicObject(m); 187 } 188 189 void ModelObj::get_shape_type(ExtValue *ret) 190 { 191 ret>setInt(getShapeType()); 192 }
Note: See TracChangeset
for help on using the changeset viewer.