Changeset 1023 for cpp


Ignore:
Timestamp:
08/05/20 14:24:31 (4 years ago)
Author:
Maciej Komosinski
Message:

Added GenoOperators::calculateSolidVolume(Part)

Location:
cpp/frams/genetics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/genooperators.cpp

    r968 r1023  
    455455        return isupper(firstchar) || firstchar == '|' || firstchar == '@' || firstchar == '*';
    456456}
     457
     458double GenoOperators::calculateSolidVolume(Part * part)
     459{
     460        double radiiProduct = part->scale.x * part->scale.y * part->scale.z;
     461        switch (part->shape)
     462        {
     463        case Part::Shape::SHAPE_CUBOID:
     464                return 8.0 * radiiProduct;
     465        case Part::Shape::SHAPE_CYLINDER:
     466                return  2.0 * M_PI * radiiProduct;
     467        case Part::Shape::SHAPE_ELLIPSOID:
     468                return  (4.0 / 3.0) * M_PI * radiiProduct;
     469        default:
     470                logMessage("GenoOperators", "calculateSolidVolume", LOG_ERROR, "Unsupported part shape");
     471                return -1;
     472        }
     473}
  • cpp/frams/genetics/genooperators.h

    r968 r1023  
    214214        static char* strchrn0(const char *str, char ch); ///<like strchr, but does not find zero char in \e str.
    215215        static bool canStartNeuroClassName(const char firstchar); ///<determines if \e firstchar may start NeuroClass name. If not, it might start NeuroClass' (or Neuro's) property name.
     216
     217        static double calculateSolidVolume(Part *part);
     218
    216219        //@}
    217220};
Note: See TracChangeset for help on using the changeset viewer.