Changeset 256 for cpp/frams/genetics


Ignore:
Timestamp:
11/18/14 17:04:37 (9 years ago)
Author:
Maciej Komosinski
Message:

Chambers in Foraminifera now have the proper orientation in 3D; simplified source

Location:
cpp/frams/genetics/fF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/fF/conv_fF.cpp

    r197 r256  
    55#include "conv_fF.h"
    66#include "fF_genotype.h"
    7 #include <frams/model/model.h>
    87#include <common/nonstd_stl.h>
    98#include <common/Convert.h>
     
    2625}
    2726
     27Part *GenoConv_fF0::addNewPart(Model *m, const fF_chamber3d* c)
     28{
     29        Part *part = m->addNewPart(Part::SHAPE_ELLIPSOID);
     30        part->p = Pt3D(c->centerX, c->centerY, c->centerZ);
     31        Pt3D hole = Pt3D(c->holeX, c->holeY, c->holeZ);
     32        Orient o;
     33        o.lookAt(part->p - hole);
     34        part->setOrient(o);
     35        return part;
     36}
     37
    2838SString GenoConv_fF0::convert(SString &in, MultiMap *map)
    2939{
     
    4050        m.vis_style = "foram"; //dedicated visual look for Foraminifera
    4151
    42         // subsequent parts (chambers) are placed relative to the previous part's orientation and location
    43         Part *p1, *p2;
    44 
    4552        fF_chamber3d **chambers = new fF_chamber3d*[gp.number_of_chambers];
    46 
    4753        for (int i = 0; i < gp.number_of_chambers; i++)
    4854                createSphere(i, chambers, radius, div_radius_length, gp.translation, gp.angle1, gp.angle2, gp.scalex, gp.scaley, gp.scalez);
    4955
    50         p1 = m.addNewPart(Part::SHAPE_ELLIPSOID);
    51         p1->p = Pt3D(chambers[0]->centerX, chambers[0]->centerY, chambers[0]->centerZ);
    52 
    53 
    54         for (int i = 1; i < gp.number_of_chambers; i++, p1 = p2)
    55         {
    56                 p2 = m.addNewPart(Part::SHAPE_ELLIPSOID);
     56        Part *p1 = addNewPart(&m, chambers[0]);
     57        for (int i = 1; i < gp.number_of_chambers; i++)
     58        {
     59                Part *p2 = addNewPart(&m, chambers[i]);
    5760                p2->scale = p1->scale.entrywiseProduct(Pt3D(gp.scalex, gp.scaley, gp.scalez)); //each part's scale is its predecessor's scale * scaling
    58 
    59                 p2->p = Pt3D(chambers[i]->centerX, chambers[i]->centerY, chambers[i]->centerZ);
    60 
    6161                m.addNewJoint(p1, p2, Joint::SHAPE_SOLID); //all parts must be connected
     62                p1 = p2;
    6263        }
    6364
    6465        for (int i = 0; i < gp.number_of_chambers; i++)
    6566                delete chambers[i];
    66         delete[]chambers;
     67        delete[] chambers;
    6768
    6869        m.close();
     
    8788                if (radius < fF_TOO_LITTLE) {
    8889                        radius = fF_TOO_LITTLE;
    89                         if (fabs(len) >(fF_TOO_MUCH * radius)) {
     90                        if (fabs(len) > (fF_TOO_MUCH * radius)) {
    9091                                len = ((len < 0) ? (-1) : 1) * fF_TOO_MUCH * radius;
    9192                        }
  • cpp/frams/genetics/fF/conv_fF.h

    r197 r256  
    2222#include <frams/util/sstring.h>
    2323#include <frams/genetics/genoconv.h>
     24#include <frams/model/model.h>
    2425#include "fF_chamber3d.h"
    2526
     
    5354        double* sines;
    5455        void precompute_cos_and_sin();
     56        Part *addNewPart(Model *m, const fF_chamber3d* c);
    5557};
    5658
Note: See TracChangeset for help on using the changeset viewer.