GCC Code Coverage Report


Directory: ./
File: Executable/ensight2mesh.cpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 0 27 0.0%
Branches: 0 78 0.0%

Line Branch Exec Source
1 // ______ ______ _ _ _____ ______
2 // | ____| ____| | (_)/ ____| | ____|
3 // | |__ | |__ | | _| (___ ___| |__
4 // | __| | __| | | | |\___ \ / __| __|
5 // | | | |____| |____| |____) | (__| |____
6 // |_| |______|______|_|_____/ \___|______|
7 // Finite Elements for Life Sciences and Engineering
8 //
9 // License: LGL2.1 License
10 // FELiScE default license: LICENSE in root folder
11 //
12 // Main authors: D. C. Corti
13 //
14
15 // System includes
16
17 // External includes
18
19 // Project includes
20 #include "Core/filesystemUtil.hpp"
21 #include "InputOutput/io.hpp"
22 #include "Geometry/geometricMeshRegion.hpp"
23 #include "Tools/simple_cmd.hpp"
24
25 bool replace(std::string& str, const std::string& from, const std::string& to) {
26 size_t start_pos = str.rfind(from);
27 if(start_pos == std::string::npos)
28 return false;
29 str.replace(start_pos, from.length(), to);
30 return true;
31 }
32
33 int main(const int argc, const char** argv)
34 {
35 struct Options
36 {
37 std::string InputFile{""};
38 bool IncludeNodes{false};
39 };
40
41 auto parser = CmdOptions<Options>::Create({
42 {"--file", &Options::InputFile },
43 {"--include_nodes", &Options::IncludeNodes }
44 });
45
46 auto options = parser->parse(argc, argv);
47
48 if (options.InputFile == "") {
49 std::cout << "The following input values must be set: " << std::endl;
50 std::cout << "\tInput file:\t--file"<< std::endl;
51 return 1;
52 }
53
54 std::cout << "The following input values has been considered" << std::endl;
55 std::cout << "\tInput file =\t" << options.InputFile << std::endl;
56 std::cout << "\tInclude nodes =\t" << options.IncludeNodes << std::endl;
57
58 // Parameters instance
59 auto& r_instance = felisce::FelisceParam::instance();
60 r_instance.readNodesReferences = options.IncludeNodes;
61
62 std::string current_path = std::filesystem::current_path();
63 current_path += "/";
64 replace(options.InputFile, ".geo", "");
65 auto p_io = felisce::make_shared<felisce::IO>( current_path, options.InputFile + ".geo" , options.InputFile + ".geo", options.InputFile + ".out.geo", current_path, current_path, "ensight");
66 auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>();
67 p_io->readMesh(*p_mesh_region, 1.0);
68
69 // Convert into meshb format
70 auto p_io_mesh_post = felisce::make_shared<felisce::IO>( current_path, options.InputFile + ".mesh" , options.InputFile + ".mesh", options.InputFile + ".out.mesh", current_path, current_path, "mesh");
71 p_io_mesh_post->writeMesh(*p_mesh_region, options.InputFile + ".out.mesh");
72 }
73