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

Added GenoOperators::calculateSolidVolume(Part)

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.