diff --git a/Element/Visualisation/vtkParser.cpp b/Element/Visualisation/vtkParser.cpp index 3011c3b45..4069a5469 100644 --- a/Element/Visualisation/vtkParser.cpp +++ b/Element/Visualisation/vtkParser.cpp @@ -159,7 +159,7 @@ void vtk_plot_node_quantity(const shared_ptr& domain, vtkInfo config data->SetTuple6(I, 0., 0., 0., 0., 0., 0.); } - data->SetName(to_category(config.type)); + data->SetName(to_category(config.type).c_str()); data->SetComponentName(0, "1"); data->SetComponentName(1, "2"); data->SetComponentName(2, "3"); @@ -179,12 +179,12 @@ void vtk_plot_node_quantity(const shared_ptr& domain, vtkInfo config if(config.store_ptr) { grid->GetPointData()->SetScalars(data); - grid->GetPointData()->SetActiveScalars(to_category(config.type)); + grid->GetPointData()->SetActiveScalars(to_category(config.type).c_str()); config.grid_ptr = grid; } else if(config.save_file) { grid->GetPointData()->SetScalars(data); - grid->GetPointData()->SetActiveScalars(to_category(config.type)); + grid->GetPointData()->SetActiveScalars(to_category(config.type).c_str()); domain->insert(make_unique>(std::async(std::launch::async, vtk_save, std::move(grid), std::move(config)))); } else { @@ -220,7 +220,7 @@ void vtk_plot_element_quantity(const shared_ptr& domain, vtkInfo con data->SetTuple6(I, 0., 0., 0., 0., 0., 0.); } - data->SetName(to_category(config.type)); + data->SetName(to_category(config.type).c_str()); data->SetComponentName(0, "1"); data->SetComponentName(1, "2"); data->SetComponentName(2, "3"); @@ -252,12 +252,12 @@ void vtk_plot_element_quantity(const shared_ptr& domain, vtkInfo con if(config.store_ptr) { grid->GetPointData()->SetScalars(data); - grid->GetPointData()->SetActiveScalars(to_category(config.type)); + grid->GetPointData()->SetActiveScalars(to_category(config.type).c_str()); config.grid_ptr = grid; } else if(config.save_file) { grid->GetPointData()->SetScalars(data); - grid->GetPointData()->SetActiveScalars(to_category(config.type)); + grid->GetPointData()->SetActiveScalars(to_category(config.type).c_str()); domain->insert(make_unique>(std::async(std::launch::async, vtk_save, std::move(grid), std::move(config)))); } else { diff --git a/Recorder/OutputType.cpp b/Recorder/OutputType.cpp index 45b38fa67..15188050c 100644 --- a/Recorder/OutputType.cpp +++ b/Recorder/OutputType.cpp @@ -17,6 +17,8 @@ #include "OutputType.h" +#include + int to_index(const OutputType config) { if(config == OutputType::S11) return 0; if(config == OutputType::S22) return 1; @@ -125,170 +127,16 @@ int to_index(const OutputType config) { return 0; } -const char* to_category(const OutputType L) { - if(OutputType::S == L) return "S"; - if(OutputType::S11 == L) return "S"; - if(OutputType::S12 == L) return "S"; - if(OutputType::S13 == L) return "S"; - if(OutputType::S22 == L) return "S"; - if(OutputType::S23 == L) return "S"; - if(OutputType::S33 == L) return "S"; - if(OutputType::E == L) return "E"; - if(OutputType::E11 == L) return "E"; - if(OutputType::E12 == L) return "E"; - if(OutputType::E13 == L) return "E"; - if(OutputType::E22 == L) return "E"; - if(OutputType::E23 == L) return "E"; - if(OutputType::E33 == L) return "E"; - if(OutputType::EE == L) return "EE"; - if(OutputType::EE11 == L) return "EE"; - if(OutputType::EE12 == L) return "EE"; - if(OutputType::EE13 == L) return "EE"; - if(OutputType::EE22 == L) return "EE"; - if(OutputType::EE23 == L) return "EE"; - if(OutputType::EE33 == L) return "EE"; - if(OutputType::PE == L) return "PE"; - if(OutputType::PE11 == L) return "PE"; - if(OutputType::PE12 == L) return "PE"; - if(OutputType::PE13 == L) return "PE"; - if(OutputType::PE22 == L) return "PE"; - if(OutputType::PE23 == L) return "PE"; - if(OutputType::PE33 == L) return "PE"; - if(OutputType::SP == L) return "SP"; - if(OutputType::SP1 == L) return "SP"; - if(OutputType::SP2 == L) return "SP"; - if(OutputType::SP3 == L) return "SP"; - if(OutputType::EP == L) return "EP"; - if(OutputType::EP1 == L) return "EP"; - if(OutputType::EP2 == L) return "EP"; - if(OutputType::EP3 == L) return "EP"; - if(OutputType::EEP == L) return "EEP"; - if(OutputType::EEP1 == L) return "EEP"; - if(OutputType::EEP2 == L) return "EEP"; - if(OutputType::EEP3 == L) return "EEP"; - if(OutputType::PEP == L) return "PEP"; - if(OutputType::PEP1 == L) return "PEP"; - if(OutputType::PEP2 == L) return "PEP"; - if(OutputType::PEP3 == L) return "PEP"; - if(OutputType::U == L) return "U"; - if(OutputType::U1 == L) return "U"; - if(OutputType::U2 == L) return "U"; - if(OutputType::U3 == L) return "U"; - if(OutputType::U4 == L) return "U"; - if(OutputType::U5 == L) return "U"; - if(OutputType::U6 == L) return "U"; - if(OutputType::UR1 == L) return "U"; - if(OutputType::UR2 == L) return "U"; - if(OutputType::UR3 == L) return "U"; - if(OutputType::V == L) return "V"; - if(OutputType::V1 == L) return "V"; - if(OutputType::V2 == L) return "V"; - if(OutputType::V3 == L) return "V"; - if(OutputType::V4 == L) return "V"; - if(OutputType::V5 == L) return "V"; - if(OutputType::V6 == L) return "V"; - if(OutputType::VR1 == L) return "V"; - if(OutputType::VR2 == L) return "V"; - if(OutputType::VR3 == L) return "V"; - if(OutputType::A == L) return "A"; - if(OutputType::A1 == L) return "A"; - if(OutputType::A2 == L) return "A"; - if(OutputType::A3 == L) return "A"; - if(OutputType::A4 == L) return "A"; - if(OutputType::A5 == L) return "A"; - if(OutputType::A6 == L) return "A"; - if(OutputType::AR1 == L) return "A"; - if(OutputType::AR2 == L) return "A"; - if(OutputType::AR3 == L) return "A"; - if(OutputType::MM == L) return "MM"; - if(OutputType::MM1 == L) return "MM"; - if(OutputType::MM2 == L) return "MM"; - if(OutputType::MM3 == L) return "MM"; - if(OutputType::MM4 == L) return "MM"; - if(OutputType::MM5 == L) return "MM"; - if(OutputType::MM6 == L) return "MM"; - if(OutputType::MMR1 == L) return "MM"; - if(OutputType::MMR2 == L) return "MM"; - if(OutputType::MMR3 == L) return "MM"; - if(OutputType::RF == L) return "RF"; - if(OutputType::RF1 == L) return "RF"; - if(OutputType::RF2 == L) return "RF"; - if(OutputType::RF3 == L) return "RF"; - if(OutputType::RF4 == L) return "RF"; - if(OutputType::RF5 == L) return "RF"; - if(OutputType::RF6 == L) return "RF"; - if(OutputType::RM1 == L) return "RF"; - if(OutputType::RM2 == L) return "RF"; - if(OutputType::RM3 == L) return "RF"; - if(OutputType::DF == L) return "DF"; - if(OutputType::DF1 == L) return "DF"; - if(OutputType::DF2 == L) return "DF"; - if(OutputType::DF3 == L) return "DF"; - if(OutputType::DF4 == L) return "DF"; - if(OutputType::DF5 == L) return "DF"; - if(OutputType::DF6 == L) return "DF"; - if(OutputType::DM1 == L) return "DF"; - if(OutputType::DM2 == L) return "DF"; - if(OutputType::DM3 == L) return "DF"; - if(OutputType::IF == L) return "IF"; - if(OutputType::IF1 == L) return "IF"; - if(OutputType::IF2 == L) return "IF"; - if(OutputType::IF3 == L) return "IF"; - if(OutputType::IF4 == L) return "IF"; - if(OutputType::IF5 == L) return "IF"; - if(OutputType::IF6 == L) return "IF"; - if(OutputType::IM1 == L) return "IF"; - if(OutputType::IM2 == L) return "IF"; - if(OutputType::IM3 == L) return "IF"; - if(OutputType::GDF == L) return "GDF"; - if(OutputType::GDF1 == L) return "GDF"; - if(OutputType::GDF2 == L) return "GDF"; - if(OutputType::GDF3 == L) return "GDF"; - if(OutputType::GDF4 == L) return "GDF"; - if(OutputType::GDF5 == L) return "GDF"; - if(OutputType::GDF6 == L) return "GDF"; - if(OutputType::GDM1 == L) return "GDM"; - if(OutputType::GDM2 == L) return "GDM"; - if(OutputType::GDM3 == L) return "GDM"; - if(OutputType::GIF == L) return "GIF"; - if(OutputType::GIF1 == L) return "GIF"; - if(OutputType::GIF2 == L) return "GIF"; - if(OutputType::GIF3 == L) return "GIF"; - if(OutputType::GIF4 == L) return "GIF"; - if(OutputType::GIF5 == L) return "GIF"; - if(OutputType::GIF6 == L) return "GIF"; - if(OutputType::GIM1 == L) return "GIF"; - if(OutputType::GIM2 == L) return "GIF"; - if(OutputType::GIM3 == L) return "GIF"; - if(OutputType::HYDRO == L) return "HYDRO"; - if(OutputType::MISES == L) return "MISES"; - if(OutputType::EEQ == L) return "EEQ"; - if(OutputType::EEEQ == L) return "EEEQ"; - if(OutputType::PEEQ == L) return "PEEQ"; - if(OutputType::KE == L) return "KE"; - if(OutputType::SE == L) return "SE"; - if(OutputType::VE == L) return "VE"; - if(OutputType::NVE == L) return "NVE"; - if(OutputType::K == L) return "K"; - if(OutputType::M == L) return "M"; - if(OutputType::ED == L) return "ED"; - if(OutputType::VD == L) return "VD"; - if(OutputType::SD == L) return "SD"; - if(OutputType::ES == L) return "ES"; - if(OutputType::VS == L) return "VS"; - if(OutputType::SS == L) return "SS"; - if(OutputType::DAMAGE == L) return "DAMAGE"; - if(OutputType::DT == L) return "DT"; - if(OutputType::DC == L) return "DC"; - if(OutputType::PP == L) return "PP"; - if(OutputType::VF == L) return "VF"; - if(OutputType::HIST == L) return "HIST"; - if(OutputType::LITR == L) return "LITR"; - if(OutputType::YF == L) return "YF"; - if(OutputType::BEAME == L) return "BEAME"; - if(OutputType::BEAMS == L) return "BEAMS"; - if(OutputType::AMP == L) return "AMP"; - if(OutputType::NL == L) return "NL"; - - return "NL"; +std::string to_category(const OutputType L) { + auto result = std::regex_replace(std::string(to_name(L)), std::regex(R"([0-9])"), ""); + if(result == "UR") return "U"; + if(result == "VR") return "V"; + if(result == "AR") return "A"; + if(result == "MMR") return "MM"; + if(result == "RM") return "RF"; + if(result == "DM") return "DF"; + if(result == "IM") return "IF"; + if(result == "GDM") return "GDF"; + if(result == "GIM") return "GIF"; + return result; } diff --git a/Recorder/OutputType.h b/Recorder/OutputType.h index c43460a73..2295627e7 100644 --- a/Recorder/OutputType.h +++ b/Recorder/OutputType.h @@ -270,7 +270,8 @@ constexpr std::string_view to_name(const OutputType L) { return magic_enum::enum constexpr OutputType to_token(const std::string_view L) { return magic_enum::enum_cast(L).value_or(OutputType::NL); } -const char* to_category(OutputType); +std::string to_category(OutputType); + int to_index(OutputType); #endif