Wildmeshing Toolkit
Loading...
Searching...
No Matches
OutputOptions.cpp
Go to the documentation of this file.
1
2#include "OutputOptions.hpp"
3#include <fmt/std.h>
4#include <wmtk/Mesh.hpp>
7
8
10
12{
14 if (nlohmann_json_t.mesh_name_path.has_value()) {
15 nlohmann_json_j["mesh_name_path"] = nlohmann_json_t.mesh_name_path.value();
16 }
17 //
18 // nlohmann_json_j["file"] = nlohmann_json_t.file.string();
19
20 // nlohmann_json_j["type"] = nlohmann_json_t.type;
21
22 nlohmann_json_j["position_attribute"] = std::visit(
23 [](const auto& attr) -> std::string {
24 using T = std::decay_t<decltype(attr)>;
25 if constexpr (std::is_same_v<std::string, T>) {
26 return attr;
27 } else {
28 return attr.mesh().get_attribute_name(attr.handle());
29 }
30 },
31 nlohmann_json_t.position_attribute);
32}
34{
35 if (nlohmann_json_j.is_string()) {
36 nlohmann_json_t.file = nlohmann_json_j.get<std::filesystem::path>();
37 } else {
38 nlohmann_json_t.file = nlohmann_json_j["file"].get<std::filesystem::path>();
39 }
40 if (nlohmann_json_j.contains("type")) {
41 nlohmann_json_t.type = nlohmann_json_j["type"];
42 } else {
43 nlohmann_json_t.type = nlohmann_json_t.file.extension().string();
44 wmtk::logger().debug(
45 "Guessing extension type of [{}] is [{}]",
46 nlohmann_json_t.file,
47 nlohmann_json_t.type);
48 }
49 if (nlohmann_json_j.contains("position_attribute")) {
50 nlohmann_json_t.position_attribute = nlohmann_json_j["position_attribute"];
51 }
52
53 if (nlohmann_json_j.contains("mesh_name_path")) {
54 nlohmann_json_t.mesh_name_path = nlohmann_json_j["mesh_name_path"].get<std::filesystem::path>();
55 }
56}
57} // namespace wmtk::components::output
#define WMTK_NLOHMANN_ASSIGN_TYPE_TO_JSON(...)
#define WMTK_NLOHMANN_JSON_FRIEND_TO_JSON_PROTOTYPE(Type)
#define WMTK_NLOHMANN_JSON_FRIEND_FROM_JSON_PROTOTYPE(Type)
spdlog::logger & logger()
Retrieves the current logger.
Definition Logger.cpp:58