Ignore:
Timestamp:
06/22/23 03:52:39 (15 months ago)
Author:
Maciej Komosinski
Message:

f4: three #define's -> enum, minor refactorizations, added comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/f4/f4_conv.cpp

    r1249 r1259  
    153153f4_Cell* f4_Model::getStick(f4_Cell *C)
    154154{
    155         if (C->type == CELL_STICK) return C;
     155        if (C->type == f4_Cell_type::CELL_STICK) return C;
    156156        if (NULL != C->dadlink)
    157157                return getStick(C->dadlink);
    158158        // we have no more dadlinks, find any stick
    159159        for (int i = 0; i < cells->cell_count; i++)
    160                 if (cells->C[i]->type == CELL_STICK)
     160                if (cells->C[i]->type == f4_Cell_type::CELL_STICK)
    161161                        return cells->C[i];
    162162        // none!
     
    177177        // make sure parent is a stick
    178178        if (C->dadlink != NULL)
    179                 if (C->dadlink->type != CELL_STICK)
     179                if (C->dadlink->type != f4_Cell_type::CELL_STICK)
    180180                {
    181181                        C->dadlink = getStick(C->dadlink);
     
    192192        MultiRange range = C->genoRange;
    193193
    194         if (C->type == CELL_STICK)
     194        if (C->type == f4_Cell_type::CELL_STICK)
    195195        {
    196196                int jj_p1_refno;  // save for later
     
    244244        }
    245245
    246         if (C->type == CELL_NEURON)
     246        if (C->type == f4_Cell_type::CELL_NEURON)
    247247        {
    248248                const char* nclass = C->neuclass->name.c_str();
     
    253253                        else
    254254                                sprintf(tmpLine, "d=\"%s\"", nclass);
    255 
    256                         C->neuro_refno = addFromString(NeuronType, tmpLine, &range);
    257                         if (C->neuro_refno < 0) return -22;
    258                         this->checkpoint();
    259255                }
    260256                else if (C->neuclass->getPreferredLocation() == 1) // attached to Part or have no required attachment - also part
     
    264260
    265261                        sprintf(tmpLine, "p=%d,d=\"%s\"", partno, nclass);
    266 
    267                         C->neuro_refno = addFromString(NeuronType, tmpLine, &range);
    268                         if (C->neuro_refno < 0) return -22;
    269                         this->checkpoint();
    270262                }
    271263                else // attached to Joint, assume there are only three possibilities of getPreferredLocation()
     
    277269                        else if (strcmp(nclass, "|") == 0)
    278270                        {
    279                                 sprintf(tmpLine, "j=%d,d=\"|:p=%g,r=%g\"", jointno, C->P.muscle_power, C->dadlink->P.muscle_bend_range); //Macko 2023-05 change: we take muscle_bend_range from dadlink, not from C, because we also assign this neuron to C->dadlink->joint_refno. Without this, for example in /*4*/<<X><<<<X>N:|>X>X>X>X the muscle is attached to the junction with 3 sticks, but gets range=33% as in a four-stick junction. f1 correctly sets range=0.5 for the analogous phenotype: X(X[|],X(X,X,X))
     271                                sprintf(tmpLine, "j=%d,d=\"|:p=%g,r=%g\"", jointno, C->P.muscle_power, C->dadlink->P.muscle_bend_range); //Macko 2023-05 change: we take muscle_bend_range from dadlink, not from C, because we also assign this neuron to C->dadlink->joint_refno. Without this, for example in /*4*/<<X><<<<X>N:|>X>X>X>X the muscle is attached to the junction with 3 sticks, but gets range=33% as in a four-stick junction. f1 correctly sets range=0.5 (see also conv_f1_f0_branch_muscle_range) for the analogous phenotype: X(X[|],X(X,X,X))
    280272                        }
    281273                        else
    282274                                sprintf(tmpLine, "j=%d,d=\"%s\"", jointno, nclass);
    283 
    284                         C->neuro_refno = addFromString(NeuronType, tmpLine, &range);
    285                         if (C->neuro_refno < 0) return -32;
    286                         this->checkpoint();
    287                 }
     275                }
     276
     277                C->neuro_refno = addFromString(NeuronType, tmpLine, &range);
     278                if (C->neuro_refno < 0) return -22;
     279                this->checkpoint();
     280
    288281                for (int j = 0; j < C->conns_count; j++)
    289282                {
Note: See TracChangeset for help on using the changeset viewer.