Changeset 1006 for cpp/frams/genetics/fS/fS_oper.cpp
- Timestamp:
- 07/14/20 16:04:46 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/fS/fS_oper.cpp
r1000 r1006 36 36 37 37 38 39 const std::map<string, double> minValues = { 40 {INGESTION, 0},//Model::getMinPart().ingest}, 41 {FRICTION, 0},//Model::getMinPart().friction}, 42 {STIFFNESS, 0.1}, 43 {ROT_X, -M_PI}, 44 {ROT_Y, -M_PI}, 45 {ROT_Z, -M_PI}, 46 {RX, -M_PI}, 47 {RY, -M_PI}, 48 {RZ, -M_PI}, 49 {SIZE, 0.01}, 50 {SIZE_X, 0},//Model::getMinPart().scale.x}, 51 {SIZE_Y, 0},//Model::getMinPart().scale.y}, 52 {SIZE_Z, 0}//Model::getMinPart().scale.z} 53 }; 54 55 const std::map<string, double> maxValues = { 56 {INGESTION, 1},//Model::getMaxPart().ingest}, 57 {FRICTION, 1},//Model::getMaxPart().friction}, 58 {STIFFNESS, 0.5}, 59 {ROT_X, M_PI}, 60 {ROT_Y, M_PI}, 61 {ROT_Z, M_PI}, 62 {RX, M_PI}, 63 {RY, M_PI}, 64 {RZ, M_PI}, 65 {SIZE, 100.0}, 66 {SIZE_X, 1},//Model::getMaxPart().scale.x}, 67 {SIZE_Y, 1},//Model::getMaxPart().scale.y}, 68 {SIZE_Z, 1}//Model::getMaxPart().scale.z} 69 }; 70 38 void GenoOper_fS::prepareParams() 39 { 40 minValues = { 41 {INGESTION, Model::getMinPart().ingest}, 42 {FRICTION, Model::getMinPart().friction}, 43 {STIFFNESS, 0.1}, 44 {ROT_X, -M_PI}, 45 {ROT_Y, -M_PI}, 46 {ROT_Z, -M_PI}, 47 {RX, -M_PI}, 48 {RY, -M_PI}, 49 {RZ, -M_PI}, 50 {SIZE, 0.01}, 51 {SIZE_X, Model::getMinPart().scale.x}, 52 {SIZE_Y, Model::getMinPart().scale.y}, 53 {SIZE_Z, Model::getMinPart().scale.z} 54 }; 55 56 maxValues = { 57 {INGESTION, Model::getMaxPart().ingest}, 58 {FRICTION, Model::getMaxPart().friction}, 59 {STIFFNESS, 0.5}, 60 {ROT_X, M_PI}, 61 {ROT_Y, M_PI}, 62 {ROT_Z, M_PI}, 63 {RX, M_PI}, 64 {RY, M_PI}, 65 {RZ, M_PI}, 66 {SIZE, 100.0}, 67 {SIZE_X, Model::getMaxPart().scale.x}, 68 {SIZE_Y, Model::getMaxPart().scale.y}, 69 {SIZE_Z, Model::getMaxPart().scale.z} 70 }; 71 } 71 72 72 73 GenoOper_fS::GenoOper_fS() 73 74 { 75 prepareParams(); 74 76 par.setParamTab(genooper_fS_paramtab); 75 77 par.select(this); … … 332 334 geno.getState(); 333 335 Node *node = geno.chooseNode(); 334 char partType = SHAPE TYPE_TO_GENE.at(availablePartShapes[rndUint(availablePartShapes.size())]);336 char partType = SHAPE_TO_GENE.at(availablePartShapes[rndUint(availablePartShapes.size())]); 335 337 336 338 Substring substring(&partType, 0, 1); … … 374 376 { 375 377 geno.getState(); 376 newNode->mutateSizeParam(SIZE_X, true);377 newNode->mutateSizeParam(SIZE_Y, true);378 newNode->mutateSizeParam(SIZE_Z, true);378 mutateSizeParam(newNode, SIZE_X, true); 379 mutateSizeParam(newNode, SIZE_Y, true); 380 mutateSizeParam(newNode, SIZE_Z, true); 379 381 } 380 382 return true; … … 483 485 bool isRadius = isRadiusOfBase || key == SIZE_X; 484 486 if (ensureCircleSection && isRadius) 487 if (ensureCircleSection && isRadius) 485 488 { 486 489 if (randomNode->partType == Part::Shape::SHAPE_ELLIPSOID) … … 490 493 } 491 494 // Add modified default value for param 492 randomNode->params[key] = mutateCreep('f', defaultValues.at(key), minValues.at(key), maxValues.at(key), true);495 randomNode->params[key] = mutateCreep('f', randomNode->defaultValues.at(key), minValues.at(key), maxValues.at(key), true); 493 496 return true; 494 497 } … … 530 533 return true; 531 534 } else 532 return randomNode->mutateSizeParam(it->first, ensureCircleSection);535 return mutateSizeParam(randomNode, it->first, ensureCircleSection); 533 536 } 534 537 } … … 696 699 } 697 700 698 bool Node::mutateSizeParam(string key, bool ensureCircleSection)699 { 700 double oldValue = getParam(key);701 double volume = calculateVolume();701 bool GenoOper_fS::mutateSizeParam(Node *node, string key, bool ensureCircleSection) 702 { 703 double oldValue = node->getParam(key); 704 double volume = node->calculateVolume(); 702 705 double valueAtMinVolume, valueAtMaxVolume; 703 706 if(key == SIZE) … … 715 718 double max = std::min(maxValues.at(key), valueAtMaxVolume); 716 719 717 params[key] = GenoOperators::mutateCreep('f',getParam(key), min, max, true);718 719 if (!ensureCircleSection || isPartSizeValid())720 node->params[key] = GenoOperators::mutateCreep('f', node->getParam(key), min, max, true); 721 722 if (!ensureCircleSection || node->isPartSizeValid()) 720 723 return true; 721 724 else 722 725 { 723 params[key] = oldValue;724 return false; 725 } 726 } 726 node->params[key] = oldValue; 727 return false; 728 } 729 }
Note: See TracChangeset
for help on using the changeset viewer.