Changeset 726 for cpp/frams/model/modelparts.cpp
- Timestamp:
- 01/19/18 19:37:43 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/model/modelparts.cpp
r714 r726 193 193 Neuro::Neuro(double _state, double _inertia, double _force, double _sigmo) 194 194 :PartBase(getDefaultStyle()), state(_state) 195 #ifdef MODEL_V1_COMPATIBLE 196 ,inertia(_inertia),force(_force),sigmo(_sigmo) 197 #endif 198 { 199 #ifdef MODEL_V1_COMPATIBLE 200 olditems=0; 201 #endif 195 { 202 196 flags = 0; 203 197 myclass = 0; … … 217 211 parent = 0; part = 0; joint = 0; 218 212 parentcount = 0; 219 #ifdef MODEL_V1_COMPATIBLE220 olditems=0;221 #endif222 213 flags = 0; 223 214 part_refno = -1; joint_refno = -1; … … 227 218 Neuro::~Neuro() 228 219 { 229 #ifdef MODEL_V1_COMPATIBLE230 if (olditems) delete olditems;231 #endif232 220 int i; 233 221 for (i = 0; i < inputs.size(); i++) … … 281 269 { 282 270 refno = src.refno; 283 #ifdef MODEL_V1_COMPATIBLE284 neuro_refno=-1;285 conn_refno=-1;286 force=src.force;287 sigmo=src.sigmo;288 inertia=src.inertia;289 weight=src.weight;290 olditems=0;291 #endif292 271 state = src.state; 293 272 part_refno = -1; … … 567 546 #endif 568 547 } 569 570 /////// old items571 #ifdef MODEL_V1_COMPATIBLE572 void OldItems::buildlist()573 { // guaranteed to work only for old NN layouts574 // (neurons,neuro connections, old receptors and effectors)575 if (listok) return;576 // inputs can contain both neuroitem connections (details="") and direct neuron references (details="N")577 // in OldItems we create neuroitems freom direct references578 for(int i=0;i<neuro.getInputCount();i++)579 {580 float w;581 Neuro *n=neuro.getInput(i,w);582 if (n->isOldNeuron())583 {584 Neuro *ni=new Neuro();585 ni->setClassName("-");586 ni->weight=w;587 ni->neuro_refno=neuro.refno;588 ni->conn_refno=n->refno;589 items+=ni;590 syntitems+=ni;591 }592 else593 {594 items+=n;595 n->weight=w;596 }597 }598 SList outputs;599 neuro.findOutputs(outputs);600 FOREACH(Neuro*,n,outputs)601 {602 if (n->isNNConnection() || n->isOldNeuron())603 outputs-=n;604 }605 items+=outputs;606 listok=1;607 }608 609 void OldItems::freelist()610 {611 FOREACH(Neuro*,n,syntitems)612 delete n;613 syntitems.clear();614 items.clear();615 listok=0;616 }617 618 int OldItems::getItemCount()619 {620 buildlist();621 return items.size();622 }623 624 NeuroItem *OldItems::getNeuroItem(int i)625 {626 buildlist();627 return (NeuroItem*)items(i);628 }629 630 NeuroItem *OldItems::addNewNeuroItem()631 {632 Neuro *nu=neuro.getModel().addNewNeuro();633 nu->setClassName("-");634 if (listok) items+=nu;635 neuro.addInput(nu);636 return (NeuroItem*)nu;637 }638 639 int OldItems::findNeuroItem(NeuroItem *ni)640 {641 buildlist();642 return items.find((void*)ni);643 }644 #endif645 548 646 549 /////////////////////////////////////// … … 801 704 } 802 705 803 804 706 ///////////////////////////////////////////////////////////////// 805 /////////////////////////////////////////////////////////////////806 707 807 708 #include F0_CLASSES_FILE 808 809 #ifdef MODEL_V1_COMPATIBLE810 811 #define FIELDSTRUCT Neuro812 ParamEntry f0_old_neuro_tab[]=813 {814 {"Connections",2,6,"n",},815 {"Other properties",},816 {"p",0,0,"part ref#","d",FIELD(part_refno),},817 {"j",0,0,"joint ref#","d",FIELD(joint_refno),},818 {"s",1,0,"state","f",FIELD(state),},819 {"in",1,0,"Inertia","f",FIELD(inertia),},820 {"fo",1,0,"Force","f",FIELD(force),},821 {"si",1,0,"Sigmoid","f",FIELD(sigmo),},822 {0,0,0,},823 };824 #undef FIELDSTRUCT825 826 #define FIELDSTRUCT NeuroItem827 ParamEntry f0_neuroitem_paramtab[]=828 {829 {"Connections",3,12,"ni",},830 {"Geometry",},831 {"Other",},832 {"n",0,0,"neuron ref#","d",FIELD(neuro_refno),},833 {"c",2,0,"connection ref#","d",FIELD(conn_refno),},834 {"w",2,0,"connection weight","f",FIELD(weight),},835 {"p",0,0,"part ref#","d",FIELD(part_refno),},836 {"j",0,0,"joint ref#","d",FIELD(joint_refno),},837 {"px",1,0,"position.x","f",FIELD(pos.x),},838 {"py",1,0,"position.y","f",FIELD(pos.y),},839 {"pz",1,0,"position.z","f",FIELD(pos.z),},840 {"rx",1,0,"rotation.x","f",FIELD(rot.x),},841 {"ry",1,0,"rotation.y","f",FIELD(rot.y),},842 {"rz",1,0,"rotation.z","f",FIELD(rot.z),},843 {"d",2,0,"item details","s",GETSET(details),},844 {0,0,0,},845 };846 #undef FIELDSTRUCT847 #endif848 709 849 710 ////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.