Ignore:
Timestamp:
07/03/20 00:32:23 (4 years ago)
Author:
Maciej Komosinski
Message:
  • separate "0" and "0s" formats (for SHAPE_BALL_AND_STICK and SHAPE_SOLIDS, respectively)
  • converting to format list (Geno::F0_FORMAT_LIST = "0,0s")
  • (optional) declaring Model as SHAPE_BALL_AND_STICK or SHAPE_SOLIDS (or SHAPE_UNKNOWN)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/_demos/full_props.cpp

    r534 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2016  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    4747*/
    4848
    49 int main(int argc,char*argv[])
     49int main(int argc, char*argv[])
    5050{
    51 StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err
    52 LoggerToStdout messages_to_stderr(LoggerBase::Enable | LoggerBase::DontBlock,VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
     51        StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err
     52        LoggerToStdout messages_to_stderr(LoggerBase::Enable | LoggerBase::DontBlock, VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
    5353
    54 PreconfiguredGenetics genetics;
     54        PreconfiguredGenetics genetics;
    5555
    56 bool reverse=false;
    57 char* gen_arg=0;
    58 for(int i=1;i<argc;i++)
     56        bool reverse = false;
     57        char* gen_arg = 0;
     58        for (int i = 1; i < argc; i++)
    5959        {
    60         char* ar=argv[i];
    61         if (ar[0]=='-')
    62                 switch(ar[1])
     60                char* ar = argv[i];
     61                if (ar[0] == '-')
     62                        switch (ar[1])
    6363                        {
    64                         case 'r': reverse=true; break;
     64                        case 'r': reverse = true; break;
    6565                        case 'h': puts("usage: full_props [-r[everse]] [genotype_or_stdin]\n"); break;
    6666                        }
     67                else
     68                        if (!gen_arg)
     69                                gen_arg = ar;
     70        }
     71        SString gen;
     72        if (gen_arg)
     73                gen = gen_arg;
    6774        else
    68                 if (!gen_arg)
    69                         gen_arg=ar;
    70         }
    71 SString gen;
    72 if (gen_arg)
    73         gen=gen_arg;
    74 else
    75         loadSString(VirtFILE::Vstdin,gen);
    76 Geno g(gen);
    77 Model m(g);
     75                loadSString(VirtFILE::Vstdin, gen);
     76        Geno g(gen);
     77        Model m(g, Model::SHAPE_UNKNOWN);
    7878
    79 if (!m.isValid())
     79        if (!m.isValid())
    8080        {
    81         logPrintf("","full_props",LOG_ERROR,"Cannot build Model from the supplied genotype\n");
    82         return 2;       
     81                logPrintf("", "full_props", LOG_ERROR, "Cannot build Model from the supplied genotype\n");
     82                return 2;
    8383        }
    8484
    85 m.open();
    86 for(int i=0;i<m.getNeuroCount();i++)
     85        m.open();
     86        for (int i = 0; i < m.getNeuroCount(); i++)
    8787        {
    88         Neuro *n=m.getNeuro(i);
    89         SyntParam p=n->classProperties(reverse);
    90         p.update();// ...so everyone reading the source can recognize that p was created to update the neuro d field
    91         // but actually, calling update() here is not necessary, because ~SyntParam() would do it anyway
     88                Neuro *n = m.getNeuro(i);
     89                SyntParam p = n->classProperties(reverse);
     90                p.update();// ...so everyone reading the source can recognize that p was created to update the neuro d field
     91                // but actually, calling update() here is not necessary, because ~SyntParam() would do it anyway
    9292        }
    93 m.close();
     93        m.close();
    9494
    95 // normal f0 (omitting default values) would be retrieved using m.getF0Geno()
    96 // the following form allows for more control:
    97 Geno f0_g;
    98 m.makeGeno(f0_g,NULL,reverse);//third arg is "handle_defaults" == whether f0 should omit default property values
    99 puts(f0_g.getGenesAndFormat().c_str());
     95        // normal f0 (omitting default values) would be retrieved using m.getF0Geno()
     96        // the following form allows for more control:
     97        Geno f0_g;
     98        m.makeGeno(f0_g, NULL, reverse);//third arg is "handle_defaults" == whether f0 should omit default property values
     99        puts(f0_g.getGenesAndFormat().c_str());
    100100
    101 return 0;
     101        return 0;
    102102}
    103103
Note: See TracChangeset for help on using the changeset viewer.