[64] | 1 | // This file is a part of the Framsticks GDK library.
|
---|
| 2 | // Copyright (C) 2002-2011 Szymon Ulatowski. See LICENSE.txt for details.
|
---|
| 3 | // Refer to http://www.framsticks.com/ for further information.
|
---|
| 4 |
|
---|
| 5 | #ifndef _MODELPARTS_H_
|
---|
| 6 | #define _MODELPARTS_H_
|
---|
| 7 |
|
---|
| 8 | #include "3d.h"
|
---|
| 9 | #include "genoconv.h"
|
---|
| 10 |
|
---|
| 11 | #include "extvalue.h"
|
---|
| 12 | #include "list.h"
|
---|
| 13 | #include "sstring.h"
|
---|
| 14 | #include "sstringutils.h"
|
---|
| 15 | #include "param.h"
|
---|
| 16 | #include "syntparam.h"
|
---|
| 17 | #include "usertags.h"
|
---|
| 18 | #include "paramtabobj.h"
|
---|
| 19 |
|
---|
| 20 | #include <stdio.h>
|
---|
| 21 |
|
---|
| 22 | //#define MODEL_V1_COMPATIBLE
|
---|
| 23 |
|
---|
| 24 | class Model;
|
---|
| 25 | class IRange;
|
---|
| 26 | class MultiRange;
|
---|
| 27 |
|
---|
| 28 | typedef UserTags<Model,void*,5> ModelUserTags;
|
---|
| 29 |
|
---|
| 30 | /** Common base for model elements. */
|
---|
| 31 | class PartBase
|
---|
| 32 | {
|
---|
| 33 | public:
|
---|
| 34 | SString vis_style;
|
---|
| 35 | PartBase(const SString& s):vis_style(s),mapped(0) {}
|
---|
| 36 | ~PartBase();
|
---|
| 37 | static const SString& getDefaultStyle(){static SString s("none"); return s;}
|
---|
| 38 | MultiRange *mapped;
|
---|
| 39 | enum PartBaseFlags { Selected=1 };
|
---|
| 40 | long flags;
|
---|
| 41 | Model *owner; ///< backlink to the model
|
---|
| 42 |
|
---|
| 43 | SString info;
|
---|
| 44 |
|
---|
| 45 | Model &getModel() const {return *owner;}
|
---|
| 46 |
|
---|
| 47 | ModelUserTags userdata;
|
---|
| 48 |
|
---|
| 49 | void notifyMappingChange();
|
---|
| 50 |
|
---|
| 51 | void clearMapping();
|
---|
| 52 | MultiRange* getMapping() {return mapped;}
|
---|
| 53 | void setMapping(const IRange &mr);
|
---|
| 54 | void addMapping(const IRange &mr);
|
---|
| 55 | void setMapping(const MultiRange &mr);
|
---|
| 56 | void addMapping(const MultiRange &mr);
|
---|
| 57 |
|
---|
| 58 | void setInfo(const SString& name,const SString& value);
|
---|
| 59 | void setInfo(const SString& name,int value);
|
---|
| 60 | void setInfo(const SString& name,double value);
|
---|
| 61 | SString getInfo(const SString& name);
|
---|
| 62 | };
|
---|
| 63 |
|
---|
| 64 | /// Part is the only real physical object in the framsticks creature.
|
---|
| 65 | /// You can use this class for querying and adjusting constructed
|
---|
| 66 | /// model properties
|
---|
| 67 | class Part: public PartBase
|
---|
| 68 | {
|
---|
| 69 | friend class Model;
|
---|
| 70 | static const SString& getDefaultStyle();
|
---|
| 71 | Part(double _mass,double _size,double _density,double _friction,double _ingest,double _assim)
|
---|
| 72 | :mass(_mass),size(_size),density(_density),friction(_friction),ingest(_ingest),assim(_assim),
|
---|
| 73 | PartBase(getDefaultStyle())
|
---|
| 74 | {}
|
---|
| 75 | public:
|
---|
| 76 | // base properties - have special meaning and therefore are often accessed directly for convenience
|
---|
| 77 | Pt3D p; ///< 3d coordinates of the part
|
---|
| 78 | Orient o; ///< orientation in 3d space (rotation matrix)
|
---|
| 79 | /// ParamInterface object is preferred way to get/set other properties.
|
---|
| 80 | ParamInterface &extraProperties();
|
---|
| 81 | ParamInterface &properties();
|
---|
| 82 | long refno;
|
---|
| 83 | Pt3D rot;
|
---|
| 84 |
|
---|
| 85 | ///
|
---|
| 86 | double mass,size,density,friction,ingest,assim;
|
---|
| 87 | Pt3D food;
|
---|
| 88 | //SList points; // collistion points
|
---|
| 89 | //Slist neurons; // "select * from owner->neurons where part=this" ;-)
|
---|
| 90 |
|
---|
| 91 | Part();
|
---|
| 92 | Part(const Part& src):PartBase(getDefaultStyle()) {operator=(src);}
|
---|
| 93 | void operator=(const Part& src);
|
---|
| 94 | };
|
---|
| 95 |
|
---|
| 96 | /// Imaginary connection between two parts.
|
---|
| 97 | /// Joint has no mass nor intertia but can transfer forces.
|
---|
| 98 | class Joint: public PartBase
|
---|
| 99 | {
|
---|
| 100 | friend class Model;
|
---|
| 101 | static const SString& getDefaultStyle();
|
---|
| 102 | Joint(double _stamina,double _stif,double _rotstif,double _d)
|
---|
| 103 | :stamina(_stamina),stif(_stif),rotstif(_rotstif),PartBase(getDefaultStyle())
|
---|
| 104 | {d=Pt3D(_d,0,0);}
|
---|
| 105 | public:
|
---|
| 106 | // base properties:
|
---|
| 107 | long p1_refno,p2_refno; ///< parts' reference numbers
|
---|
| 108 |
|
---|
| 109 | Part *part1,*part2; ///< references to parts
|
---|
| 110 | class Pt3D d; ///< position delta between parts
|
---|
| 111 | class Pt3D rot; ///< orientation delta between parts expressed as 3 angles
|
---|
| 112 |
|
---|
| 113 | Joint();
|
---|
| 114 | Joint(const Joint& src):PartBase(getDefaultStyle()) {operator=(src);}
|
---|
| 115 | void operator=(const Joint& src);
|
---|
| 116 |
|
---|
| 117 | /** connect two parts with this joint.
|
---|
| 118 | p2 position will be adjusted if delta option is in effect.
|
---|
| 119 | @see isDelta()
|
---|
| 120 | */
|
---|
| 121 | void attachToParts(Part* p1,Part* p2);
|
---|
| 122 | /// @see attachToParts(Part*,Part*)
|
---|
| 123 | void attachToParts(int p1,int p2);
|
---|
| 124 |
|
---|
| 125 | /** discard delta information but don't disable delta flag.
|
---|
| 126 | delta will be calculated from parts positions during final consistency check.
|
---|
| 127 | */
|
---|
| 128 | void resetDelta();
|
---|
| 129 |
|
---|
| 130 | /** enable or disable delta option.
|
---|
| 131 | delta value is not changed.
|
---|
| 132 | */
|
---|
| 133 | void useDelta(int false_or_true);
|
---|
| 134 |
|
---|
| 135 | /** @return 1 if delta option is in effect.
|
---|
| 136 | @see useDelta(), resetDelta(), useDelta()
|
---|
| 137 | */
|
---|
| 138 | int isDelta();
|
---|
| 139 |
|
---|
| 140 | /// ParamInterface object is preferred way to get/set other properties.
|
---|
| 141 | ParamInterface &extraProperties();
|
---|
| 142 | ParamInterface &properties();
|
---|
| 143 |
|
---|
| 144 | // do not touch these:
|
---|
| 145 | long refno; ///< this joint's reference number
|
---|
| 146 | double stamina;
|
---|
| 147 | double stif,rotstif; ///< stiffness for moving and bending forces
|
---|
| 148 | class Orient o; ///< orientation delta between parts as rotation matrix
|
---|
| 149 | /** flag: generated f0 should include delta data.
|
---|
| 150 | set by 'singlestep' if j: attributes use delta option */
|
---|
| 151 | int usedelta;
|
---|
| 152 | };
|
---|
| 153 |
|
---|
| 154 | #define JOINT_DELTA_MARKER 99999.0
|
---|
| 155 |
|
---|
| 156 | ////////////////// NN /////////////////
|
---|
| 157 |
|
---|
| 158 | class NeuroClass;
|
---|
| 159 |
|
---|
| 160 | typedef UserTags<NeuroClass,void*,5> NeuroClassUserTags;
|
---|
| 161 |
|
---|
| 162 | /** Information about neuron class.
|
---|
| 163 | */
|
---|
| 164 | class NeuroClass
|
---|
| 165 | {
|
---|
| 166 | bool ownedvectordata;
|
---|
| 167 | void operator=(const NeuroClass& nosuchthich){}
|
---|
| 168 | public:
|
---|
| 169 | SString name,longname,description;
|
---|
| 170 | ParamEntry *props;
|
---|
| 171 | long prefinputs,prefoutput;
|
---|
| 172 | long preflocation;
|
---|
| 173 | int *vectordata;
|
---|
| 174 | long visualhints;
|
---|
| 175 |
|
---|
| 176 | void *impl;
|
---|
| 177 | bool active;
|
---|
| 178 | int genactive;
|
---|
| 179 | NeuroClassUserTags userdata;
|
---|
| 180 |
|
---|
| 181 | //////////////////////
|
---|
| 182 | ~NeuroClass();
|
---|
| 183 | NeuroClass();
|
---|
| 184 | NeuroClass(ParamEntry *_props,SString _description,
|
---|
| 185 | int _prefinputs,int _prefoutput,int _preflocation,int *_vectordata,bool own_vd=1,int vhints=0);
|
---|
| 186 | /** class name for use in Neuro::setClassName(), Neuro::setDetails() (former 'moredata' field),
|
---|
| 187 | eg. "N","-",G" */
|
---|
| 188 | const SString& getName() {return name;}
|
---|
| 189 | /** human friendly name, eg. "Neuron","Link","Gyroscope" */
|
---|
| 190 | const SString& getLongName() {return longname;}
|
---|
| 191 | /** long description */
|
---|
| 192 | const SString& getDescription() {return description;}
|
---|
| 193 | ParamEntry* getParamTab() {return props;}
|
---|
| 194 |
|
---|
| 195 | /** NeuroClass specific properties, recognized by all neurons of this class */
|
---|
| 196 | Param getProperties() {return Param(props);}
|
---|
| 197 |
|
---|
| 198 | /** preferred number of inputs, -1 = no preference (any number will go).
|
---|
| 199 | extra inputs may be ignored by the object (depends on the class).
|
---|
| 200 | */
|
---|
| 201 | int getPreferredInputs() {return prefinputs;}
|
---|
| 202 |
|
---|
| 203 | /** @return 0 if this object doesn't provide useful output signal. */
|
---|
| 204 | int getPreferredOutput() {return prefoutput;}
|
---|
| 205 |
|
---|
| 206 | /** @return 0 if the object doesn't need any assignment to the body element.
|
---|
| 207 | @return 1 = it likes to be attached to the Part ( @see Neuro::attachToPart() )
|
---|
| 208 | @return 2 = the object prefers to have the Joint ( @see Neuro::attachToJoint() )
|
---|
| 209 | */
|
---|
| 210 | int getPreferredLocation() {return preflocation;}
|
---|
| 211 | /** vector drawing to be used in neuro net diagram.
|
---|
| 212 | interpretation:
|
---|
| 213 | {
|
---|
| 214 | LEN = datalength (excluding this number)
|
---|
| 215 | NL = number_of_lines
|
---|
| 216 | line#1 -> NS = number_of_segments, x1,y1, x2,y2, ... xNS-1,yNS-1,
|
---|
| 217 | ...
|
---|
| 218 | line#NL -> NS = number_of_segments, x1,y1, x2,y2, ... xNS-1,yNS-1,
|
---|
| 219 | }
|
---|
| 220 | */
|
---|
| 221 | int* getSymbolGlyph()
|
---|
| 222 | {return vectordata;}
|
---|
| 223 | void setSymbolGlyph(int *data,bool owned=1)
|
---|
| 224 | {if (vectordata&&ownedvectordata) delete []vectordata;
|
---|
| 225 | vectordata=data; ownedvectordata=owned;}
|
---|
| 226 | /** additional information about how the neuron should be drawn
|
---|
| 227 | used by structure view (and maybe some other components).
|
---|
| 228 | return value is defined by the enum Hint
|
---|
| 229 | @see enum Hint
|
---|
| 230 | */
|
---|
| 231 | int getVisualHints()
|
---|
| 232 | {return visualhints;}
|
---|
| 233 |
|
---|
| 234 | enum Hint
|
---|
| 235 | /** don't draw neurons of this class */
|
---|
| 236 | { Invisible=1,
|
---|
| 237 | /** don't draw classname label below the neuron */
|
---|
| 238 | DontShowClass=2,
|
---|
| 239 | /** draw the neuron at the first part when attached to joint (default is in the middle) */
|
---|
| 240 | AtFirstPart=4,
|
---|
| 241 | /** draw the neuron at the second part when attached to joint (default is in the middle) */
|
---|
| 242 | AtSecondPart=8,
|
---|
| 243 | /** use effector colour for this neuro unit */
|
---|
| 244 | EffectorClass=16,
|
---|
| 245 | /** use receptor colour for this neuro unit */
|
---|
| 246 | ReceptorClass=32,
|
---|
| 247 | V1BendMuscle=64,
|
---|
| 248 | V1RotMuscle=128,
|
---|
| 249 | };
|
---|
| 250 |
|
---|
| 251 | /** textual summary, automatically generated from other properties (like the neuro class tooltip) */
|
---|
| 252 | SString getSummary();
|
---|
| 253 | };
|
---|
| 254 |
|
---|
| 255 | class Neuro;
|
---|
| 256 |
|
---|
| 257 | #ifdef MODEL_V1_COMPATIBLE
|
---|
| 258 | class NeuroItem;
|
---|
| 259 |
|
---|
| 260 | /** for compatibility with old Neuro/NeuroItem */
|
---|
| 261 | class OldItems
|
---|
| 262 | {
|
---|
| 263 | Neuro &neuro;
|
---|
| 264 | SList syntitems; ///< to be deleted
|
---|
| 265 | SList items;
|
---|
| 266 | int listok;
|
---|
| 267 | public:
|
---|
| 268 | OldItems(Neuro &n):neuro(n),listok(0) {}
|
---|
| 269 | ~OldItems() {freelist();}
|
---|
| 270 | void buildlist();
|
---|
| 271 | void freelist();
|
---|
| 272 |
|
---|
| 273 | int getItemCount();
|
---|
| 274 | NeuroItem *getNeuroItem(int i);
|
---|
| 275 | NeuroItem *addNewNeuroItem();
|
---|
| 276 | int findNeuroItem(NeuroItem *n);
|
---|
| 277 | };
|
---|
| 278 | #endif
|
---|
| 279 |
|
---|
| 280 | /** Single processing unit in framsticks NN. */
|
---|
| 281 | class Neuro: public PartBase
|
---|
| 282 | {
|
---|
| 283 | friend class Model;
|
---|
| 284 | static const SString& getDefaultStyle();
|
---|
| 285 |
|
---|
| 286 | struct NInput { Neuro *n; double weight; SString *info;
|
---|
| 287 | NInput(Neuro *_n,double w,SString *i=0):n(_n),weight(w),info(i) {} };
|
---|
| 288 |
|
---|
| 289 | SListTempl<NInput> inputs;
|
---|
| 290 |
|
---|
| 291 | NeuroClass *myclass;
|
---|
| 292 | bool knownclass;
|
---|
| 293 | SString myclassname, myclassparams;
|
---|
| 294 | /** set myclass and make knownclass=true */
|
---|
| 295 | void checkClass();
|
---|
| 296 |
|
---|
| 297 | SString** inputInfo(int i);
|
---|
| 298 |
|
---|
| 299 | public:
|
---|
| 300 | enum NeuroFlags { HoldState=2 };
|
---|
| 301 | ParamInterface &properties();
|
---|
| 302 | ParamInterface &extraProperties();
|
---|
| 303 |
|
---|
| 304 | void setInputInfo(int i,const SString& name,const SString &value);
|
---|
| 305 | void setInputInfo(int i,const SString& name,int value);
|
---|
| 306 | void setInputInfo(int i,const SString& name,double value);
|
---|
| 307 | SString getInputInfo(int i);
|
---|
| 308 | SString getInputInfo(int i,const SString& name);
|
---|
| 309 |
|
---|
| 310 | NeuroClass* getClass();
|
---|
| 311 | void setClass(NeuroClass*);
|
---|
| 312 |
|
---|
| 313 | SString getClassParams() {return myclassparams;}
|
---|
| 314 | void setClassParams(const SString& cp) {myclassparams=cp;}
|
---|
| 315 |
|
---|
| 316 | SString getClassName();
|
---|
| 317 | void setClassName(const SString& clazz);
|
---|
| 318 |
|
---|
| 319 | /** return neuro unit details encoded as <CLASS> ":" <PROPERTIES>
|
---|
| 320 |
|
---|
| 321 | new Neuro can be created as root object (without parent) or can be
|
---|
| 322 | the child of existing Neuro. Children of the Neuro are its inputs.
|
---|
| 323 | Standard framsticks neuron calculates the sum of all input units - other processing
|
---|
| 324 | units don't have to treat them equally and can even ignore some of them.
|
---|
| 325 | There are hints about expected inputs in the class database, @see getClass
|
---|
| 326 |
|
---|
| 327 | Application should not assume anything about classes and its properties
|
---|
| 328 | except for two standard classes: (information about all current classes
|
---|
| 329 | can be retrieved with getClass/getClassProperties methods)
|
---|
| 330 | - getClassName()="N" is the standard framsticks neuron, accepts any number of inputs,
|
---|
| 331 | compatible with old Neuro object
|
---|
| 332 | - getClassName()="-" is the neuron link, compatible with old Neuro-Neuro link
|
---|
| 333 | (NeuroItem with empty details)
|
---|
| 334 | Empty details defaults to "-" if the parent unit is specified,
|
---|
| 335 | and "N" if the unit has no parent.
|
---|
| 336 | */
|
---|
| 337 | SString getDetails();
|
---|
| 338 |
|
---|
| 339 | /** details = classname + ":" + classparams
|
---|
| 340 | @see getDetails()
|
---|
| 341 | */
|
---|
| 342 | void setDetails(const SString&);
|
---|
| 343 |
|
---|
| 344 | #define STATRICKCLASS Neuro
|
---|
| 345 | PARAMGETDEF(details) {arg1->setString(getDetails());}
|
---|
| 346 | PARAMSETDEF(details) {setDetails(arg1->getString());return PSET_CHANGED;}
|
---|
| 347 | PARAMGETDEF(inputCount);
|
---|
| 348 | PARAMPROCDEF(p_getInputNeuroDef);
|
---|
| 349 | PARAMPROCDEF(p_getInputNeuroIndex);
|
---|
| 350 | PARAMPROCDEF(p_getInputWeight);
|
---|
| 351 | PARAMGETDEF(classObject);
|
---|
| 352 | #undef STATRICKCLASS
|
---|
| 353 |
|
---|
| 354 | SyntParam classProperties();
|
---|
| 355 | // base properties:
|
---|
| 356 | long refno; ///< unique reference number (former 'neuro' refno)
|
---|
| 357 |
|
---|
| 358 | long part_refno; ///< can be used by some items as the part ref#
|
---|
| 359 | long joint_refno; ///< can be used by some items as the joint ref#
|
---|
| 360 |
|
---|
| 361 | Pt3D pos,rot; ///< default = zero
|
---|
| 362 |
|
---|
| 363 | ModelUserTags userdata;
|
---|
| 364 |
|
---|
| 365 | Neuro();
|
---|
| 366 | Neuro(double _state,double _inertia,double _force,double _sigmo);
|
---|
| 367 | Neuro(const Neuro& src):PartBase(getDefaultStyle()) {operator=(src);}
|
---|
| 368 |
|
---|
| 369 | ~Neuro();
|
---|
| 370 |
|
---|
| 371 | void operator=(const Neuro& src);
|
---|
| 372 |
|
---|
| 373 | /** Attach this Neuro to the specified Part or detach it from the body if p==NULL.
|
---|
| 374 | Neuro can be attached to either Part or Joint, but not both.
|
---|
| 375 | @see getPart()
|
---|
| 376 | */
|
---|
| 377 | void attachToPart(Part* p) {part=p; joint=0;}
|
---|
| 378 |
|
---|
| 379 | /** Attach this Neuro to the specified Joint or detach it from the body if p==NULL.
|
---|
| 380 | Neuro can be attached to either Part or Joint, but not both.
|
---|
| 381 | @see getJoint()
|
---|
| 382 | */
|
---|
| 383 | void attachToJoint(Joint* j) {joint=j; part=0;}
|
---|
| 384 |
|
---|
| 385 | void attachToPart(int i);
|
---|
| 386 | void attachToJoint(int i);
|
---|
| 387 |
|
---|
| 388 | /** @return Part the Neuro is attached to, or NULL if it has no defined location on the body.
|
---|
| 389 | @see attachToPart()
|
---|
| 390 | */
|
---|
| 391 | Part *getPart() {return part;}
|
---|
| 392 |
|
---|
| 393 | /** @return Joint the Neuro is attached to, or NULL if it has no defined location on the body.
|
---|
| 394 | @see attachToJoint()
|
---|
| 395 | */
|
---|
| 396 | Joint *getJoint() {return joint;}
|
---|
| 397 |
|
---|
| 398 | int isOldEffector();
|
---|
| 399 | int isOldReceptor();
|
---|
| 400 | int isOldNeuron();
|
---|
| 401 | int isNNConnection();
|
---|
| 402 |
|
---|
| 403 | /** @return the number of inputs connected to this Neuro.
|
---|
| 404 | Functions like getInput(), getInputWeight() will accept connection number [0..InputCount-1]
|
---|
| 405 | */
|
---|
| 406 | int getInputCount() const {return inputs.size();}
|
---|
| 407 |
|
---|
| 408 | /// @return the number of output connections (including possible self-connections)
|
---|
| 409 | int getOutputsCount() const;
|
---|
| 410 |
|
---|
| 411 | /** @return the Neuro connected as i-th input */
|
---|
| 412 | Neuro* getInput(int i) const {return (i>=inputs.size())?0:inputs(i).n;}
|
---|
| 413 | /** @return the Neuro connected as i-th input.
|
---|
| 414 | @param weight
|
---|
| 415 | */
|
---|
| 416 | Neuro* getInput(int i,float &weight) const;
|
---|
| 417 | /** @return connectin weight for i-th input */
|
---|
| 418 | float getInputWeight(int i) const;
|
---|
| 419 | /** change connection weight for i-th input */
|
---|
| 420 | void setInputWeight(int i,float weight);
|
---|
| 421 | /** connect i-th input with another neuron */
|
---|
| 422 | void setInput(int i,Neuro*n);
|
---|
| 423 | /** connect i-th input with another neuron */
|
---|
| 424 | void setInput(int i,Neuro*n,float weight);
|
---|
| 425 | /** add new input. @return its reference number */
|
---|
| 426 | int addInput(Neuro* child,float weight=1.0,const SString* info=0);
|
---|
| 427 | /** @return reference number [0..InputCount-1] of the input
|
---|
| 428 | or -1 if 'child' is not connected with this Neuro.*/
|
---|
| 429 | int findInput(Neuro* child) const;
|
---|
| 430 | void removeInput(int refno);
|
---|
| 431 | /** @return reference number of the child connection, like findInput() */
|
---|
| 432 | int removeInput(Neuro* child);
|
---|
| 433 |
|
---|
| 434 | int findInputs(SList& result,const char* classname=0,const Part* part=0,const Joint* joint=0) const;
|
---|
| 435 | int findOutputs(SList& result,const char* classname=0,const Part* part=0,const Joint* joint=0) const;
|
---|
| 436 |
|
---|
| 437 | /* class database retrieval */
|
---|
| 438 | static int getClassCount();
|
---|
| 439 | /** @return Neuro class name.
|
---|
| 440 | @param classindex 0 .. getClassCount()
|
---|
| 441 | */
|
---|
| 442 | static SString getClassName(int classindex);
|
---|
| 443 | static NeuroClass* getClass(int classindex);
|
---|
| 444 | static NeuroClass* getClass(const SString& classname);
|
---|
| 445 | static int getClassIndex(const NeuroClass*nc);
|
---|
| 446 |
|
---|
| 447 | #ifdef MODEL_V1_COMPATIBLE
|
---|
| 448 | friend class OldItems;
|
---|
| 449 | long neuro_refno; ///< parent ref# (called neuro_refno for compatibility with old Neuro class), @see moredata
|
---|
| 450 | long conn_refno; ///< the other neuron ref# in N-N connections, can be used by some other items
|
---|
| 451 | double weight; ///< weight of the N-N connection and (all?) receptors
|
---|
| 452 | double inertia,force,sigmo; //!!!
|
---|
| 453 |
|
---|
| 454 | /** @deprecated provided only for compatibility with old Neuro/NeuroItem classes.
|
---|
| 455 | use getInputCount() instead. @sa getInputCount() */
|
---|
| 456 | int getItemCount() {return oldItems().getItemCount();}
|
---|
| 457 |
|
---|
| 458 | /** @deprecated provided only for compatibility with old Neuro/NeuroItem classes.
|
---|
| 459 | use getInput() instead. @sa getInput() */
|
---|
| 460 | NeuroItem* getNeuroItem(int i) {return oldItems().getNeuroItem(i);}
|
---|
| 461 | #endif
|
---|
| 462 |
|
---|
| 463 | protected:
|
---|
| 464 | #ifdef MODEL_V1_COMPATIBLE
|
---|
| 465 | /** old Neuro compatibility */
|
---|
| 466 | OldItems* olditems;
|
---|
| 467 | OldItems& oldItems() {if (!olditems) olditems=new OldItems(*this); return *olditems;}
|
---|
| 468 | void invalidateOldItems() {if (olditems) olditems->freelist();}
|
---|
| 469 | #endif
|
---|
| 470 |
|
---|
| 471 | public:
|
---|
| 472 |
|
---|
| 473 | // not really private, but you should not access those directly
|
---|
| 474 | double state;
|
---|
| 475 |
|
---|
| 476 | /** may reference parent neuron if parentcount is exacty 1. parent is invalid otherwise. @sa parentcount */
|
---|
| 477 | Neuro *parent;
|
---|
| 478 | int parentcount; ///< @sa parent
|
---|
| 479 |
|
---|
| 480 | Part *part; ///< link to the Part
|
---|
| 481 | Joint *joint; ///< link to the Joint - required by some objects (eg.muscles)
|
---|
| 482 | Orient o; ///< rotation matrix calculated from "rot"
|
---|
| 483 | static ParamEntry emptyParamTab[];
|
---|
| 484 | };
|
---|
| 485 |
|
---|
| 486 | #ifdef MODEL_V1_COMPATIBLE
|
---|
| 487 | class NeuroItem;
|
---|
| 488 |
|
---|
| 489 | /// for compatibility with old NeuroItem class.
|
---|
| 490 | class NeuroItem: public Neuro
|
---|
| 491 | {
|
---|
| 492 | public:
|
---|
| 493 | NeuroItem() {}
|
---|
| 494 | };
|
---|
| 495 | #endif
|
---|
| 496 |
|
---|
| 497 | class NeuroExt: public Neuro
|
---|
| 498 | {
|
---|
| 499 | public:
|
---|
| 500 | #define STATRICKCLASS NeuroExt
|
---|
| 501 | PARAMGETDEF(neuroclass);
|
---|
| 502 | PARAMSETDEF(neuroclass);
|
---|
| 503 | #undef STATRICKCLASS
|
---|
| 504 | static ParamEntry *getParamTab();
|
---|
| 505 | };
|
---|
| 506 |
|
---|
| 507 | class NeuroConn
|
---|
| 508 | {
|
---|
| 509 | public:
|
---|
| 510 | int n1_refno,n2_refno;
|
---|
| 511 | double weight;
|
---|
| 512 | SString info;
|
---|
| 513 | NeuroConn();
|
---|
| 514 | };
|
---|
| 515 |
|
---|
| 516 | extern ParamEntry f0_part_paramtab[],f0_joint_paramtab[],f0_nodeltajoint_paramtab[],f0_neuro_paramtab[],f0_neuroconn_paramtab[],f0_neuroitem_paramtab[];
|
---|
| 517 | extern Param st_neuroparam,st_jointparam,st_partparam;
|
---|
| 518 |
|
---|
| 519 | #endif
|
---|