diff --git a/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp b/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp index c48647d7340b934cb86a25ea7f1980a268237072..da5af3d519d538a6d9d0332f293c3f7961c4ac33 100644 --- a/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp +++ b/Applications/Utils/FileConverter/ConvertSHPToGLI.cpp @@ -17,25 +17,18 @@ #include <iostream> #include <vector> -// TCLAP -#include "tclap/CmdLine.h" - -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include <tclap/CmdLine.h> // ShapeLib #include <shapefil.h> -// BaseLib -#include "LogogSimpleFormatter.h" +#include "Applications/ApplicationsLib/LogogSetup.h" #include "GeoLib/IO/XmlIO/Qt/XmlGmlInterface.h" #include "GeoLib/IO/XmlIO/Qt/XmlStnInterface.h" - -// GeoLib -#include "GEOObjects.h" -#include "Point.h" -#include "Station.h" +#include "GeoLib/GEOObjects.h" +#include "GeoLib/Point.h" +#include "GeoLib/Station.h" void convertPoints (DBFHandle dbf_handle, std::string const& out_fname, @@ -140,10 +133,7 @@ void printFieldInformationTable(DBFHandle const& dbf_handle, std::size_t n_field int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Converts points contained in shape file", ' ', "0.1"); TCLAP::ValueArg<std::string> shapefile_arg("s", @@ -172,7 +162,7 @@ int main (int argc, char* argv[]) ERR("Shape file contains %d polylines.", number_of_elements); ERR("This programm only handles only files containing points."); SHPClose(hSHP); - return 0; + return EXIT_SUCCESS; } SHPClose(hSHP); } else { @@ -239,9 +229,5 @@ int main (int argc, char* argv[]) ERR("Could not open the database file."); } - delete custom_format; - delete logog_cout; - LOGOG_SHUTDOWN(); - - return 0; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/FileConverter/FEFLOW2OGS.cpp b/Applications/Utils/FileConverter/FEFLOW2OGS.cpp index 69ee3843d28d9454389bd5e996c0023563b79dbc..9b6608ea53fce33da3474a5ccbdde1e517faeafc 100644 --- a/Applications/Utils/FileConverter/FEFLOW2OGS.cpp +++ b/Applications/Utils/FileConverter/FEFLOW2OGS.cpp @@ -7,14 +7,13 @@ * */ -// STL #include <string> +#include <memory> // ThirdParty -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include "Applications/ApplicationsLib/LogogSetup.h" // BaseLib #include "BaseLib/FileTools.h" @@ -22,23 +21,18 @@ #ifndef WIN32 #include "BaseLib/MemWatch.h" #endif -#include "BaseLib/LogogSimpleFormatter.h" // FileIO +#include "FileIO/FEFLOWInterface.h" + #include "MeshLib/IO/writeMeshToFile.h" #include "MeshLib/IO/Legacy/MeshIO.h" -#include "FileIO/FEFLOWInterface.h" #include "MeshLib/IO/VtkIO/VtuInterface.h" - -// MeshLib #include "MeshLib/Mesh.h" int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *const custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Converting a mesh in FEFLOW file format (ASCII, version 5.4) to a vtk unstructured grid file (new OGS file format) or to the old OGS file format - see options.", ' ', "0.1"); @@ -71,11 +65,12 @@ int main (int argc, char* argv[]) BaseLib::RunTime run_time; run_time.start(); FileIO::FEFLOWInterface feflowIO(nullptr); - MeshLib::Mesh const*const mesh(feflowIO.readFEFLOWFile(feflow_mesh_arg.getValue())); + std::unique_ptr<MeshLib::Mesh const> mesh( + feflowIO.readFEFLOWFile(feflow_mesh_arg.getValue())); if (mesh == nullptr) { INFO("Could not read mesh from %s.", feflow_mesh_arg.getValue().c_str()); - return -1; + return EXIT_FAILURE; } #ifndef WIN32 unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); @@ -84,13 +79,10 @@ int main (int argc, char* argv[]) INFO("Time for reading: %f seconds.", run_time.elapsed()); INFO("Read %d nodes and %d elements.", mesh->getNNodes(), mesh->getNElements()); - // *** write mesh in new format std::string ogs_mesh_fname(ogs_mesh_arg.getValue()); INFO("Writing %s.", ogs_mesh_fname.c_str()); MeshLib::IO::writeMeshToFile(*mesh, ogs_mesh_fname); - INFO("\tDone."); - - delete mesh; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/FileConverter/GMSH2OGS.cpp b/Applications/Utils/FileConverter/GMSH2OGS.cpp index 73433fb0e3fc1aadddd9ad55950da564a0937f63..bf62d4c19365544726bd31f8d3cc3feefe462517 100644 --- a/Applications/Utils/FileConverter/GMSH2OGS.cpp +++ b/Applications/Utils/FileConverter/GMSH2OGS.cpp @@ -17,10 +17,9 @@ #include <algorithm> // ThirdParty -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include "Applications/ApplicationsLib/LogogSetup.h" // BaseLib #include "FileTools.h" @@ -28,24 +27,18 @@ #ifndef WIN32 #include "MemWatch.h" #endif -#include "LogogSimpleFormatter.h" // FileIO #include "FileIO/GMSHInterface.h" -#include "MeshLib/IO/Legacy/MeshIO.h" -#include "MeshLib/IO/VtkIO/VtuInterface.h" -// MeshLib +#include "MeshLib/IO/writeMeshToFile.h" #include "MeshLib/MeshSearch/ElementSearch.h" #include "MeshLib/Mesh.h" #include "MeshLib/MeshEditing/RemoveMeshComponents.h" int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *const custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Converting meshes in gmsh file format (ASCII, version 2.2) to a vtk unstructured grid file (new OGS file format) or to the old OGS file format - see options.", ' ', "0.1"); @@ -110,21 +103,7 @@ int main (int argc, char* argv[]) } // *** write mesh in new format - std::string ogs_mesh_fname(ogs_mesh_arg.getValue()); - if (BaseLib::getFileExtension(ogs_mesh_fname).compare("msh") == 0) { - INFO("Writing %s.", ogs_mesh_fname.c_str()); - MeshLib::IO::Legacy::MeshIO mesh_io; - mesh_io.setMesh(mesh); - mesh_io.writeToFile(ogs_mesh_fname); - } else { - if (BaseLib::getFileExtension(ogs_mesh_fname).compare("vtu") != 0) { - ogs_mesh_fname += ".vtu"; - } - INFO("Writing %s.", ogs_mesh_fname.c_str()); - MeshLib::IO::VtuInterface mesh_io(mesh); - mesh_io.writeToFile(ogs_mesh_fname); - } - INFO("\tDone."); + MeshLib::IO::writeMeshToFile(*mesh, ogs_mesh_arg.getValue()); delete mesh; } diff --git a/Applications/Utils/FileConverter/OGS2VTK.cpp b/Applications/Utils/FileConverter/OGS2VTK.cpp index 4b8260390a06cf4e3ef42e2d016e51fcc0b71a69..81fe9d073f9d2f2f84ab0a4364c61e4d86755b1c 100644 --- a/Applications/Utils/FileConverter/OGS2VTK.cpp +++ b/Applications/Utils/FileConverter/OGS2VTK.cpp @@ -11,31 +11,20 @@ * http://www.opengeosys.org/LICENSE.txt */ -// STL #include <string> +#include <memory> -// TCLAP -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include "Applications/ApplicationsLib/LogogSetup.h" -// BaseLib -#include "LogogSimpleFormatter.h" - -// FileIO #include "MeshLib/IO/VtkIO/VtuInterface.h" #include "MeshLib/IO/readMeshFromFile.h" - -// MeshLib -#include "Mesh.h" +#include "MeshLib/Mesh.h" int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Converts OGS mesh into VTK mesh.", ' ', "0.1"); TCLAP::ValueArg<std::string> mesh_in("i", "mesh-input-file", @@ -48,15 +37,12 @@ int main (int argc, char* argv[]) cmd.add(mesh_out); cmd.parse(argc, argv); - MeshLib::Mesh* mesh (MeshLib::IO::readMeshFromFile(mesh_in.getValue())); + std::unique_ptr<MeshLib::Mesh const> mesh( + MeshLib::IO::readMeshFromFile(mesh_in.getValue())); INFO("Mesh read: %d nodes, %d elements.", mesh->getNNodes(), mesh->getNElements()); - MeshLib::IO::VtuInterface vtu(mesh); + MeshLib::IO::VtuInterface vtu(mesh.get()); vtu.writeToFile(mesh_out.getValue()); - delete custom_format; - delete logog_cout; - LOGOG_SHUTDOWN(); - - return 0; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/FileConverter/TIN2VTK.cpp b/Applications/Utils/FileConverter/TIN2VTK.cpp index a839ab5d2fcb4578a52605e449b972a0e3679619..fff58c413c2c93153358ea0786ab7a18601bed70 100644 --- a/Applications/Utils/FileConverter/TIN2VTK.cpp +++ b/Applications/Utils/FileConverter/TIN2VTK.cpp @@ -11,15 +11,12 @@ #include <string> #include <vector> -// TCLAP -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include "Applications/ApplicationsLib/LogogSetup.h" // BaseLib #include "BaseLib/BuildInfo.h" -#include "BaseLib/LogogSimpleFormatter.h" #include "BaseLib/FileTools.h" // GeoLib @@ -28,7 +25,6 @@ #include "GeoLib/PointVec.h" #include "GeoLib/IO/TINInterface.h" -// FileIO #include "MeshLib/IO/VtkIO/VtuInterface.h" // MeshLib @@ -38,10 +34,7 @@ int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Converts TIN file into VTU file.", ' ', BaseLib::BuildInfo::git_describe); TCLAP::ValueArg<std::string> inArg("i", "input-tin-file", @@ -62,7 +55,7 @@ int main (int argc, char* argv[]) std::unique_ptr<GeoLib::Surface> sfc( GeoLib::IO::TINInterface::readTIN(tinFileName, point_vec)); if (!sfc) - return 1; + return EXIT_FAILURE; INFO("TIN read: %d points, %d triangles", pnt_vec->size(), sfc->getNTriangles()); INFO("converting to mesh data"); @@ -73,9 +66,5 @@ int main (int argc, char* argv[]) MeshLib::IO::VtuInterface writer(mesh.get()); writer.writeToFile(outArg.getValue()); - delete custom_format; - delete logog_cout; - LOGOG_SHUTDOWN(); - - return 0; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/FileConverter/VTK2OGS.cpp b/Applications/Utils/FileConverter/VTK2OGS.cpp index 7e902882b705297294d92473fdd8ac057b620fdc..bd5c710d2948f5204faf344a82d855c70dfe2b9f 100644 --- a/Applications/Utils/FileConverter/VTK2OGS.cpp +++ b/Applications/Utils/FileConverter/VTK2OGS.cpp @@ -14,16 +14,10 @@ // STL #include <string> -// TCLAP -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include "Applications/ApplicationsLib/LogogSetup.h" -// BaseLib -#include "LogogSimpleFormatter.h" - -// FileIO #include "MeshLib/IO/VtkIO/VtuInterface.h" #include "MeshLib/Mesh.h" @@ -31,10 +25,7 @@ int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Converts VTK mesh into OGS mesh.", ' ', "0.1"); TCLAP::ValueArg<std::string> mesh_in("i", "mesh-input-file", @@ -54,9 +45,5 @@ int main (int argc, char* argv[]) meshIO.setMesh(mesh); meshIO.writeToFile(mesh_out.getValue()); - delete custom_format; - delete logog_cout; - LOGOG_SHUTDOWN(); - - return 0; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/FileConverter/VTK2TIN.cpp b/Applications/Utils/FileConverter/VTK2TIN.cpp index 5352fc93909f844973d38ed2304261f8b2ef41c1..719693d0486acc57411549c2fc31564109e89919 100644 --- a/Applications/Utils/FileConverter/VTK2TIN.cpp +++ b/Applications/Utils/FileConverter/VTK2TIN.cpp @@ -11,11 +11,9 @@ #include <string> #include <fstream> -// TCLAP -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include "Applications/ApplicationsLib/LogogSetup.h" // BaseLib #include "BaseLib/BuildInfo.h" @@ -32,16 +30,12 @@ #include "MeshLib/Node.h" #include "MeshLib/convertMeshToGeo.h" -// FileIO #include "MeshLib/IO/VtkIO/VtuInterface.h" int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Converts VTK mesh into TIN file.", ' ', BaseLib::BuildInfo::git_describe); TCLAP::ValueArg<std::string> mesh_in("i", "mesh-input-file", @@ -66,9 +60,5 @@ int main (int argc, char* argv[]) mesh_out.getValue()); } - delete custom_format; - delete logog_cout; - LOGOG_SHUTDOWN(); - - return 0; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/FileConverter/generateMatPropsFromMatID.cpp b/Applications/Utils/FileConverter/generateMatPropsFromMatID.cpp index eeb52cb820d03323876e34eccbe3122e76e62d68..bd814b7c7a7eb080b1502239570bca77d56412ac 100644 --- a/Applications/Utils/FileConverter/generateMatPropsFromMatID.cpp +++ b/Applications/Utils/FileConverter/generateMatPropsFromMatID.cpp @@ -14,10 +14,7 @@ #include <memory> -// ThirdParty/logog -#include "logog/include/logog.hpp" - -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" @@ -90,7 +87,6 @@ int main (int argc, char* argv[]) MeshLib::IO::writeMeshToFile(*mesh, new_mshname); INFO("New files \"%s\" and \"%s\" written.", new_mshname.c_str(), new_matname.c_str()); - std::cout << "Conversion finished." << std::endl; return EXIT_SUCCESS; } diff --git a/Applications/Utils/GeoTools/MoveGeometry.cpp b/Applications/Utils/GeoTools/MoveGeometry.cpp index af34d35dffa914b859bb0afbcb02e3b8934b2d87..06a4cef6ce518baca5823304c529ac0f064789f5 100644 --- a/Applications/Utils/GeoTools/MoveGeometry.cpp +++ b/Applications/Utils/GeoTools/MoveGeometry.cpp @@ -12,25 +12,22 @@ */ // ThirdParty -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include "Applications/ApplicationsLib/LogogSetup.h" -#include "BaseLib/LogogSimpleFormatter.h" -#include "MathLib/Vector3.h" #include "GeoLib/IO/XmlIO/Qt/XmlGmlInterface.h" #include "GeoLib/GEOObjects.h" +#include "MathLib/Vector3.h" + #include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); - LOGOG_INITIALIZE(); - logog::Cout *logogCout(new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logogCout->SetFormatter(*custom_format); + + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd ("Moves the points of a geometry by a given displacement vector.", ' ', "0.1"); @@ -55,10 +52,7 @@ int main(int argc, char *argv[]) GeoLib::IO::XmlGmlInterface xml(geo_objects); if (!xml.readFile(geo_input_arg.getValue())) { - delete logogCout; - delete custom_format; - LOGOG_SHUTDOWN(); - return 1; + return EXIT_FAILURE; } MathLib::Vector3 displacement(0.0, 0.0, 0.0); @@ -81,8 +75,5 @@ int main(int argc, char *argv[]) xml.setNameForExport(geo_names[0]); xml.writeToFile(geo_output_arg.getValue()); - delete logogCout; - delete custom_format; - LOGOG_SHUTDOWN(); - return 0; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/GeoTools/TriangulatePolyline.cpp b/Applications/Utils/GeoTools/TriangulatePolyline.cpp index c8249e712b288504cd9e7793b112af040a3e83e3..9c20441a9c69e6059f8b02e9f693dba43cba290a 100644 --- a/Applications/Utils/GeoTools/TriangulatePolyline.cpp +++ b/Applications/Utils/GeoTools/TriangulatePolyline.cpp @@ -13,11 +13,12 @@ #include <string> -#include "logog/include/logog.hpp" -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> + +#include "Applications/ApplicationsLib/LogogSetup.h" #include "BaseLib/BuildInfo.h" -#include "BaseLib/LogogSimpleFormatter.h" + #include "GeoLib/IO/XmlIO/Qt/XmlGmlInterface.h" #include "GeoLib/AnalyticalGeometry.h" #include "GeoLib/GEOObjects.h" @@ -25,7 +26,6 @@ #include <QCoreApplication> - std::string output_question() { WARN ("Given polyline is not closed. Close polyline now?"); @@ -39,10 +39,7 @@ int main(int argc, char *argv[]) { QCoreApplication app(argc, argv, false); - LOGOG_INITIALIZE(); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog::Cout *logogCout(new logog::Cout); - logogCout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Triangulates the specified polyline in the given geometry file.", ' ', BaseLib::BuildInfo::git_describe); TCLAP::ValueArg<std::string> input_arg("i", "input", "GML input file (*.gml)", true, "", "string"); @@ -61,7 +58,7 @@ int main(int argc, char *argv[]) if (!xml.readFile(file_name)) { ERR ("Failed to load geometry file."); - return 1; + return EXIT_FAILURE; } std::vector<std::string> geo_names; @@ -73,14 +70,14 @@ int main(int argc, char *argv[]) if (line == nullptr) { ERR ("No polyline found with name \"%s\". Aborting...", polyline_name.c_str()); - return 1; + return EXIT_FAILURE; } // check if polyline can be triangulated (i.e. closed + coplanar) if (!line->isCoplanar()) { ERR ("Polyline is not coplanar, no unambiguous triangulation possible. Aborting..."); - return 1; + return EXIT_FAILURE; } if (!line->isClosed()) @@ -95,7 +92,7 @@ int main(int argc, char *argv[]) INFO ("Polyline closed."); } else - return 1; + return EXIT_FAILURE; } // create surface @@ -129,8 +126,5 @@ int main(int argc, char *argv[]) xml.writeToFile(output_arg.getValue()); INFO ("...done."); - delete logogCout; - delete custom_format; - LOGOG_SHUTDOWN(); - return 0; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/MeshEdit/AddTopLayer.cpp b/Applications/Utils/MeshEdit/AddTopLayer.cpp index 292f6e5aa90fd105078c420290f9c936e2f38c4f..120ed0fdb722b283d38ec2718c9fec3fd76d1da8 100644 --- a/Applications/Utils/MeshEdit/AddTopLayer.cpp +++ b/Applications/Utils/MeshEdit/AddTopLayer.cpp @@ -11,8 +11,7 @@ #include <memory> -// TCLAP -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" diff --git a/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp b/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp index 474c1cc307405690ed4c3bec5f704258649740cc..c37c992c464f9d9df295cdbb8e02dc1312c2d832 100644 --- a/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp +++ b/Applications/Utils/MeshEdit/CreateBoundaryConditionsAlongPolylines.cpp @@ -14,33 +14,24 @@ #include <vector> #include <fstream> -// TCLAP -#include "tclap/CmdLine.h" - -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" -// BaseLib #include "BaseLib/FileTools.h" -// FileIO #include "MeshLib/IO/readMeshFromFile.h" #include "MeshLib/IO/writeMeshToFile.h" -// GeoLib #include "GeoLib/GEOObjects.h" #include "GeoLib/Point.h" #include "GeoLib/IO/readGeometryFromFile.h" #include "GeoLib/IO/writeGeometryToFile.h" -// MeshLib #include "MeshLib/Mesh.h" #include "MeshLib/Node.h" #include "MeshLib/MeshSurfaceExtraction.h" -// MeshGeoToolsLib #include "MeshGeoToolsLib/MeshNodeSearcher.h" void convertMeshNodesToGeometry(std::vector<MeshLib::Node*> const& nodes, @@ -173,7 +164,8 @@ int main (int argc, char* argv[]) // *** read mesh INFO("Reading mesh \"%s\" ... ", mesh_arg.getValue().c_str()); - MeshLib::Mesh * subsurface_mesh(MeshLib::IO::readMeshFromFile(mesh_arg.getValue())); + std::unique_ptr<MeshLib::Mesh> subsurface_mesh( + MeshLib::IO::readMeshFromFile(mesh_arg.getValue())); INFO("done."); INFO("Extracting top surface of mesh \"%s\" ... ", mesh_arg.getValue().c_str()); @@ -183,8 +175,7 @@ int main (int argc, char* argv[]) MeshLib::MeshSurfaceExtraction::getMeshSurface(*subsurface_mesh, dir, angle)); INFO("done."); - delete subsurface_mesh; - subsurface_mesh = nullptr; + subsurface_mesh.reset(nullptr); // *** read geometry GeoLib::GEOObjects geometries; @@ -203,7 +194,7 @@ int main (int argc, char* argv[]) if (!plys) { ERR("Could not get vector of polylines out of geometry \"%s\".", geo_name.c_str()); - return -1; + return EXIT_FAILURE; } MeshGeoToolsLib::SearchLength search_length_strategy; @@ -230,7 +221,7 @@ int main (int argc, char* argv[]) geometry_sets.getGeometryNames(geo_names); if (geo_names.empty()) { ERR("Did not find mesh nodes along polylines."); - return -1; + return EXIT_FAILURE; } std::string merge_name("AllMeshNodesAlongPolylines"); @@ -289,5 +280,5 @@ int main (int argc, char* argv[]) BaseLib::dropFileExtension(output_base_fname.getValue())); writeBCsAndGeometry(geometry_sets, surface_name, base_fname, bc_type.getValue(), gml_arg.getValue()); - return 0; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/MeshEdit/ExtractSurface.cpp b/Applications/Utils/MeshEdit/ExtractSurface.cpp index 47a36c0907030da99883ce5e7e7c283b4fbe08e4..13e37f4552252ddfb770ef921f00d5a73cda6ca6 100644 --- a/Applications/Utils/MeshEdit/ExtractSurface.cpp +++ b/Applications/Utils/MeshEdit/ExtractSurface.cpp @@ -13,7 +13,7 @@ #include <string> #include <vector> -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" diff --git a/Applications/Utils/MeshEdit/MapGeometryToMeshSurface.cpp b/Applications/Utils/MeshEdit/MapGeometryToMeshSurface.cpp index 2f909691a4581a14466730c440c6a8616fca07bf..f93acc2c33bf4b8080b49fdb6d12a704dddf0e94 100644 --- a/Applications/Utils/MeshEdit/MapGeometryToMeshSurface.cpp +++ b/Applications/Utils/MeshEdit/MapGeometryToMeshSurface.cpp @@ -13,34 +13,21 @@ #include <cstdlib> #include <vector> -// TCLAP -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include "Applications/ApplicationsLib/LogogSetup.h" -// BaseLib -#include "BaseLib/LogogSimpleFormatter.h" - -// FileIO -#include "MeshLib/IO/readMeshFromFile.h" -#include "GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h" - -// GeoLib #include "GeoLib/GEOObjects.h" +#include "GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h" -// MeshLib #include "MeshLib/Mesh.h" +#include "MeshLib/IO/readMeshFromFile.h" -// MeshGeoToolsLib #include "MeshGeoToolsLib/GeoMapper.h" int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Maps geometric objects to the surface of a given mesh." "The documentation is available at https://docs.opengeosys.org/docs/tools/model-preparation/map-geometric-object-to-the-surface-of-a-mesh", diff --git a/Applications/Utils/MeshEdit/MoveMesh.cpp b/Applications/Utils/MeshEdit/MoveMesh.cpp index 88d0234492435157870c52d62b544a4ae226c137..036ce08d67f0a13f3edafa77e1e82e439a8c79e7 100644 --- a/Applications/Utils/MeshEdit/MoveMesh.cpp +++ b/Applications/Utils/MeshEdit/MoveMesh.cpp @@ -10,36 +10,26 @@ * http://www.opengeosys.org/project/license */ -// ThirdParty -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include "Applications/ApplicationsLib/LogogSetup.h" -// BaseLib -#include "StringTools.h" -#include "FileTools.h" -#include "LogogSimpleFormatter.h" +#include "BaseLib/StringTools.h" +#include "BaseLib/FileTools.h" -// FileIO #include "MeshLib/IO/readMeshFromFile.h" -#include "MeshLib/IO/VtkIO/VtuInterface.h" +#include "MeshLib/IO/writeMeshToFile.h" -// GeoLib -#include "AABB.h" +#include "GeoLib/AABB.h" -// MeshLib #include "MeshLib/Node.h" -#include "Elements/Element.h" -#include "MeshEditing/moveMeshNodes.h" -#include "Mesh.h" +#include "MeshLib/Elements/Element.h" +#include "MeshLib/MeshEditing/moveMeshNodes.h" +#include "MeshLib/Mesh.h" int main(int argc, char *argv[]) { - LOGOG_INITIALIZE(); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog::Cout *logogCout(new logog::Cout); - logogCout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Moves the mesh nodes using the given displacement vector or if no displacement vector is given, moves the mesh nodes such that the centroid of the given mesh is in the origin.", ' ', "0.1"); // Define a value argument and add it to the command line. @@ -65,7 +55,12 @@ int main(int argc, char *argv[]) std::string fname (mesh_arg.getValue()); - MeshLib::Mesh* mesh = MeshLib::IO::readMeshFromFile(fname); + std::unique_ptr<MeshLib::Mesh> mesh(MeshLib::IO::readMeshFromFile(fname)); + + if (!mesh) { + ERR("Could not read mesh from file \"%s\".", fname.c_str()); + return EXIT_FAILURE; + } MeshLib::Node displacement(0.0, 0.0, 0.0); if (fabs(x_arg.getValue()) < std::numeric_limits<double>::epsilon() @@ -81,11 +76,12 @@ int main(int argc, char *argv[]) displacement[2] = z_arg.getValue(); } - INFO("translate model (%f, %f, %f).", displacement[0], displacement[1], displacement[2]); + INFO("translate model (%f, %f, %f).", + displacement[0], + displacement[1], + displacement[2]); MeshLib::moveMeshNodes( - mesh->getNodes().begin(), - mesh->getNodes().end(), - displacement); + mesh->getNodes().begin(), mesh->getNodes().end(), displacement); std::string out_fname(mesh_out_arg.getValue()); if (out_fname.empty()) { @@ -93,13 +89,7 @@ int main(int argc, char *argv[]) out_fname += "_displaced.vtu"; } - MeshLib::IO::VtuInterface mesh_io(mesh); - mesh_io.writeToFile(out_fname); + MeshLib::IO::writeMeshToFile(*mesh, out_fname); - delete mesh; - delete logogCout; - delete custom_format; - LOGOG_SHUTDOWN(); + return EXIT_SUCCESS; } - - diff --git a/Applications/Utils/MeshEdit/NodeReordering.cpp b/Applications/Utils/MeshEdit/NodeReordering.cpp index ecaf4d2d9410483dd76121c68bd768bc6f2d3951..59ac3989807d958e3069ba827a7144c65dec8236 100644 --- a/Applications/Utils/MeshEdit/NodeReordering.cpp +++ b/Applications/Utils/MeshEdit/NodeReordering.cpp @@ -14,7 +14,7 @@ #include <memory> #include <vector> -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" diff --git a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp index b2fd9a3f821176809357b4fc456f5303a670c97b..f37eddaccaab140f800a4a37af29d0f69a8ee5bb 100644 --- a/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp +++ b/Applications/Utils/MeshEdit/ResetPropertiesInPolygonalRegion.cpp @@ -13,30 +13,21 @@ #include <cstdlib> #include <vector> -// TCLAP -#include "tclap/CmdLine.h" - -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" -// FileIO #include "MeshLib/IO/readMeshFromFile.h" #include "MeshLib/IO/writeMeshToFile.h" -// GeoLib +#include "GeoLib/AnalyticalGeometry.h" #include "GeoLib/GEOObjects.h" #include "GeoLib/Polygon.h" -#include "GeoLib/AnalyticalGeometry.h" - #include "GeoLib/IO/readGeometryFromFile.h" -// MathLib #include "MathLib/Vector3.h" #include "MathLib/LinAlg/Dense/DenseMatrix.h" -// MeshLib #include "MeshLib/Mesh.h" #include "MeshLib/Node.h" #include "MeshLib/Elements/Element.h" diff --git a/Applications/Utils/MeshEdit/appendLinesAlongPolyline.cpp b/Applications/Utils/MeshEdit/appendLinesAlongPolyline.cpp index 28ae467f359639d89616269c91aaad4f81e72cbb..19fbf36ea9dfe790370006f516a1844289352018 100644 --- a/Applications/Utils/MeshEdit/appendLinesAlongPolyline.cpp +++ b/Applications/Utils/MeshEdit/appendLinesAlongPolyline.cpp @@ -6,38 +6,25 @@ * http://www.opengeosys.org/LICENSE.txt */ -// TCLAP -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include "Applications/ApplicationsLib/LogogSetup.h" -// BaseLib -#include "LogogSimpleFormatter.h" -#include "FileTools.h" +#include "BaseLib/FileTools.h" -// GeoLib -#include "GEOObjects.h" -#include "PolylineVec.h" - -// FileIO -#include "MeshLib/IO/Legacy/MeshIO.h" -#include "MeshLib/IO/readMeshFromFile.h" +#include "GeoLib/GEOObjects.h" +#include "GeoLib/PolylineVec.h" #include "GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h" -// MeshLib -#include "Mesh.h" - -// MeshGeoToolsLib #include "MeshGeoToolsLib/AppendLinesAlongPolyline.h" +#include "MeshLib/IO/writeMeshToFile.h" +#include "MeshLib/IO/readMeshFromFile.h" +#include "MeshLib/Mesh.h" int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Append line elements into a mesh.", ' ', "0.1"); TCLAP::ValueArg<std::string> mesh_in("i", "mesh-input-file", @@ -64,22 +51,23 @@ int main (int argc, char* argv[]) geo_objs.getGeometryNames (geo_names); if (geo_names.empty ()) { - std::cout << "no geometries found" << std::endl; - return -1; + ERR("No geometries found."); + return EXIT_FAILURE; } const GeoLib::PolylineVec* ply_vec (geo_objs.getPolylineVecObj(geo_names[0])); if (!ply_vec) { - std::cout << "could not found polylines" << std::endl; - return -1; + ERR("Could not find polylines in geometry \"%s\".", + geo_names.front().c_str()); + return EXIT_FAILURE; } // read a mesh MeshLib::Mesh const*const mesh (MeshLib::IO::readMeshFromFile(mesh_in.getValue())); if (!mesh) { - ERR("Mesh file %s not found", mesh_in.getValue().c_str()); - return 1; + ERR("Mesh file \"%s\" not found", mesh_in.getValue().c_str()); + return EXIT_FAILURE; } INFO("Mesh read: %d nodes, %d elements.", mesh->getNNodes(), mesh->getNElements()); @@ -88,15 +76,7 @@ int main (int argc, char* argv[]) MeshGeoToolsLib::appendLinesAlongPolylines(*mesh, *ply_vec); INFO("Mesh created: %d nodes, %d elements.", new_mesh->getNNodes(), new_mesh->getNElements()); - // write into a file - MeshLib::IO::Legacy::MeshIO meshIO; - meshIO.setMesh(new_mesh.get()); - meshIO.writeToFile(mesh_out.getValue()); - - delete custom_format; - delete logog_cout; - LOGOG_SHUTDOWN(); + MeshLib::IO::writeMeshToFile(*new_mesh, mesh_out.getValue()); - return 1; + return EXIT_SUCCESS; } - diff --git a/Applications/Utils/MeshEdit/checkMesh.cpp b/Applications/Utils/MeshEdit/checkMesh.cpp index 3ea4a976220442afa7c5bb9d471ab68f41e6d583..3bcfb28755bfd021c3641a3b8ac3bbf8ff5f34bb 100644 --- a/Applications/Utils/MeshEdit/checkMesh.cpp +++ b/Applications/Utils/MeshEdit/checkMesh.cpp @@ -9,14 +9,14 @@ #include <array> #include <string> -#include "logog/include/logog.hpp" -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> + +#include "Applications/ApplicationsLib/LogogSetup.h" #include "BaseLib/BuildInfo.h" #include "BaseLib/StringTools.h" #include "BaseLib/MemWatch.h" #include "BaseLib/RunTime.h" -#include "BaseLib/LogogSimpleFormatter.h" #include "BaseLib/FileTools.h" #include "GeoLib/AABB.h" @@ -28,14 +28,10 @@ #include "MeshLib/MeshQuality/MeshValidation.h" #include "MeshLib/IO/readMeshFromFile.h" -#include "MeshLib/IO/Legacy/MeshIO.h" int main(int argc, char *argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Checks mesh properties", ' ', BaseLib::BuildInfo::git_describe); TCLAP::UnlabeledValueArg<std::string> mesh_arg("mesh-file","input mesh file",true,"","string"); @@ -47,16 +43,15 @@ int main(int argc, char *argv[]) cmd.parse( argc, argv ); - const std::string filename(mesh_arg.getValue()); - // read the mesh file BaseLib::MemWatch mem_watch; const unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); BaseLib::RunTime run_time; run_time.start(); - const MeshLib::Mesh* mesh = MeshLib::IO::readMeshFromFile(filename); // FileIO outputs nr. of nodes and elements + std::unique_ptr<MeshLib::Mesh> mesh( + MeshLib::IO::readMeshFromFile(mesh_arg.getValue())); if (!mesh) - return 1; + return EXIT_FAILURE; const unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); if (mem_with_mesh>0) @@ -104,9 +99,9 @@ int main(int argc, char *argv[]) } if (valid_arg.isSet()) { - // Validation - MeshLib::MeshValidation validation(*const_cast<MeshLib::Mesh*>(mesh)); // MeshValidation outputs error messages - /* Remark: MeshValidation can modify the original mesh */ + // MeshValidation outputs error messages + // Remark: MeshValidation can modify the original mesh + MeshLib::MeshValidation validation(*mesh); unsigned const n_holes (MeshLib::MeshValidation::detectHoles(*mesh)); if (n_holes > 0) @@ -116,9 +111,4 @@ int main(int argc, char *argv[]) else INFO ("No holes found within the mesh."); } - - delete mesh; - delete custom_format; - delete logog_cout; - LOGOG_SHUTDOWN(); } diff --git a/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp b/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp index a1fe56fbc82eea71d9666592624e27c250a2694a..04c6571f7c7681c372f1cc6e22e643762dad19da 100644 --- a/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp +++ b/Applications/Utils/MeshEdit/createLayeredMeshFromRasters.cpp @@ -16,7 +16,7 @@ #include <string> #include <vector> -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" diff --git a/Applications/Utils/MeshEdit/editMaterialID.cpp b/Applications/Utils/MeshEdit/editMaterialID.cpp index 2ee57872e9b56b63c88db817698ad06478ec67e7..d25569e6ef64378fba3f3646297e394d592170ca 100644 --- a/Applications/Utils/MeshEdit/editMaterialID.cpp +++ b/Applications/Utils/MeshEdit/editMaterialID.cpp @@ -6,31 +6,21 @@ * http://www.opengeosys.org/LICENSE.txt */ -// TCLAP -#include "tclap/CmdLine.h" +#include <memory> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include <tclap/CmdLine.h> -// BaseLib -#include "BaseLib/LogogSimpleFormatter.h" +#include "Applications/ApplicationsLib/LogogSetup.h" -// FileIO -#include "MeshLib/IO/Legacy/MeshIO.h" #include "MeshLib/IO/readMeshFromFile.h" #include "MeshLib/IO/writeMeshToFile.h" - -// MeshLib #include "MeshLib/Mesh.h" #include "MeshLib/Elements/Element.h" #include "MeshLib/MeshEditing/ElementValueModification.h" int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Edit material IDs of mesh elements.", ' ', "0.1"); TCLAP::SwitchArg replaceArg("r", "replace", "replace material IDs", false); @@ -81,7 +71,8 @@ int main (int argc, char* argv[]) } } - MeshLib::Mesh* mesh (MeshLib::IO::readMeshFromFile(mesh_in.getValue())); + std::unique_ptr<MeshLib::Mesh> mesh( + MeshLib::IO::readMeshFromFile(mesh_in.getValue())); INFO("Mesh read: %d nodes, %d elements.", mesh->getNNodes(), mesh->getNElements()); if (condenseArg.isSet()) { @@ -104,13 +95,7 @@ int main (int argc, char* argv[]) INFO("updated %d elements", cnt); } - // write into a file MeshLib::IO::writeMeshToFile(*mesh, mesh_out.getValue()); - delete custom_format; - delete logog_cout; - LOGOG_SHUTDOWN(); - - return 0; + return EXIT_SUCCESS; } - diff --git a/Applications/Utils/MeshEdit/moveMeshNodes.cpp b/Applications/Utils/MeshEdit/moveMeshNodes.cpp index 5613c653b3d7371bed2d7575040e19f815f1ced8..fee56c48dd40904e25840211cb393e8fa687278f 100644 --- a/Applications/Utils/MeshEdit/moveMeshNodes.cpp +++ b/Applications/Utils/MeshEdit/moveMeshNodes.cpp @@ -1,16 +1,26 @@ /** * \file moveMeshNodes.cpp * 2012/03/07 KR Initial implementation + * + * \copyright + * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/LICENSE.txt */ -#include "logog/include/logog.hpp" -#include "LogogSimpleFormatter.h" +#include <memory> + +#include "Applications/ApplicationsLib/LogogSetup.h" + +#include "GeoLib/AABB.h" + #include "MeshLib/IO/readMeshFromFile.h" -#include "MeshLib/IO/Legacy/MeshIO.h" -#include "AABB.h" -#include "Mesh.h" +#include "MeshLib/IO/writeMeshToFile.h" +#include "MeshLib/Mesh.h" #include "MeshLib/Node.h" -#include "MathTools.h" + +#include "MathLib/MathTools.h" int find_closest_point(MeshLib::Node const*const point, std::vector<MeshLib::Node*> const& nodes, double const& max_dist) { @@ -46,10 +56,7 @@ bool containsPoint(MeshLib::Node const& pnt, MathLib::Point3d const& min, int main (int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logogCout = new logog::Cout; - BaseLib::LogogSimpleFormatter* formatter = new BaseLib::LogogSimpleFormatter; - logogCout->SetFormatter(*formatter); + ApplicationsLib::LogogSetup logog_setup; std::vector<std::string> keywords; keywords.push_back("-ALL"); @@ -97,7 +104,8 @@ int main (int argc, char* argv[]) return -1; } - MeshLib::Mesh* mesh (MeshLib::IO::readMeshFromFile(msh_name)); + std::unique_ptr<MeshLib::Mesh> mesh( + MeshLib::IO::readMeshFromFile(msh_name)); //std::vector<std::size_t> del_nodes; // Start keyword-specific selection of nodes @@ -183,11 +191,8 @@ int main (int argc, char* argv[]) } /**** add other keywords here ****/ - MeshLib::IO::Legacy::MeshIO meshIO; - meshIO.setMesh(mesh); - meshIO.setPrecision(9); - meshIO.writeToFile(msh_name.substr(0, msh_name.length()-4) + "_new.msh"); - delete mesh; + MeshLib::IO::writeMeshToFile( + *mesh, msh_name.substr(0, msh_name.length() - 4) + "_new.msh"); return 1; } diff --git a/Applications/Utils/MeshEdit/queryMesh.cpp b/Applications/Utils/MeshEdit/queryMesh.cpp index 3ee7f9e2f467d9ff08e780e6b05142a344d7a88f..767d6583acb3705b98da2a06a9c2b238465daebd 100644 --- a/Applications/Utils/MeshEdit/queryMesh.cpp +++ b/Applications/Utils/MeshEdit/queryMesh.cpp @@ -8,10 +8,10 @@ #include <array> #include <memory> +#include <sstream> #include <string> -#include "logog/include/logog.hpp" -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" @@ -22,7 +22,6 @@ #include "MeshLib/Node.h" #include "MeshLib/Elements/Element.h" #include "MeshLib/Mesh.h" - #include "MeshLib/IO/readMeshFromFile.h" int main(int argc, char *argv[]) @@ -49,39 +48,46 @@ int main(int argc, char *argv[]) auto materialIds = mesh->getProperties().getPropertyVector<int>("MaterialIDs"); - std::cout << std::scientific << std::setprecision(12); for (auto ele_id : eleId_arg.getValue()) { - std::cout << "--------------------------------------------------------" << std::endl; + std::stringstream out; + out << std::scientific + << std::setprecision(std::numeric_limits<double>::digits10); + out << "--------------------------------------------------------" << std::endl; auto* ele = mesh->getElement(ele_id); - std::cout << "# Element " << ele->getID() << std::endl; - std::cout << "Type : " << CellType2String(ele->getCellType()) << std::endl; + out << "# Element " << ele->getID() << std::endl; + out << "Type : " << CellType2String(ele->getCellType()) << std::endl; if (materialIds) - std::cout << "Mat ID : " << (*materialIds)[ele_id] << std::endl; - std::cout << "Nodes: " << std::endl; + out << "Mat ID : " << (*materialIds)[ele_id] << std::endl; + out << "Nodes: " << std::endl; for (unsigned i=0; i<ele->getNNodes(); i++) - std::cout << ele->getNode(i)->getID() << " " << *ele->getNode(i) << std::endl; - std::cout << "Content: " << ele->getContent() << std::endl; - std::cout << "Neighbors: "; + out << ele->getNode(i)->getID() << " " << *ele->getNode(i) << std::endl; + out << "Content: " << ele->getContent() << std::endl; + out << "Neighbors: "; for (unsigned i=0; i<ele->getNNeighbors(); i++) { if (ele->getNeighbor(i)) - std::cout << ele->getNeighbor(i)->getID() << " "; + out << ele->getNeighbor(i)->getID() << " "; else - std::cout << "none "; + out << "none "; } - std::cout << std::endl; + out << std::endl; + INFO("%s", out.str().c_str()); } for (auto node_id : nodeId_arg.getValue()) { - std::cout << "--------------------------------------------------------" << std::endl; + std::stringstream out; + out << std::scientific + << std::setprecision(std::numeric_limits<double>::digits10); + out << "--------------------------------------------------------" << std::endl; auto* node = mesh->getNode(node_id); - std::cout << "# Node" << node->getID() << std::endl; - std::cout << "Coordinates: " << *node << std::endl; - std::cout << "Connected elements: " ; + out << "# Node" << node->getID() << std::endl; + out << "Coordinates: " << *node << std::endl; + out << "Connected elements: " ; for (unsigned i=0; i<node->getNElements(); i++) - std::cout << node->getElement(i)->getID() << " "; - std::cout << std::endl; + out << node->getElement(i)->getID() << " "; + out << std::endl; + INFO("%s", out.str().c_str()); } } diff --git a/Applications/Utils/MeshEdit/removeMeshElements.cpp b/Applications/Utils/MeshEdit/removeMeshElements.cpp index 4a81ec112c28dd8fd9a0f894fdde450ca6075889..2a969d75e3ca89b81dad7f444735949beb7219b5 100644 --- a/Applications/Utils/MeshEdit/removeMeshElements.cpp +++ b/Applications/Utils/MeshEdit/removeMeshElements.cpp @@ -13,8 +13,7 @@ #include <memory> -// TCLAP -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" diff --git a/Applications/Utils/MeshEdit/reviseMesh.cpp b/Applications/Utils/MeshEdit/reviseMesh.cpp index 3666a58e07a11fe0fd8817bcf64b5e33519b8206..01d132ae2ac298c4dff78203b9923bd6f0249074 100644 --- a/Applications/Utils/MeshEdit/reviseMesh.cpp +++ b/Applications/Utils/MeshEdit/reviseMesh.cpp @@ -8,14 +8,15 @@ */ #include <array> +#include <memory> #include <string> -#include "logog/include/logog.hpp" -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> + +#include "Applications/ApplicationsLib/LogogSetup.h" #include "BaseLib/BuildInfo.h" #include "BaseLib/StringTools.h" -#include "BaseLib/LogogSimpleFormatter.h" #include "BaseLib/FileTools.h" #include "MeshLib/Node.h" @@ -28,10 +29,7 @@ int main(int argc, char *argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logog_cout (new logog::Cout); - BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); - logog_cout->SetFormatter(*custom_format); + ApplicationsLib::LogogSetup logog_setup; TCLAP::CmdLine cmd("Mesh revision tool", ' ', BaseLib::BuildInfo::git_describe); TCLAP::ValueArg<std::string> input_arg("i", "input-mesh-file","input mesh file",true,"","string"); @@ -49,18 +47,20 @@ int main(int argc, char *argv[]) cmd.parse( argc, argv ); // read a mesh file - MeshLib::Mesh* org_mesh (MeshLib::IO::readMeshFromFile(input_arg.getValue())); + std::unique_ptr<MeshLib::Mesh> org_mesh( + MeshLib::IO::readMeshFromFile(input_arg.getValue())); if (!org_mesh) - return 0; + return EXIT_FAILURE; INFO("Mesh read: %d nodes, %d elements.", org_mesh->getNNodes(), org_mesh->getNElements()); // revise the mesh - MeshLib::Mesh* new_mesh = nullptr; + std::unique_ptr<MeshLib::Mesh> new_mesh; if (simplify_arg.getValue()) { INFO("Simplifying the mesh..."); MeshLib::MeshRevision rev(const_cast<MeshLib::Mesh&>(*org_mesh)); unsigned int minDim = (minDim_arg.isSet() ? minDim_arg.getValue() : org_mesh->getDimension()); - new_mesh = rev.simplifyMesh("revised_mesh", eps_arg.getValue(), minDim); + new_mesh.reset( + rev.simplifyMesh("revised_mesh", eps_arg.getValue(), minDim)); } // write into a file @@ -69,12 +69,5 @@ int main(int argc, char *argv[]) MeshLib::IO::writeMeshToFile(*new_mesh, output_arg.getValue()); } - delete org_mesh; - delete new_mesh; - - delete custom_format; - delete logog_cout; - LOGOG_SHUTDOWN(); - - return 0; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/MeshGeoTools/ComputeSurfaceNodeIDsInPolygonalRegion.cpp b/Applications/Utils/MeshGeoTools/ComputeSurfaceNodeIDsInPolygonalRegion.cpp index 8c022d63e1155cb6b3296913795b27a2a31b21f0..b44d630867c902bea7784f4719ba8429b7413df0 100644 --- a/Applications/Utils/MeshGeoTools/ComputeSurfaceNodeIDsInPolygonalRegion.cpp +++ b/Applications/Utils/MeshGeoTools/ComputeSurfaceNodeIDsInPolygonalRegion.cpp @@ -14,7 +14,7 @@ #include <string> #include <vector> -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" diff --git a/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp b/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp index 0d2725d0b4a55978c6e2ce6a7f7d31b3e7d9b49d..69bf18bc847c0ed6162835dda431caf0b2da5eaf 100644 --- a/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp +++ b/Applications/Utils/ModelPreparation/ComputeNodeAreasFromSurfaceMesh.cpp @@ -14,7 +14,7 @@ #include <string> #include <vector> -#include "tclap/CmdLine.h" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" diff --git a/Applications/Utils/OGSFileConverter/main.cpp b/Applications/Utils/OGSFileConverter/main.cpp index 7072eea448c7ecd73afc4ee9aa56d0e3a89ef86b..593542373b2526df825045a8c91331baf06b7623 100644 --- a/Applications/Utils/OGSFileConverter/main.cpp +++ b/Applications/Utils/OGSFileConverter/main.cpp @@ -1,18 +1,23 @@ +/** + * + * \copyright + * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/LICENSE.txt + */ + #include "OGSFileConverter.h" #include <clocale> -#include "logog/include/logog.hpp" -#include "LogogSimpleFormatter.h" +#include "Applications/ApplicationsLib/LogogSetup.h" #include <QtGui/QApplication> int main(int argc, char* argv[]) { - LOGOG_INITIALIZE(); - logog::Cout* logogCout = new logog::Cout; - BaseLib::LogogSimpleFormatter* formatter = new BaseLib::LogogSimpleFormatter; - logogCout->SetFormatter(*formatter); + ApplicationsLib::LogogSetup logog_setup; QApplication app(argc, argv); setlocale(LC_NUMERIC,"C"); @@ -22,9 +27,5 @@ int main(int argc, char* argv[]) int returncode = app.exec(); delete fc; - delete formatter; - delete logogCout; - LOGOG_SHUTDOWN(); - return returncode; } diff --git a/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp b/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp index c0c7f909614aae6b76380623fbfd6239701d3b3b..d75fdc3b9b00d751bafdb608c4e5c36738070e80 100644 --- a/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp +++ b/Applications/Utils/SimpleMeshCreation/createMeshElemPropertiesFromASCRaster.cpp @@ -14,7 +14,6 @@ #include <numeric> #include <tclap/CmdLine.h> -#include <logog/include/logog.hpp> #include "Applications/ApplicationsLib/LogogSetup.h" @@ -216,7 +215,7 @@ int main (int argc, char* argv[]) if (!property_out) { ERR("Could not open file %s for writing the mapping.", property_fname.c_str()); - return -1; + return EXIT_FAILURE; } for (std::size_t k(0); k < n_dest_mesh_elements; k++) @@ -245,5 +244,5 @@ int main (int argc, char* argv[]) MeshLib::IO::writeMeshToFile(*dest_mesh, out_mesh_arg.getValue()); } - return 0; + return EXIT_SUCCESS; } diff --git a/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp b/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp index d1fa6efe7c90c5b643fd5a7d2d7b2685280aea00..d64d60e9868b632a219c4c5ab00d790ce02c89eb 100644 --- a/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp +++ b/Applications/Utils/SimpleMeshCreation/generateStructuredMesh.cpp @@ -11,11 +11,7 @@ #include <string> #include <vector> -// TCLAP -#include "tclap/CmdLine.h" - -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include <tclap/CmdLine.h> #include "Applications/ApplicationsLib/LogogSetup.h" @@ -157,12 +153,12 @@ int main (int argc, char* argv[]) [&](TCLAP::ValueArg<double> *arg){return arg->isSet();}); if (!isLengthSet) { ERR("Missing input: Length information is not provided at all."); - return 1; + return EXIT_FAILURE; } else { for (unsigned i=0; i<3; i++) { if (dim_used[i] && !vec_lengthArg[i]->isSet()) { ERR("Missing input: Length for dimension [%d] is required but missing.", i); - return 1; + return EXIT_FAILURE; } } } @@ -223,6 +219,6 @@ int main (int argc, char* argv[]) MeshLib::IO::writeMeshToFile(*(mesh.get()), mesh_out.getValue()); } - return 0; + return EXIT_SUCCESS; }