diff --git a/Applications/Utils/MeshEdit/CMakeLists.txt b/Applications/Utils/MeshEdit/CMakeLists.txt index 829c51c6f952fcabda75556e4736715b6ca3bd1d..8e9a765551c0c6e9f28a685813e6094dda34a91c 100644 --- a/Applications/Utils/MeshEdit/CMakeLists.txt +++ b/Applications/Utils/MeshEdit/CMakeLists.txt @@ -89,7 +89,7 @@ add_executable(convertToLinearMesh convertToLinearMesh.cpp ) target_link_libraries(convertToLinearMesh MeshLib) set_target_properties(convertToLinearMesh PROPERTIES FOLDER Utilities) -add_executable(UnityPreprocessing UnityPreprocessing.cpp ) +add_executable(UnityPreprocessing UnityPreprocessing.cpp) target_link_libraries(UnityPreprocessing MeshLib) set_target_properties(UnityPreprocessing PROPERTIES FOLDER Utilities) diff --git a/Applications/Utils/MeshEdit/UnityPreprocessing.cpp b/Applications/Utils/MeshEdit/UnityPreprocessing.cpp index 3eaf2474f2ce6122f2a062ba6ee20ac396b5c9b4..a3788cfa1e94ec797fd1c0ebdd8a1068d54e0960 100644 --- a/Applications/Utils/MeshEdit/UnityPreprocessing.cpp +++ b/Applications/Utils/MeshEdit/UnityPreprocessing.cpp @@ -123,7 +123,6 @@ MeshLib::Mesh* constructMesh(MeshLib::Mesh const& mesh) { INFO("Splitting nodes...") std::vector<MeshLib::Element*> const& elems = mesh.getElements(); - std::size_t const n_elems (elems.size()); std::vector<MeshLib::Node*> new_nodes; std::vector<MeshLib::Element*> new_elems; std::vector<std::vector<std::size_t>> node_map; @@ -179,7 +178,7 @@ int main (int argc, char* argv[]) cmd.parse(argc, argv); INFO("Reading mesh \"%s\" ... ", mesh_arg.getValue().c_str()); - MeshLib::Mesh* mesh = MeshLib::IO::readMeshFromFile(mesh_arg.getValue()); + std::unique_ptr<MeshLib::Mesh> mesh {MeshLib::IO::readMeshFromFile(mesh_arg.getValue())}; if (!mesh) return EXIT_FAILURE; INFO("done.\n"); @@ -187,33 +186,33 @@ int main (int argc, char* argv[]) INFO("Checking for line elements...") std::array<unsigned, 7> const& n_element_types = MeshLib::MeshInformation::getNumberOfElementTypes(*mesh); - MeshLib::Mesh* result; + std::unique_ptr<MeshLib::Mesh> result; if (n_element_types[0] == 0) { INFO ("No line elements found.\n"); - result = mesh; + result = std::move(mesh); } else if (n_element_types[0] == mesh->getNumberOfElements()) { INFO ("Keeping line mesh.\n"); - result = mesh; + result = std::move(mesh); } else { MeshLib::ElementSearch searcher(*mesh); std::size_t const n_rem_elems = searcher.searchByElementType(MeshLib::MeshElemType::LINE); - result = MeshLib::removeElements(*mesh, searcher.getSearchedElementIDs(), "temp mesh"); + result.reset(MeshLib::removeElements(*mesh, searcher.getSearchedElementIDs(), "temp mesh")); INFO ("%d line elements found and removed.\n", n_rem_elems); } INFO("Checking for cell-arrays..."); if (containsCellVecs(*result)) - result = constructMesh(*result); + result.reset(constructMesh(*result)); else INFO("No cell arrays found, keeping mesh structure.\n"); INFO("Writing mesh \"%s\" ... ", mesh_out_arg.getValue().c_str()); - MeshLib::IO::VtuInterface writer(result, vtkXMLWriter::Ascii, false); + MeshLib::IO::VtuInterface writer(result.get(), vtkXMLWriter::Ascii, false); writer.writeToFile(mesh_out_arg.getValue()); INFO("done.");