Wildmeshing Toolkit
get_all_meshes.cpp
Go to the documentation of this file.
1 #include "get_all_meshes.hpp"
2 
3 
5 
6 #include <wmtk/utils/Logger.hpp>
7 
8 #include <wmtk/EdgeMesh.hpp>
9 #include <wmtk/Mesh.hpp>
10 #include <wmtk/PointMesh.hpp>
11 #include <wmtk/TetMesh.hpp>
12 #include <wmtk/TriMesh.hpp>
14 
15 namespace wmtk::components {
16 
17 void get_all_meshes(const utils::Paths& paths, const nlohmann::json& j, io::Cache& cache)
18 {
19  using namespace internal;
20 
21  GetAllMeshesOptions options = j.get<GetAllMeshesOptions>();
22 
23  std::shared_ptr<Mesh> mesh_in = cache.read_mesh(options.input);
24 
25  auto get_all = [&](auto&& m) {
26  const std::string name =
27  fmt::format("{}_{}", options.name, fmt::join(m.absolute_multi_mesh_id(), ""));
28  logger().info("Exporting {}", name);
29  cache.write_mesh(*m.shared_from_this(), name);
30  };
31  multimesh::MultiMeshVisitor visitor(get_all);
32  visitor.execute_from_root(*mesh_in);
33 }
34 
35 } // namespace wmtk::components
void write_mesh(const Mesh &m, const std::string &name, const std::map< std::string, std::vector< int64_t >> &multimesh_names={})
Write a mesh to cache.
Definition: Cache.cpp:194
std::shared_ptr< Mesh > read_mesh(const std::string &name) const
Load a mesh from cache.
Definition: Cache.cpp:171
void get_all_meshes(const utils::Paths &paths, const nlohmann::json &j, io::Cache &cache)
spdlog::logger & logger()
Retrieves the current logger.
Definition: Logger.cpp:58
nlohmann::json json
Definition: input.cpp:9