Saving force magnitudes
This commit is contained in:
parent
81a60c686c
commit
02295c4ba5
62
src/main.cpp
62
src/main.cpp
|
@ -11,26 +11,52 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// DRMSimulationModel::runUnitTests();
|
||||
if (argc != 3) {
|
||||
return 1;
|
||||
}
|
||||
// DRMSimulationModel::runUnitTests();
|
||||
// const std::string tileInto_triMesh_filename("/home/iason/Models/"
|
||||
// "hexagon_384tri.ply");
|
||||
const std::string tileInto_triMesh_filename = argv[1];
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/fra/ex5_56.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/fra/ex3_96.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/fra/ex2_230.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/fra/ex1_74.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/fra/ex2_122.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/"
|
||||
// "instantMeshes_plane_200_big_1x1_100x100.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/"
|
||||
// "instantMeshes_plane_500_big_1x1_100x100.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/"
|
||||
// "instantMeshes_plane_1000_big_1x1_100x100.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/"
|
||||
// "instantMeshes_strip_45.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/"
|
||||
// "instantMeshes_widerStrip_100.ply");
|
||||
const std::string tileInto_triMesh_filename(
|
||||
"/home/iason/Coding/build/PatternTillingReducedModel/Meshes/"
|
||||
"instantMeshes_plane_34.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/"
|
||||
// "instantMeshes_plane_34.ply");
|
||||
// const std::string tileInto_triMesh_filename(
|
||||
// "/home/iason/Coding/build/PatternTillingReducedModel/RelWithDebInfo/"
|
||||
// "instantMeshes_plane4Hexagon_5.ply");
|
||||
VCGTriMesh tileInto_triMesh;
|
||||
tileInto_triMesh.load(tileInto_triMesh_filename);
|
||||
const bool surfaceLoadSuccessfull = tileInto_triMesh.load(tileInto_triMesh_filename);
|
||||
assert(surfaceLoadSuccessfull);
|
||||
|
||||
std::shared_ptr<VCGPolyMesh> pTileInto_polyMesh = PolygonalRemeshing::remeshWithPolygons(
|
||||
tileInto_triMesh);
|
||||
|
||||
//Load optimization results
|
||||
// //Load optimization results
|
||||
// const size_t numberOfOptimizationResults = argc - 1;
|
||||
// std::vector<ReducedPatternOptimization::Results> optimizationResults(
|
||||
// numberOfOptimizationResults);
|
||||
|
@ -39,16 +65,22 @@ int main(int argc, char *argv[])
|
|||
// commandLineParameterIndex++)
|
||||
// optimizationResults[commandLineParameterIndex].load(argv[commandLineParameterIndex + 1]);
|
||||
|
||||
// for (const auto &dirEntry : std::filesystem::directory_iterator(
|
||||
std::filesystem::path optimizationResultsPath0(
|
||||
"/home/iason/Coding/build/ReducedModelOptimization/RelWithDebInfo/OptimizationResults/"
|
||||
"ConvergedJobs");
|
||||
std::filesystem::path optimizationResultsPath1(
|
||||
"/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
"patterns/ReducedModelOptimization/Results/selectionOfPatterns_0.2To1.6/"
|
||||
"selectionOfPatterns/1.2/ConvergedJobs");
|
||||
const std::filesystem::path optimizationResultsPath = argv[2];
|
||||
// std::filesystem::path optimizationResultsPath0(
|
||||
// "/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
// "patterns/ReducedModelOptimization/Results/selectionOfPatterns2");
|
||||
// std::filesystem::path optimizationResultsPath1(
|
||||
// "/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
// "patterns/ReducedModelOptimization/Results/selectionOfPatterns_0.2To1.6/"
|
||||
// "selectionOfPatterns/1.2/ConvergedJobs");
|
||||
// std::filesystem::path optimizationResultsPath2(
|
||||
// "/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
// "patterns/ReducedModelOptimization/Results/selectionOfPatterns3");
|
||||
// std::filesystem::path optimizationResultsPath3(
|
||||
// "/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
// "patterns/ReducedModelOptimization/Results/selectionOfPatterns4");
|
||||
std::vector<ReducedPatternOptimization::Results> optimizationResults
|
||||
= ReducedPatternSimulator::loadOptimizationResults(optimizationResultsPath1);
|
||||
= ReducedPatternSimulator::loadOptimizationResults(optimizationResultsPath);
|
||||
//Load reduced
|
||||
const std::filesystem::path patternFilePath(
|
||||
"/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,42 +11,65 @@ using LinearFullSimulationResults = SimulationResults;
|
|||
using ReducedSimulationResults = SimulationResults;
|
||||
using FullPatternVertexIndex = int;
|
||||
using ReducedPatternVertexIndex = int;
|
||||
using OptimizationResultsIndex = int;
|
||||
class ReducedPatternSimulator
|
||||
{
|
||||
std::vector<ReducedPatternOptimization::Results> &mOptimizationResults;
|
||||
std::shared_ptr<SimulationMesh> pTiledFullPattern_simulationMesh;
|
||||
std::shared_ptr<SimulationMesh> pTiledReducedPattern_simulationMesh;
|
||||
std::shared_ptr<SimulationJob> pJob_tiledReducedPattern;
|
||||
std::shared_ptr<SimulationJob> pJob_tiledFullPattern;
|
||||
std::shared_ptr<VCGPolyMesh> pTileIntoSurface;
|
||||
const Vector6d externalForce{0, 0, 0.1, 0, 0, 0};
|
||||
double minInputForceMagnitude = std::numeric_limits<double>::max();
|
||||
std::string gui_jobLabel;
|
||||
std::string gui_tessellationLabel;
|
||||
bool gui_shouldRerunFullPatternSimulation{false};
|
||||
float gui_scaleFactor{1};
|
||||
std::vector<glm::vec3> gui_fullVerticesColors;
|
||||
std::vector<glm::vec3> gui_reducedVerticesColors;
|
||||
std::array<float, 3> gui_externalForce{0, 0, 0};
|
||||
std::array<float, 3> gui_externalMoment{0, 0, 0};
|
||||
std::array<float, 4> gui_randomnessParams{0.02, 0.02, 0.3, 0.4};
|
||||
std::array<float, 4> gui_randomnessParams{0.02, 0.02, 0.1, 0.3};
|
||||
std::vector<int> gui_faceToPatternIndex;
|
||||
std::vector<int> gui_fullPatternSelectedVertices;
|
||||
std::pair<glm::vec3, size_t> gui_currentColorPatternIndexPair{glm::vec3(1, 0, 0), 0};
|
||||
std::vector<glm::vec3> gui_colorsPerFace;
|
||||
std::unordered_map<VertexIndex, VertexIndex> fullToReducedViMap; //of only the common vertices
|
||||
std::unordered_map<VertexIndex, VertexIndex> reducedToFullViMap; //of only the common vertices
|
||||
std::vector<size_t> tilledFullPatternInterfaceVi;
|
||||
double surfaceBaseTriangleHeight{-1};
|
||||
std::string fullPatternsSurfacelabel;
|
||||
std::string fullPatternsLabel;
|
||||
std::array<double, 3> color_tesselatedFullPatterns{0.89, 0.61, 0.11};
|
||||
std::array<double, 3> color_tesselatedReducedPatterns{0.11, 0.89, 0.22};
|
||||
std::string fullPatternsSurfacelabel{"Empty label"};
|
||||
std::string fullPatternsLabel{"Empty label"};
|
||||
std::string surfaceLabel{"Empty label"};
|
||||
std::string fullPatternsOrderLabel{"Empty label"};
|
||||
|
||||
vcg::Triangle3<double> reducedPatternBaseTriangle;
|
||||
PatternGeometry reducedPattern;
|
||||
const bool randomTesselationIsEnabled{false};
|
||||
const std::vector<std::string> scenariosTestSetLabels{// "22Hex_random0",
|
||||
// "22Hex_random1",
|
||||
// "22Hex_random2",
|
||||
// "22Hex_random3",
|
||||
// "22Hex_random4",
|
||||
// "22Hex_random5",
|
||||
// "22Hex_random6",
|
||||
// "22Hex_random7",
|
||||
// "22Hex_random8",
|
||||
// "22Hex_random9",
|
||||
// "22Hex_random10",
|
||||
// "22Hex_random11",
|
||||
// "22Hex_random12",
|
||||
// "22Hex_random17",
|
||||
// "22Hex_random14"
|
||||
const std::vector<std::string> scenariosTestSetLabels{"22Hex_randomBending0",
|
||||
"22Hex_randomBending1",
|
||||
"22Hex_randomBending2",
|
||||
"22Hex_randomBending3",
|
||||
"22Hex_randomBending4",
|
||||
"22Hex_randomBending5",
|
||||
"22Hex_randomBending6",
|
||||
"22Hex_randomBending7",
|
||||
"22Hex_randomBending8",
|
||||
"22Hex_randomBending9",
|
||||
"22Hex_randomBending10",
|
||||
"22Hex_randomBending11",
|
||||
"22Hex_randomBending12",
|
||||
"22Hex_randomBending13",
|
||||
"22Hex_randomBending14",
|
||||
"22Hex_randomBending15",
|
||||
"22Hex_randomBending16",
|
||||
"22Hex_randomBending17",
|
||||
"22Hex_randomBending18",
|
||||
"22Hex_randomBending19",
|
||||
"22Hex_randomBending20",
|
||||
"22Hex_bending_0.005N",
|
||||
"22Hex_bending_0.01N",
|
||||
"22Hex_bending_0.03N",
|
||||
|
@ -66,11 +89,12 @@ class ReducedPatternSimulator
|
|||
std::unordered_map<size_t, size_t> shuffleToNumOfOccur;
|
||||
|
||||
public:
|
||||
ReducedPatternSimulator(
|
||||
const std::vector<ReducedPatternOptimization::Results> &optimizationResults);
|
||||
ReducedPatternSimulator(std::vector<ReducedPatternOptimization::Results> &optimizationResults);
|
||||
void simulate(std::shared_ptr<VCGPolyMesh> &tileIntoSurface,
|
||||
std::vector<ReducedPatternOptimization::Results> &optimizationResults,
|
||||
PatternGeometry &reducedPattern);
|
||||
PatternGeometry &reducedPattern,
|
||||
const std::vector<OptimizationResultsIndex> &perSurfaceFacePatternIndices
|
||||
= std::vector<OptimizationResultsIndex>());
|
||||
/*
|
||||
* centers the surface
|
||||
* scales it such that its average base triangle size matches a desired one. This is done in order to match the base triangle on which the reduced pattern was optimized on
|
||||
|
@ -88,13 +112,12 @@ public:
|
|||
const std::filesystem::path &optimizationResultsFolderPath);
|
||||
|
||||
private:
|
||||
std::shared_ptr<VCGPolyMesh> pTileIntoSurface;
|
||||
std::vector<PatternGeometry> fullPatterns;
|
||||
static void createSimulationJobs(const Vector6d &externalForce,
|
||||
SimulationJob &job_fullPattern,
|
||||
SimulationJob &job_reducedPattern);
|
||||
void createGuiMenu();
|
||||
std::pair<FullPatternVertexIndex, ReducedPatternVertexIndex> getPickedVertices(
|
||||
std::pair<FullPatternVertexIndex, ReducedPatternVertexIndex> getPickedInterfaceVertices(
|
||||
const std::pair<std::string, size_t> &selection) const;
|
||||
void reset();
|
||||
void saveJobs(const filesystem::__cxx11::path &outputFolderPath);
|
||||
|
@ -103,7 +126,6 @@ private:
|
|||
SimulationResults &reducedResults);
|
||||
void createTiledSimulationMeshes(std::vector<PatternGeometry> &fullPatterns,
|
||||
std::vector<PatternGeometry> &reducedPatterns);
|
||||
using OptimizationResultsIndex = size_t;
|
||||
void createTiledSimulationMeshes(
|
||||
const std::shared_ptr<ConstVCGPolyMesh> &pTileIntoSurface,
|
||||
std::vector<ReducedPatternOptimization::Results> &optimizationResults,
|
||||
|
@ -137,25 +159,25 @@ private:
|
|||
const bool &shouldDraw);
|
||||
void tileReducedPatterns(
|
||||
const std::vector<ReducedPatternOptimization::Results> &optimizationResults,
|
||||
const std::vector<size_t> &perSurfaceFacePatternIndices,
|
||||
const std::vector<int> &perSurfaceFacePatternIndices,
|
||||
std::shared_ptr<SimulationMesh> &pSimulationMesh_tiledReduced,
|
||||
std::vector<size_t> &tileIntoEdgeToTiledReduced);
|
||||
void shuffleReducedPatterns(
|
||||
const std::vector<ReducedPatternOptimization::Results> &optimizationResults,
|
||||
const std::vector<size_t> &tileIntoEdgeToTiledFullPattern,
|
||||
const std::vector<size_t> &perSurfaceFacePatternIndices);
|
||||
const std::vector<int> &perSurfaceFacePatternIndices);
|
||||
void runWeightEvaluation(const std::filesystem::path &optimizationResultsFolderPath);
|
||||
void constructViMaps(const std::vector<size_t> &tileIntoEdgeToTiledFullPattern,
|
||||
const std::vector<size_t> &tileIntoEdgeToTiledReducedPattern);
|
||||
std::vector<size_t> computePerSurfaceFacePatternsIndices(
|
||||
std::vector<int> computePerSurfaceFacePatternsIndices(
|
||||
const std::vector<ReducedPatternOptimization::Results> &optimizationResults) const;
|
||||
void tileFullPatterns(std::vector<ConstPatternGeometry> &fullPatterns,
|
||||
const std::vector<size_t> &perSurfaceFacePatternIndices,
|
||||
const std::vector<int> &perSurfaceFacePatternIndices,
|
||||
std::shared_ptr<SimulationMesh> &pTiledFullPattern_simulationMesh,
|
||||
std::vector<size_t> &tileIntoEdgeToTiledFullVi);
|
||||
void fillFullPatterns(std::vector<ReducedPatternOptimization::Results> &optimizationResults);
|
||||
void computeLabels(const std::vector<ReducedPatternOptimization::Results> &optimizationResults,
|
||||
const std::vector<size_t> &perSurfaceFacePatternIndex);
|
||||
const std::vector<OptimizationResultsIndex> &perSurfaceFacePatternIndex);
|
||||
void createShufflings(std::vector<ReducedPatternOptimization::Results> &optimizationResults);
|
||||
void generateRandomSimulationScenario(const std::array<float, 4> &randomScenarioParameters);
|
||||
std::tuple<DRMFullSimulationResults, ReducedSimulationResults, LinearFullSimulationResults>
|
||||
|
@ -166,6 +188,18 @@ private:
|
|||
ReducedSimulationResults,
|
||||
LinearFullSimulationResults> &simulationResults,
|
||||
const string &csvFilePath = {});
|
||||
void reportDistances(const std::vector<std::string> &scenarioLabels);
|
||||
void saveTesselation(const std::filesystem::path &saveTo);
|
||||
void removeDrawnSimulationJobs();
|
||||
void loadTessellation(const std::filesystem::path &jsonFilePath);
|
||||
void computeSurfaceColorsFromPerFacePatterns(const std::vector<int> &faceToPatternIndex);
|
||||
void resetTilledMeshes();
|
||||
std::string computeFullPatternSetLabel(
|
||||
const std::vector<ReducedPatternOptimization::Results> &optimizationResults);
|
||||
void resetUserSelectedVertices();
|
||||
void resetUserSelectedFaces();
|
||||
void removeTesselatedPatterns();
|
||||
void updateTesselationColors();
|
||||
};
|
||||
|
||||
#endif // REDUCEDPATTERNSIMULATOR_HPP
|
||||
|
|
Loading…
Reference in New Issue