Ignore:
Timestamp:
01/19/18 19:37:43 (6 years ago)
Author:
Maciej Komosinski
Message:
  • Changed Model::singleStepBuild() to Model::addFromString() to create model elements; the latter requires explicit indication of element type (P/J/N/C)
  • Removed old compatibility source (#ifdef MODEL_V1_COMPATIBLE) from f1->f0 converter and neuron definitions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/modelparts.cpp

    r714 r726  
    193193Neuro::Neuro(double _state, double _inertia, double _force, double _sigmo)
    194194        :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{
    202196        flags = 0;
    203197        myclass = 0;
     
    217211        parent = 0; part = 0; joint = 0;
    218212        parentcount = 0;
    219 #ifdef MODEL_V1_COMPATIBLE
    220         olditems=0;
    221 #endif
    222213        flags = 0;
    223214        part_refno = -1; joint_refno = -1;
     
    227218Neuro::~Neuro()
    228219{
    229 #ifdef MODEL_V1_COMPATIBLE
    230         if (olditems) delete olditems;
    231 #endif
    232220        int i;
    233221        for (i = 0; i < inputs.size(); i++)
     
    281269{
    282270        refno = src.refno;
    283 #ifdef MODEL_V1_COMPATIBLE
    284         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 #endif
    292271        state = src.state;
    293272        part_refno = -1;
     
    567546#endif
    568547}
    569 
    570 /////// old items
    571 #ifdef MODEL_V1_COMPATIBLE
    572 void OldItems::buildlist()
    573 { // guaranteed to work only for old NN layouts
    574         // (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 references
    578         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                 else
    593                 {
    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 #endif
    645548
    646549///////////////////////////////////////
     
    801704}
    802705
    803 
    804706/////////////////////////////////////////////////////////////////
    805 /////////////////////////////////////////////////////////////////
    806707
    807708#include F0_CLASSES_FILE
    808 
    809 #ifdef MODEL_V1_COMPATIBLE
    810 
    811 #define FIELDSTRUCT Neuro
    812 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 FIELDSTRUCT
    825 
    826 #define FIELDSTRUCT NeuroItem
    827 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 FIELDSTRUCT
    847 #endif
    848709
    849710////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.