Changeset 899 for cpp/frams/model/modelparts.h
- Timestamp:
- 11/30/19 02:13:25 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/model/modelparts.h
r844 r899 24 24 class MultiRange; 25 25 26 typedef UserTags<Model, void *, 5> ModelUserTags;26 typedef UserTags<Model, void *, 5> ModelUserTags; 27 27 28 28 /** Common base for model elements. */ … … 31 31 public: 32 32 SString vis_style; 33 PartBase(const SString &s) :vis_style(s), mapped(0) {}33 PartBase(const SString &s) :vis_style(s), mapped(0) {} 34 34 ~PartBase(); 35 static SString getDefaultStyle() { return SString("none"); }35 static SString getDefaultStyle() { return SString("none"); } 36 36 MultiRange *mapped; 37 37 enum PartBaseFlags { Selected = 1 }; … … 48 48 49 49 void clearMapping(); 50 MultiRange *getMapping() { return mapped; }50 MultiRange *getMapping() { return mapped; } 51 51 void setMapping(const IRange &mr); 52 52 void addMapping(const IRange &mr); … … 54 54 void addMapping(const MultiRange &mr); 55 55 56 void setInfo(const SString & name, const SString&value);57 void setInfo(const SString &name, int value);58 void setInfo(const SString &name, double value);59 SString getInfo(const SString &name);56 void setInfo(const SString &name, const SString &value); 57 void setInfo(const SString &name, int value); 58 void setInfo(const SString &name, double value); 59 SString getInfo(const SString &name); 60 60 }; 61 61 … … 94 94 95 95 Part(enum Shape s = SHAPE_BALL_AND_STICK); 96 Part(const Part &src) :PartBase(getDefaultStyle()) { operator=(src); }97 void operator=(const Part &src);96 Part(const Part &src) :PartBase(getDefaultStyle()) { operator=(src); } 97 void operator=(const Part &src); 98 98 99 99 void setPositionAndRotationFromAxis(const Pt3D &p1, const Pt3D &p2); … … 101 101 void setRot(const Pt3D &r);///< set part.rot (rotation angles) and calculate part.o 102 102 103 static Param &getStaticParam();103 static Param &getStaticParam(); 104 104 }; 105 105 … … 128 128 129 129 Joint(); 130 Joint(const Joint &src) :PartBase(getDefaultStyle()) { operator=(src); }131 void operator=(const Joint &src);130 Joint(const Joint &src) :PartBase(getDefaultStyle()) { operator=(src); } 131 void operator=(const Joint &src); 132 132 133 133 /** connect two parts with this joint. … … 135 135 @see isDelta() 136 136 */ 137 void attachToParts(Part * p1, Part*p2);137 void attachToParts(Part *p1, Part *p2); 138 138 /// @see attachToParts(Part*,Part*) 139 139 void attachToParts(int p1, int p2); … … 168 168 Pt3D vcolor; 169 169 170 static Param &getStaticParam();170 static Param &getStaticParam(); 171 171 }; 172 172 173 173 #define JOINT_DELTA_MARKER 99999.0 174 174 175 ////////////////// NN ///////////////// 175 176 177 ////////////////// Neural Network ///////////////// 176 178 177 179 class NeuroClass; 178 180 179 typedef UserTags<NeuroClass, void *, 5> NeuroClassUserTags;181 typedef UserTags<NeuroClass, void *, 5> NeuroClassUserTags; 180 182 181 183 /** Information about neuron class. … … 184 186 { 185 187 bool ownedvectordata; 186 void operator=(const NeuroClass & nosuchthich){}188 void operator=(const NeuroClass &nosuchthich) {} 187 189 public: 188 190 SString name, longname, description; … … 207 209 /** class name for use in Neuro::setClassName(), Neuro::setDetails() (former 'moredata' field), 208 210 eg. "N","-",G" */ 209 const SString &getName() { return name; }211 const SString &getName() { return name; } 210 212 /** human friendly name, eg. "Neuron","Link","Gyroscope" */ 211 const SString &getLongName() { return longname; }213 const SString &getLongName() { return longname; } 212 214 /** long description */ 213 const SString &getDescription() { return description; }214 ParamEntry *getParamTab() { return props; }215 const SString &getDescription() { return description; } 216 ParamEntry *getParamTab() { return props; } 215 217 216 218 /** NeuroClass specific properties, recognized by all neurons of this class */ … … 240 242 } 241 243 */ 242 int *getSymbolGlyph()244 int *getSymbolGlyph() 243 245 { 244 246 return vectordata; … … 246 248 void setSymbolGlyph(int *data, bool owned = 1) 247 249 { 248 if (vectordata &&ownedvectordata) delete[]vectordata;250 if (vectordata && ownedvectordata) delete[]vectordata; 249 251 vectordata = data; ownedvectordata = owned; 250 252 } … … 282 284 283 285 static void resetActive(); ///< set default values of active and genactive for all classes 284 static void setGenActive(const char* classes[]); ///< set genactive for specified classes 285 }; 286 287 class Neuro; 288 289 /** Single processing unit in Framsticks NN. */ 286 static void setGenActive(const char *classes[]); ///< set genactive for specified classes 287 }; 288 289 290 291 292 293 294 /** Single processing unit in Framsticks neural network. */ 290 295 class Neuro : public PartBase 291 296 { … … 305 310 /** set myclass and make knownclass=true */ 306 311 void checkClass(); 307 SString **inputInfo(int i);312 SString **inputInfo(int i); 308 313 void defassign(); 309 314 … … 313 318 Param extraProperties(); 314 319 315 void setInputInfo(int i, const SString &name, const SString &value);316 void setInputInfo(int i, const SString &name, int value);317 void setInputInfo(int i, const SString &name, double value);320 void setInputInfo(int i, const SString &name, const SString &value); 321 void setInputInfo(int i, const SString &name, int value); 322 void setInputInfo(int i, const SString &name, double value); 318 323 SString getInputInfo(int i); 319 SString getInputInfo(int i, const SString &name);320 321 NeuroClass *getClass();322 void setClass(NeuroClass *);324 SString getInputInfo(int i, const SString &name); 325 326 NeuroClass *getClass(); 327 void setClass(NeuroClass *); 323 328 324 329 SString getClassParams() { return myclassparams; } 325 void setClassParams(const SString &cp) { myclassparams = cp; }330 void setClassParams(const SString &cp) { myclassparams = cp; } 326 331 327 332 SString getClassName(); 328 void setClassName(const SString &clazz);333 void setClassName(const SString &clazz); 329 334 330 335 /** return neuro unit details encoded as <CLASS> ":" <PROPERTIES> … … 351 356 @see getDetails() 352 357 */ 353 void setDetails(const SString &);358 void setDetails(const SString &); 354 359 355 360 #define STATRICKCLASS Neuro … … 377 382 Neuro(); 378 383 Neuro(double _state, double _inertia, double _force, double _sigmo); 379 Neuro(const Neuro &src) :PartBase(getDefaultStyle()) { operator=(src); }384 Neuro(const Neuro &src) :PartBase(getDefaultStyle()) { operator=(src); } 380 385 381 386 ~Neuro(); 382 387 383 void operator=(const Neuro &src);388 void operator=(const Neuro &src); 384 389 385 390 /** Attach this Neuro to the specified Part or detach it from the body if p==NULL. … … 387 392 @see getPart() 388 393 */ 389 void attachToPart(Part *p) { part = p; joint = 0; }394 void attachToPart(Part *p) { part = p; joint = 0; } 390 395 391 396 /** Attach this Neuro to the specified Joint or detach it from the body if p==NULL. … … 393 398 @see getJoint() 394 399 */ 395 void attachToJoint(Joint *j) { joint = j; part = 0; }400 void attachToJoint(Joint *j) { joint = j; part = 0; } 396 401 397 402 void attachToPart(int i); … … 422 427 423 428 /** @return the Neuro connected as i-th input */ 424 Neuro *getInput(int i) const { return (i >= inputs.size()) ? 0 : inputs(i).n; }429 Neuro *getInput(int i) const { return (i >= inputs.size()) ? 0 : inputs(i).n; } 425 430 /** @return the Neuro connected as i-th input. 426 431 @param weight 427 432 */ 428 Neuro *getInput(int i, double &weight) const;433 Neuro *getInput(int i, double &weight) const; 429 434 /** @return connectin weight for i-th input */ 430 435 double getInputWeight(int i) const; … … 432 437 void setInputWeight(int i, double weight); 433 438 /** connect i-th input with another neuron */ 434 void setInput(int i, Neuro *n);439 void setInput(int i, Neuro *n); 435 440 /** connect i-th input with another neuron */ 436 void setInput(int i, Neuro *n, double weight);441 void setInput(int i, Neuro *n, double weight); 437 442 /** add new input. @return its reference number */ 438 int addInput(Neuro * child, double weight = 1.0, const SString*info = 0);443 int addInput(Neuro *child, double weight = 1.0, const SString *info = 0); 439 444 /** @return reference number [0..InputCount-1] of the input 440 445 or -1 if 'child' is not connected with this Neuro.*/ 441 int findInput(Neuro *child) const;446 int findInput(Neuro *child) const; 442 447 void removeInput(paInt refno); 443 448 /** @return reference number of the child connection, like findInput() */ 444 int removeInput(Neuro *child);445 446 int findInputs(SList & result, const char* classname = 0, const Part* part = 0, const Joint*joint = 0) const;447 int findOutputs(SList & result, const char* classname = 0, const Part* part = 0, const Joint*joint = 0) const;449 int removeInput(Neuro *child); 450 451 int findInputs(SList &result, const char *classname = 0, const Part *part = 0, const Joint *joint = 0) const; 452 int findOutputs(SList &result, const char *classname = 0, const Part *part = 0, const Joint *joint = 0) const; 448 453 449 454 /* class database retrieval */ … … 453 458 */ 454 459 static SString getClassName(int classindex); 455 static NeuroClass *getClass(int classindex);456 static NeuroClass * getClass(const SString&classname);457 static int getClassIndex(const NeuroClass *nc);460 static NeuroClass *getClass(int classindex); 461 static NeuroClass *getClass(const SString &classname); 462 static int getClassIndex(const NeuroClass *nc); 458 463 459 464 // not really private, but you should not access those directly … … 468 473 Orient o; ///< rotation matrix calculated from "rot" 469 474 static ParamEntry emptyParamTab[]; 470 static Param &getStaticParam();475 static Param &getStaticParam(); 471 476 }; 472 477
Note: See TracChangeset
for help on using the changeset viewer.