Changeset 1056


Ignore:
Timestamp:
12/28/20 02:06:52 (3 years ago)
Author:
Maciej Komosinski
Message:

Cosmetic

Location:
cpp
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • cpp/README.txt

    r1022 r1056  
    3838      +- vm            - virtual machine programming: FramScript grammar (lex and yacc/bison)
    3939          +- classes   - C++ interfaces and implementations of basic FramScript objects
     40
     41
     42______________________ Source formatting guidelines _____________________
     43
     44File names: all letters are lower case, with '-' as word separator if needed.
     45Indents: tab
     46Scopes
     47{
     48        ClassName variable_lower_case;
     49        variable_lower_case.camelCaseMathodOrFunction();
     50}
  • cpp/frams/genetics/fS/fS_general.cpp

    r1032 r1056  
    1212#include "../genooperators.h"
    1313#include "common/nonstd_math.h"
    14 #include "../../model/geometry/part_distance_estimator.h"
     14#include <frams/model/geometry/part_distance_estimator.h>
    1515
    1616int fS_Genotype::precision = 4;
     
    482482        Pt3D scale;
    483483        calculateScale(scale);
    484         return GeometryUtils::isSolidPartScaleValid(partShape, scale);
     484        return GeometryUtils::isSolidPartScaleValid(partShape, scale, true); //2020-12: mac->JS: I set the last argument to true because this is how the original code worked, but I think it should be ensureCircleSection?
    485485}
    486486
     
    910910        Part *parentTmpPart = PartDistanceEstimator::buildTemporaryPart(parent->partShape, parentScale, parent->getRotation());
    911911
    912         double result;
    913912        tmpPart->p = state->v;
    914         result = PartDistanceEstimator::calculateDistance(*tmpPart, *parentTmpPart, genotypeParams.distanceTolerance, genotypeParams.relativeDensity);
    915 
     913        double result = PartDistanceEstimator::calculateDistance(*tmpPart, *parentTmpPart, genotypeParams.distanceTolerance, genotypeParams.relativeDensity);
    916914
    917915        delete tmpPart;
  • cpp/frams/genetics/fS/fS_oper.cpp

    r1032 r1056  
    339339        {
    340340                geno.getState(false);
    341                 mutateScaleParam(newNode, SCALE_X, true);
     341                mutateScaleParam(newNode, SCALE_X, true); //TODO 2020-12: mac->JS: should be true or rather ensureCircleSection?
    342342                mutateScaleParam(newNode, SCALE_Y, true);
    343343                mutateScaleParam(newNode, SCALE_Z, true);
  • cpp/frams/genetics/fS/fS_oper.h

    r1030 r1056  
    142142
    143143        /**
    144          * Change the value of the scale parameter by given multiplier
    145          * Do not change the value if any of the scale restrictions is not satisfied
     144         * Change the value of the scale parameter by a given multiplier.
     145         * Do not change the value if any of the scale restrictions is not satisfied.
    146146         * @param paramKey
    147147         * @param multiplier
    148148         * @param ensureCircleSection
    149          * @return True if the parameter value was change, false otherwise
     149         * @return True if the parameter value was changed, false otherwise
    150150         */
    151151        bool mutateScaleParam(Node *node, string key, bool ensureCircleSection);
  • cpp/frams/model/geometry/geometryutils.cpp

    r1045 r1056  
    369369}
    370370
    371 double GeometryUtils::calculateSolidVolume(Part * part)
     371double GeometryUtils::calculateSolidVolume(const Part * part)
    372372{
    373373        double radiiProduct = part->scale.x * part->scale.y * part->scale.z;
     
    386386}
    387387
    388 bool GeometryUtils::isSolidPartScaleValid(const Part::Shape &partShape, const Pt3D &scale)
     388bool GeometryUtils::isSolidPartScaleValid(const Part::Shape &partShape, const Pt3D &scale, bool ensureCircleSection)
    389389{
    390390        Part *tmpPart = new Part(partShape);
     
    402402                return false;
    403403
    404         if (partShape == Part::Shape::SHAPE_ELLIPSOID && scale.maxComponentValue() != scale.minComponentValue()) // When any radius has a different value than the others
    405                 return false;
    406         if (partShape == Part::Shape::SHAPE_CYLINDER && scale.y != scale.z) // If base radii have different values
    407                 return false;
     404        if (ensureCircleSection)
     405        {
     406                if (partShape == Part::Shape::SHAPE_ELLIPSOID && scale.maxComponentValue() != scale.minComponentValue()) // Any radius has a different value than the other ones?
     407                        return false;
     408                if (partShape == Part::Shape::SHAPE_CYLINDER && scale.y != scale.z) // Base radii have different values?
     409                        return false;
     410        }
    408411        return true;
    409412}
  • cpp/frams/model/geometry/geometryutils.h

    r1045 r1056  
    178178        double ellipsePerimeter(const double a, const double b);
    179179
    180         double calculateSolidVolume(Part *part);
    181         bool isSolidPartScaleValid(const Part::Shape &partShape, const Pt3D &scale);
     180        double calculateSolidVolume(const Part *part);
     181        bool isSolidPartScaleValid(const Part::Shape &partShape, const Pt3D &scale, bool ensureCircleSection);
    182182
    183183    /**
  • cpp/frams/model/geometry/part_distance_estimator.h

    r1032 r1056  
    77
    88#include "frams/model/geometry/meshbuilder.h"
     9#include <cmath>
    910
    1011class PartDistanceEstimator
     
    5455        static double calculateDistance(Part tmpPart1, Part tmpPart2, double distanceTolerance, double relativeDensity)
    5556        {
    56                 /// tmpPart1 and tmpPart2 are copied for purpose and should not be passed as reference
    57                 /// This function can change some of the properties of those parts
     57                /// tmpPart1 and tmpPart2 are copied for purpose and should not be passed as reference.
     58                /// This function can change some of the properties of those parts.
    5859                /// tmpPart1 will be approximated by surface points.
    59                 /// The collision between the parts is detected when any of those points is inside tmpPart2
    60                 /// If tmpPart1 and tmpPart2 are swapped, the calculated distance may slightly differ
     60                /// The collision between the parts is detected when any of these points is inside tmpPart2.
     61                /// If tmpPart1 and tmpPart2 are swapped, the calculated distance may slightly differ.
    6162                Pt3D directionVersor = tmpPart1.p - tmpPart2.p;
    6263                directionVersor.normalize();
Note: See TracChangeset for help on using the changeset viewer.