MySources/reducedmodelevaluator.hpp

252 lines
7.3 KiB
C++

#ifndef REDUCEDMODELEVALUATOR_HPP
#define REDUCEDMODELEVALUATOR_HPP
#include "reducedmodeloptimizer_structs.hpp"
#include "utilities.hpp"
class ReducedModelEvaluator {
public:
enum CSVExportingDirection { Vertical = 0, Horizontal };
enum CSVExportingData {
raw_drm2Reduced = 0,
norm_groundTruth2Reduced,
raw_and_norm_drm2Reduced,
NumberOfDataTypes
};
inline static std::array<std::string, NumberOfDataTypes>
csvExportingDataStrings{"raw_drm2Reduced", "norm_drm2Reduced",
"raw_and_norm_drm2Reduced"};
struct ExportingSettings {
// exporting settings
CSVExportingDirection direction{Horizontal};
CSVExportingData data{norm_groundTruth2Reduced};
bool shouldWriteHeader{true};
std::string resultsLabel;
};
struct Settings {
#ifdef POLYSCOPE_DEFINED
bool shouldDraw{false};
#endif
bool shouldRecomputeGroundTruthResults{false};
bool beVerbose{true};
NLOHMANN_DEFINE_TYPE_INTRUSIVE(
Settings,
shouldRecomputeGroundTruthResults,
beVerbose
//#ifdef POLYSCOPE_DEFINED
// ,
// shouldDraw
//#endif
)
bool save(const std::filesystem::path& jsonFilePath) const;
bool load(const std::filesystem::path& jsonFilePath);
std::string toString() const {
nlohmann::json json = *this;
return std::string("Reduced model evaluation settings:" + json.dump());
}
};
inline static constexpr int NumberOfEvaluationScenarios = 17;
inline static const std::array<std::string, NumberOfEvaluationScenarios>
scenariosTestSetLabels{
"22Hex_randomBending0",
"22Hex_randomBending1",
"22Hex_randomBending2",
"22Hex_randomBending4",
"22Hex_randomBending5",
"22Hex_randomBending8",
"22Hex_randomBending9",
"22Hex_randomBending11",
"22Hex_randomBending12",
"22Hex_randomBending16",
"22Hex_randomBending17",
"22Hex_randomBending18",
"22Hex_randomBending19",
"22Hex_bending_0.01N",
"22Hex_pullOppositeVerts_0.05N",
"22Hex_cylinder_0.1N",
"22Hex_s_0.05N",
};
inline static constexpr double forceScalingFactor = 1.5;
struct Results {
std::array<double, NumberOfEvaluationScenarios> distances_drm2reduced;
std::array<double, NumberOfEvaluationScenarios>
distances_normalizedGroundTruth2reduced;
std::array<std::string, NumberOfEvaluationScenarios>
evaluationScenarioLabels;
std::array<double, NumberOfEvaluationScenarios> maxDisplacements;
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Results,
evaluationScenarioLabels,
maxDisplacements)
inline static std::string defaultFileName{"evaluationResults.json"};
void save(const std::filesystem::path& saveToPath) {
assert(std::filesystem::is_directory(saveToPath));
nlohmann::json json = *this;
std::filesystem::path jsonFilePath(
std::filesystem::path(saveToPath).append(defaultFileName));
std::ofstream jsonFile(jsonFilePath.string());
jsonFile << json;
jsonFile.close();
}
};
ReducedModelEvaluator();
Results evaluateReducedModel(
ReducedModelOptimization::Results& optimizationResult,
const std::filesystem::path& scenariosDirectoryPath,
// const std::filesystem::path &reducedPatternFilePath,
const std::filesystem::path& fullPatternTessellatedResultsDirectoryPath,
const ReducedModelEvaluator::Settings& settings);
Results evaluateReducedModel(
ReducedModelOptimization::Results& optimizationResult,
const Settings& settings);
static void printResultsVertically(
const ReducedModelEvaluator::Results& evaluationResults,
CSVFile& csvOutput);
static void printResults(
const ReducedModelEvaluator::Results& evaluationResults,
const std::string& resultsLabel);
static void printResultsHorizontally(const Results& evaluationResults,
CSVFile& csvOutput);
static void printResults(const Results& evaluationResults,
const ExportingSettings& exportingSettings,
CSVFile& csvOutput);
static void printHeader(const ExportingSettings& exportingSettings,
CSVFile& csvOutput);
// static double evaluateOptimizationSettings(
// const ReducedModelOptimization::Settings &optimizationSettings,
// const std::vector<std::shared_ptr<PatternGeometry>> &pPatterns,
// std::vector<ReducedModelEvaluator::Results>
// &patternEvaluationResults);
std::shared_ptr<VCGPolyMesh> pTileIntoSurface;
ReducedModelOptimization::Colors::RGBColor color_tesselatedPatterns{
24.0 / 255, 23.0 / 255, 23.0 / 255};
ReducedModelOptimization::Colors::RGBColor color_tesselatedReducedModels{
67.0 / 255, 160.00 / 255, 232.0 / 255};
ReducedModelOptimization::Colors::RGBColor color_tileIntoSurface{
// 222 / 255.0, 235 / 255.0, 255 / 255.0};
156 / 255.0, 195 / 255.0, 254 / 255.0};
ReducedModelOptimization::Colors::RGBColor interfaceNodes_color{
63.0 / 255, 85.0 / 255, 42.0 / 255};
inline static constexpr char* tileIntoSurfaceFileContent = R"~(OFF
46 66 0
-0.0745923 0.03573945 0
-0.07464622 0.02191801 0
-0.06264956 0.02878203 0
-0.08658896 0.02887542 0
-0.06270347 0.01496059 0
-0.06259564 0.04260346 0
-0.08664289 0.01505398 0
-0.08653505 0.04269686 0
-0.0507068 0.02182462 0
-0.07453838 0.04956088 0
-0.05065288 0.03564605 0
-0.09858564 0.02201139 0
-0.09853172 0.03583283 0
-0.06254172 0.0564249 0
-0.05059896 0.04946748 0
-0.08648112 0.0565183 0
-0.09847781 0.04965428 0
-0.03871013 0.02868864 0
-0.07448447 0.06338232 0
-0.03865621 0.04251007 0
-0.1105284 0.02896881 0
-0.1104745 0.04279025 0
-0.03876406 0.0148672 0
-0.05054504 0.06328891 0
-0.0624878 0.07024634 0
-0.03860229 0.0563315 0
-0.1105823 0.01514738 0
-0.08642721 0.07033974 0
-0.09842389 0.06347572 0
-0.1104206 0.05661169 0
-0.07443054 0.07720376 0
-0.05049112 0.07711035 0
-0.03854837 0.07015293 0
-0.06243387 0.08406778 0
-0.08637329 0.08416118 0
-0.09836997 0.07729716 0
-0.1103666 0.07043312 0
-0.07437663 0.09102518 0
-0.03849445 0.08397438 0
-0.0504372 0.0909318 0
-0.06237995 0.09788923 0
-0.08631937 0.09798261 0
-0.09831604 0.09111859 0
-0.1103127 0.08425456 0
-0.03844052 0.09779582 0
-0.1102588 0.09807601 0
3 0 1 2
3 3 1 0
3 4 2 1
3 5 0 2
3 3 6 1
3 3 0 7
3 8 2 4
3 5 9 0
3 10 5 2
3 3 11 6
3 7 0 9
3 12 3 7
3 10 2 8
3 5 13 9
3 10 14 5
3 12 11 3
3 7 9 15
3 12 7 16
3 10 8 17
3 14 13 5
3 18 9 13
3 19 14 10
3 12 20 11
3 18 15 9
3 16 7 15
3 21 12 16
3 22 17 8
3 19 10 17
3 23 13 14
3 18 13 24
3 19 25 14
3 21 20 12
3 26 11 20
3 18 27 15
3 16 15 28
3 21 16 29
3 23 24 13
3 23 14 25
3 30 18 24
3 30 27 18
3 15 27 28
3 29 16 28
3 23 31 24
3 23 25 32
3 30 24 33
3 30 34 27
3 35 28 27
3 29 28 36
3 23 32 31
3 24 31 33
3 30 33 37
3 30 37 34
3 35 27 34
3 35 36 28
3 32 38 31
3 33 31 39
3 40 37 33
3 34 37 41
3 35 34 42
3 35 43 36
3 38 39 31
3 40 33 39
3 34 41 42
3 35 42 43
3 44 39 38
3 45 43 42
)~";
};
#endif // REDUCEDMODELEVALUATOR_HPP