Changeset 139


Ignore:
Timestamp:
02/20/14 17:49:28 (10 years ago)
Author:
sz
Message:

class renaming + minor corrections

Location:
cpp/frams
Files:
12 edited

Legend:

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

    r138 r139  
    2626        gm.p_report(NULL, NULL);
    2727
    28         const char* src = (argc > 1) ? argv[1] : "/*9*/RRR";
     28        const char* src = (argc > 1) ? argv[1] : "/*9*/UUU";
    2929        Geno gsrc(src, -1, "First");
    3030        printGenAndTitle(gsrc, "source genotype (gsrc)");
     
    4242        printGenAndTitle(ginvalid, "invalid");
    4343
    44         Geno fixed = gm.Validate(ginvalid);
    45         printGenAndTitle(fixed, "validated");
     44        Geno gvalidated = gm.Validate(ginvalid);
     45        printGenAndTitle(gvalidated, "validated");
    4646
    47         printf("\nHTMLized: %s\n", (const char*)gm.HTMLize((const char*)fixed.getGene()));
     47        printf("\nHTMLized: %s\n", (const char*)gm.HTMLize((const char*)gvalidated.getGene()));
    4848
    4949        return 0;
  • cpp/frams/_demos/part_shapes.cpp

    r121 r139  
    99int main()
    1010{
    11 Model *m=new Model;
    12 Part *p1,*p2;
    13 Joint *j;
     11        Model m;
     12        Part *p1, *p2;
     13        Joint *j;
    1414
    15 m->open();
     15        m.open();
    1616
    17 // chain of ellipsoids - subsequent parts are placed relative to the previous part's orientation and location
    18 p1=m->addNewPart(Part::SHAPE_ELLIPSOID); //initial part
    19 p1->scale=Pt3D(1.0,0.7,0.4);
     17        // chain of ellipsoids - subsequent parts are placed relative to the previous part's orientation and location
     18        p1 = m.addNewPart(Part::SHAPE_ELLIPSOID); //initial part
     19        p1->scale = Pt3D(1.0, 0.7, 0.4);
    2020
    21 Orient rotation=Orient_1; //must be initialized explicitly because the default Orient constructor does not initialize anything
    22 rotation.rotate(Pt3D(0.1,0.2,0.3));
     21        Orient rotation = Orient_1; //must be initialized explicitly because the default Orient constructor does not initialize anything
     22        rotation.rotate(Pt3D(0.1, 0.2, 0.3));
    2323
    24 for(int N=10;N>0;N--,p1=p2)
     24        for (int N = 10; N > 0; N--, p1 = p2)
    2525        {
    26         p2=m->addNewPart(Part::SHAPE_ELLIPSOID);
    27         p2->scale=p1->scale*0.9; //each part is smaller than its predecessor
    28        
    29         Pt3D advance(p1->scale.x,0,0); //advance by previous part's ellipsoid x radius
    30         p2->p = p1->p + p1->o.transform(advance); //advance vector transformed by p1 orientation == in p1 local coordinates
    31         p2->setOrient(p1->o.transform(rotation)); //rotation transformed by p1 orientation
     26                p2 = m.addNewPart(Part::SHAPE_ELLIPSOID);
     27                p2->scale = p1->scale*0.9; //each part is smaller than its predecessor
    3228
    33         m->addNewJoint(p1,p2,Joint::SHAPE_SOLID); //all parts must be connected
     29                Pt3D advance(p1->scale.x, 0, 0); //advance by previous part's ellipsoid x radius
     30                p2->p = p1->p + p1->o.transform(advance); //advance vector transformed by p1's orientation (i.e., in p1's local coordinates)
     31                p2->setOrient(p1->o.transform(rotation)); //rotation transformed by p1's orientation
     32
     33                m.addNewJoint(p1, p2, Joint::SHAPE_SOLID); //all parts must be connected
    3434        }
    3535
    36 // chain of cyllinders - line segments between points calculated from the parametric formula P(a)=(2-2*cos(a),2*sin(a)) (circle with r=2)
    37 Pt3D prev,next;
    38 p1=m->getPart(0);
    39 for(float a=0;a<M_PI;a+=M_PI/10)
     36        // chain of cyllinders - line segments between points calculated from the parametric formula P(a)=(2-2*cos(a),2*sin(a)) (circle with r=2)
     37        Pt3D prev, next;
     38        p1 = m.getPart(0);
     39        for (float a = 0; a<M_PI; a += M_PI / 10)
    4040        {
    41         Pt3D next(2-2*cos(a),0,2*sin(a));
    42         if (a>0)
     41                Pt3D next(2 - 2 * cos(a), 0, 2 * sin(a));
     42                if (a>0)
    4343                {
    44                 p2=m->addNewPart(Part::SHAPE_CYLINDER);
    45                 p2->setPositionAndRotationFromAxis(prev,next);
    46                 p2->scale=Pt3D(prev.distanceTo(next)*0.5,0.05,0.05);// distance*0.5 because scale is "radius", not cylinder length
     44                        p2 = m.addNewPart(Part::SHAPE_CYLINDER);
     45                        p2->setPositionAndRotationFromAxis(prev, next);
     46                        p2->scale = Pt3D(prev.distanceTo(next)*0.5, 0.05, 0.05);// distance*0.5 because scale is "radius", not cylinder length
    4747
    48                 m->addNewJoint(p1,p2,Joint::SHAPE_SOLID); //all parts must be connected
     48                        m.addNewJoint(p1, p2, Joint::SHAPE_SOLID); //all parts must be connected
    4949                }
    50         p1=p2;
    51         prev=next;
     50                p1 = p2;
     51                prev = next;
    5252        }
    5353
    54 m->close();
    55 puts((const char*)m->getF0Geno().toString());
    56 // the genotype can be fed directly to the genotype viewer, like this:
    57 // part_shapes | theater -g -vpart_shapes -
     54        m.close();
     55        puts((const char*)m.getF0Geno().toString());
     56        // the genotype can be fed directly to the genotype viewer, like this:
     57        // part_shapes | theater -g -vpart_shapes -
    5858}
  • cpp/frams/genetics/defgenoconv.cpp

    r121 r139  
    77#include GEN_CONFIG_FILE
    88
    9 #ifdef USE_GENCONV_F10
     9#ifdef USE_GENCONV_f10
    1010#include "f1/conv_f1.h"
    1111#endif
    12 #ifdef USE_GENCONV_F20
     12#ifdef USE_GENCONV_f20
    1313#include "f2/conv_f2.h"
    1414#endif
    15 #ifdef USE_GENCONV_F32
     15#ifdef USE_GENCONV_f32
    1616#include "f3/conv_f3.h"
    1717#endif
    18 #ifdef USE_GENCONV_F40
     18#ifdef USE_GENCONV_f40
    1919#include "f4/conv_f4.h"
    2020#endif
    21 #ifdef USE_GENCONV_F41_TEST
     21#ifdef USE_GENCONV_f41_TEST
    2222#include "f4/conv_f4.h"
    2323#endif
    24 #ifdef USE_GENCONV_F50
     24#ifdef USE_GENCONV_f50
    2525#include "f5/conv_f5.h"
    2626#endif
    27 #ifdef USE_GENCONV_F60
     27#ifdef USE_GENCONV_f60
    2828#include "f6/geno_f6.h"
    2929#endif
    30 #ifdef USE_GENCONV_F70
     30#ifdef USE_GENCONV_f70
    3131#include "f7/conv_f7.h"
    3232#endif
    33 #ifdef USE_GENCONV_F81
     33#ifdef USE_GENCONV_f81
    3434#include "f8/conv_f8tof1.h"
    3535#endif
    36 #ifdef USE_GENCONV_F90
     36#ifdef USE_GENCONV_f90
    3737#include "f9/conv_f9.h"
     38#endif
     39#ifdef USE_GENCONV_fF0
     40#include "fF/conv_fF.h"
    3841#endif
    3942
    4043DefaultGenoConvManager::DefaultGenoConvManager()
    4144{
    42 #ifdef USE_GENCONV_F10
    43 addConverter(new GenoConv_F1());
     45#ifdef USE_GENCONV_f10
     46        addConverter(new GenoConv_f1());
    4447#endif
    45 #ifdef USE_GENCONV_F20
    46 addConverter(new GenoConv_F20());
     48#ifdef USE_GENCONV_f20
     49        addConverter(new GenoConv_f20());
    4750#endif
    48 #ifdef USE_GENCONV_F32
    49 addConverter(new GenoConv_F32());
     51#ifdef USE_GENCONV_f32
     52        addConverter(new GenoConv_f32());
    5053#endif
    51 #ifdef USE_GENCONV_F40
    52 addConverter(new GenoConv_F40());
     54#ifdef USE_GENCONV_f40
     55        addConverter(new GenoConv_f40());
    5356#endif
    54 #ifdef USE_GENCONV_F41_TEST
    55 addConverter(new GenoConv_F41_TestOnly());
     57#ifdef USE_GENCONV_f41_TEST
     58        addConverter(new GenoConv_f41_TestOnly());
    5659#endif
    57 #ifdef USE_GENCONV_F50
    58 addConverter(new GenoConv_F50);
     60#ifdef USE_GENCONV_f50
     61        addConverter(new GenoConv_f50);
    5962#endif
    60 #ifdef USE_GENCONV_F60
    61 addConverter(new GenoConv_F60);
     63#ifdef USE_GENCONV_f60
     64        addConverter(new GenoConv_f60);
    6265#endif
    63 #ifdef USE_GENCONV_F70
    64 addConverter(new GenoConv_F70);
     66#ifdef USE_GENCONV_f70
     67        addConverter(new GenoConv_f70);
    6568#endif
    66 #ifdef USE_GENCONV_F81
    67 addConverter(new GenoConv_F8ToF1());
     69#ifdef USE_GENCONV_f81
     70        addConverter(new GenoConv_f8ToF1());
    6871#endif
    69 #ifdef USE_GENCONV_F90
    70 addConverter(new GenoConv_F90);
     72#ifdef USE_GENCONV_f90
     73        addConverter(new GenoConv_f90);
     74#endif
     75#ifdef USE_GENCONV_fF0
     76        addConverter(new GenoConv_fF0);
    7177#endif
    7278
    73 param.updatetab();
     79        param.updatetab();
    7480}
  • cpp/frams/genetics/f1/conv_f1.cpp

    r121 r139  
    100100
    101101/** main conversion function - with conversion map support */
    102 SString GenoConv_F1::convert(SString &i,MultiMap *map)
     102SString GenoConv_f1::convert(SString &i,MultiMap *map)
    103103{
    104104const char* g=(const char*)i;
  • cpp/frams/genetics/f1/conv_f1.h

    r121 r139  
    6060 
    6161*/
    62 class GenoConv_F1: public GenoConverter
     62class GenoConv_f1: public GenoConverter
    6363{
    6464public:
    65 GenoConv_F1()
     65GenoConv_f1()
    6666        {
    6767        name="Recursive encoding";
     
    7070        }
    7171SString convert(SString &i,MultiMap *map);
    72 ~GenoConv_F1() {}
     72~GenoConv_f1() {}
    7373};
    7474
  • cpp/frams/genetics/f9/conv_f9.cpp

    r125 r139  
    1010#define APPLY_DETERMINISTIC_BODY_NOISE //this representation easily produces perfectly vertical sticks that would stay upright forever. In most cases such infinite perfection is not desired, so we make the construct less perfect by perturbing its coordinates.
    1111
    12 GenoConv_F90::GenoConv_F90()
     12GenoConv_f90::GenoConv_f90()
    1313{
    1414        name = "Turtle3D-ortho encoding";
     
    2525//const char* turtle_commandsZ_f9="0000-+";
    2626
    27 SString GenoConv_F90::convert(SString &in, MultiMap *map)
     27SString GenoConv_f90::convert(SString &in, MultiMap *map)
    2828{
    2929        vector<XYZ_LOC> vertices;
     
    5555}
    5656
    57 int GenoConv_F90::addSegment(Model &m,vector<XYZ_LOC> &vertices,const XYZ_LOC &new_vertex,int recently_added)
     57int GenoConv_f90::addSegment(Model &m,vector<XYZ_LOC> &vertices,const XYZ_LOC &new_vertex,int recently_added)
    5858{
    5959        if (vertices.size()<1)
     
    7777}
    7878
    79 int GenoConv_F90::findVertexAt(vector<XYZ_LOC> &vertices,const XYZ_LOC &vertex)
     79int GenoConv_f90::findVertexAt(vector<XYZ_LOC> &vertices,const XYZ_LOC &vertex)
    8080{
    8181        for(int i=0;i<vertices.size();i++)
     
    8585
    8686
    87 int GenoConv_F90::addNewVertex(Model &m,vector<XYZ_LOC> &vertices,const XYZ_LOC &new_vertex)
     87int GenoConv_f90::addNewVertex(Model &m,vector<XYZ_LOC> &vertices,const XYZ_LOC &new_vertex)
    8888{
    8989        Part *p=new Part;
     
    110110}
    111111
    112 void GenoConv_F90::setColors(Model &m) //sets fixed (independent from genes) colors and widths on a model, purely for aesthetic purposes
     112void GenoConv_f90::setColors(Model &m) //sets fixed (independent from genes) colors and widths on a model, purely for aesthetic purposes
    113113{
    114114        //a rainbow on Joints: from the first one red, through middle green, to blue or violet - last
     
    145145}
    146146
    147 void GenoConv_F90::perturbPartLocations(Model &m) //deterministic "body noise", see APPLY_DETERMINISTIC_BODY_NOISE
     147void GenoConv_f90::perturbPartLocations(Model &m) //deterministic "body noise", see APPLY_DETERMINISTIC_BODY_NOISE
    148148{
    149149        for(int i=0;i<m.getPartCount();i++)
  • cpp/frams/genetics/f9/conv_f9.h

    r125 r139  
    2929
    3030// The f9->f0 converter
    31 class GenoConv_F90: public GenoConverter
     31class GenoConv_f90: public GenoConverter
    3232{
    3333public:
    34         GenoConv_F90();
     34        GenoConv_f90();
    3535
    36         //implementation GenoConverter method
     36        //implementation of the GenoConverter method
    3737        SString convert(SString &in, MultiMap *map);
    3838
  • cpp/frams/genetics/f9/oper_f9.h

    r120 r139  
    1818        int crossOver(char *&g1,char *&g2,float& chg1,float& chg2);
    1919        unsigned long style(const char *g, int pos);
    20         char* getSimplest() {return "R";}
     20        const char* getSimplest() {return "R";}
    2121
    2222        double mut_prob; //mutation probability
  • cpp/frams/genetics/gen-config-GDK.h

    r138 r139  
    1212 */
    1313
    14 #define USE_GENCONV_F10
    15 //#define USE_GENCONV_F21
    16 //#define USE_GENCONV_F30
    17 //#define USE_GENCONV_F40
    18 //#define USE_GENCONV_F41_TEST
    19 //#define USE_GENCONV_F50
    20 #define USE_GENCONV_F90
     14#define USE_GENCONV_f10
     15//#define USE_GENCONV_f21
     16//#define USE_GENCONV_f30
     17//#define USE_GENCONV_f40
     18//#define USE_GENCONV_f41_TEST
     19//#define USE_GENCONV_f50
     20#define USE_GENCONV_f90
    2121
    22 //#define USE_GENMAN_F0
    23 //#define USE_GENMAN_F1
    24 //#define USE_GENMAN_F2
    25 //#define USE_GENMAN_F3
    26 //#define USE_GENMAN_F4
    27 //#define USE_GENMAN_F5
    28 #define USE_GENMAN_F9
     22//#define USE_GENMAN_f0
     23//#define USE_GENMAN_f1
     24//#define USE_GENMAN_f2
     25//#define USE_GENMAN_f3
     26//#define USE_GENMAN_f4
     27//#define USE_GENMAN_f5
     28#define USE_GENMAN_f9
  • cpp/frams/genetics/genman.cpp

    r138 r139  
    1111
    1212
    13 #ifdef USE_GENMAN_F0
     13#ifdef USE_GENMAN_f0
    1414#include "f0/oper_f0.h"
    1515#endif
    16 #ifdef USE_GENMAN_F0FUZZY
     16#ifdef USE_GENMAN_f0FUZZY
    1717#include "f0/oper_f0Fuzzy.h"
    1818#endif
    19 #ifdef USE_GENMAN_F1
     19#ifdef USE_GENMAN_f1
    2020#include "f1/oper_f1.h"
    2121#endif
    22 #ifdef USE_GENMAN_F2
     22#ifdef USE_GENMAN_f2
    2323#include "f2/oper_f2.h"
    2424#endif
    25 #ifdef USE_GENMAN_F2
     25#ifdef USE_GENMAN_f2
    2626#include "f3/oper_f3.h"
    2727#endif
    28 #ifdef USE_GENMAN_F4
     28#ifdef USE_GENMAN_f4
    2929#include "f4/oper_f4.h"
    3030#endif
    31 #ifdef USE_GENMAN_F5
     31#ifdef USE_GENMAN_f5
    3232#include "f5/oper_f5.h"
    3333#endif
    34 #ifdef USE_GENMAN_F6
     34#ifdef USE_GENMAN_f6
    3535#include "f6/oper_f6.h"
    3636#endif
    37 #ifdef USE_GENMAN_F7
     37#ifdef USE_GENMAN_f7
    3838#include "f7/oper_f7.h"
    3939#endif
    40 #ifdef USE_GENMAN_F8
     40#ifdef USE_GENMAN_f8
    4141#include "f8/oper_f8.h"
    4242#endif
    43 #ifdef USE_GENMAN_F9
     43#ifdef USE_GENMAN_f9
    4444#include "f9/oper_f9.h"
     45#endif
     46#ifdef USE_GENMAN_fF
     47#include "fF/oper_fF.h"
    4548#endif
    4649
     
    101104        clearStats();
    102105
    103 #ifdef USE_GENMAN_F0
     106#ifdef USE_GENMAN_f0
    104107        geno_fx_list.push_back(new Geno_f0);
    105108#endif
    106 #ifdef USE_GENMAN_F0FUZZY
     109#ifdef USE_GENMAN_f0FUZZY
    107110        geno_fx_list.push_back(new Geno_f0Fuzzy);
    108111#endif
    109 #ifdef USE_GENMAN_F1
     112#ifdef USE_GENMAN_f1
    110113        geno_fx_list.push_back(new Geno_f1);
    111114#endif
    112 #ifdef USE_GENMAN_F2
     115#ifdef USE_GENMAN_f2
    113116        geno_fx_list.push_back(new Geno_f2);
    114117#endif
    115 #ifdef USE_GENMAN_F3
     118#ifdef USE_GENMAN_f3
    116119        geno_fx_list.push_back(new Geno_f3);
    117120#endif
    118 #ifdef USE_GENMAN_F4
     121#ifdef USE_GENMAN_f4
    119122        geno_fx_list.push_back(new Geno_f4);
    120123#endif
    121 #ifdef USE_GENMAN_F5
     124#ifdef USE_GENMAN_f5
    122125        geno_fx_list.push_back(new Geno_f5);
    123126#endif
    124 #ifdef USE_GENMAN_F6
     127#ifdef USE_GENMAN_f6
    125128        geno_fx_list.push_back(new Geno_f6);
    126129#endif
    127 #ifdef USE_GENMAN_F7
     130#ifdef USE_GENMAN_f7
    128131        geno_fx_list.push_back(new Geno_f7);
    129132#endif
    130 #ifdef USE_GENMAN_F8
     133#ifdef USE_GENMAN_f8
    131134        geno_fx_list.push_back(new Geno_f8);
    132135#endif
    133 #ifdef USE_GENMAN_F9
     136#ifdef USE_GENMAN_f9
    134137        geno_fx_list.push_back(new GenoOper_f9);
     138#endif
     139#ifdef USE_GENMAN_fF
     140        geno_fx_list.push_back(new GenoOper_fF);
    135141#endif
    136142
  • cpp/frams/genetics/oper_fx.h

    r121 r139  
    160160
    161161/**\return a pointer to the simplest genotype string*/
    162    virtual char* getSimplest() {return NULL;}
     162   virtual const char* getSimplest() {return NULL;}
    163163
    164164/**You may want to have your genotype colored. This method provides desired character styles for genes.
  • cpp/frams/util/3d.h

    r121 r139  
    6262void getAngles(const Pt3D& X,const Pt3D& dir);
    6363void vectorProduct(const Pt3D& a,const Pt3D& b);
     64Pt3D vectorProduct(const Pt3D& p) const {return (*this)*p;}
     65Pt3D entrywiseProduct(const Pt3D &p) const {return Pt3D(x*p.x,y*p.y,z*p.z);} ///< also known as Hadamard product or Schur product
     66double dotProduct(const Pt3D& p) const {return x*p.x+y*p.y+z*p.z;}
    6467bool normalize();
    6568};
Note: See TracChangeset for help on using the changeset viewer.