diff --git a/applications/isotropic_remeshing/examples/raw/camel.json b/applications/isotropic_remeshing/examples/raw/camel.json index 9f90edb653..87e7a600df 100644 --- a/applications/isotropic_remeshing/examples/raw/camel.json +++ b/applications/isotropic_remeshing/examples/raw/camel.json @@ -5,8 +5,8 @@ }, "root": "/home/mtao/git/wildmeshing-toolkit/data/aa0abd4658bb064515ee7cc2a7be87aa", "position_attribute": "vertices", - "iterations": 30, - "length_rel": 1, + "iterations": 5, + "length_rel": 0.01, "length_abs": -1, "lock_boundary": true, "edge_swap_mode": "valence", @@ -15,6 +15,6 @@ "fix_uv_seam": false, "output": { "path": "output.hdf5", - "type": "hdf5" + "type": ".hdf5" } } diff --git a/components/input/src/wmtk/components/input/InputOptions.cpp b/components/input/src/wmtk/components/input/InputOptions.cpp index 35c88c4c2a..9470e6f634 100644 --- a/components/input/src/wmtk/components/input/InputOptions.cpp +++ b/components/input/src/wmtk/components/input/InputOptions.cpp @@ -16,8 +16,8 @@ namespace nlohmann { void adl_serializer::to_json(json& j, const Type& v) { // - j["file"] = v.file; - j["file"] = v.file.string(); + j["path"] = v.path; + j["path"] = v.path.string(); if (!v.name_spec.is_null()) { assert(!v.name_spec_file.has_value()); j["name_spec"] = v.name_spec; @@ -44,10 +44,15 @@ void adl_serializer::to_json(json& j, con void adl_serializer::from_json(const json& j, Type& v) { if (j.is_string()) { - v.file = j.get(); + v.path= j.get(); return; + } else if(j.contains("path")) { + v.path = j["path"].get(); + } else if(j.contains("file")) { + wmtk::logger().warn("InputOptions using file is deprecated, use file"); + v.path = j["file"].get(); } - v.file = j["file"].get(); + if (j.contains("name_spec")) { v.name_spec = j["name_spec"]; } diff --git a/components/input/src/wmtk/components/input/InputOptions.hpp b/components/input/src/wmtk/components/input/InputOptions.hpp index 3a37a68cf3..0328c0eac8 100644 --- a/components/input/src/wmtk/components/input/InputOptions.hpp +++ b/components/input/src/wmtk/components/input/InputOptions.hpp @@ -18,7 +18,7 @@ class InputOptions public: InputOptions(); ~InputOptions(); - std::filesystem::path file; + std::filesystem::path path; std::optional>> imported_attributes; diff --git a/components/input/src/wmtk/components/input/input.cpp b/components/input/src/wmtk/components/input/input.cpp index 9822a30351..f78d4e0918 100644 --- a/components/input/src/wmtk/components/input/input.cpp +++ b/components/input/src/wmtk/components/input/input.cpp @@ -16,7 +16,7 @@ std::shared_ptr input( { InputOptions options; options.old_mode = true; - options.file = file; + options.path = file; options.ignore_z_if_zero = ignore_z_if_zero; if (!tetrahedron_attributes.empty()) { options.imported_attributes = {{}, {}, {}, tetrahedron_attributes}; @@ -33,7 +33,7 @@ multimesh::NamedMultiMesh input( const InputOptions& options, const components::utils::PathResolver& resolver) { - const auto [file_path, found] = resolver.resolve(options.file); + const auto [file_path, found] = resolver.resolve(options.path); if (!found) { const auto& paths = resolver.get_paths(); std::vector path_strs; @@ -46,7 +46,7 @@ multimesh::NamedMultiMesh input( log_and_throw_error( "file [{}] not found (input path was [{}], paths searched were [{}]", file_path.string(), - options.file.string(), + options.path.string(), fmt::join(path_strs, ",")); } diff --git a/components/input/tests/input.cpp b/components/input/tests/input.cpp index d0b8a810e9..c42f52a7eb 100644 --- a/components/input/tests/input.cpp +++ b/components/input/tests/input.cpp @@ -28,7 +28,7 @@ TEST_CASE("component_input", "[components][input]") {"ignore_z", false}, {"tetrahedron_attributes", json::array()}}; auto opts = component_json.get(); - CHECK(opts.file == input_file); + CHECK(opts.path == input_file); CHECK(opts.ignore_z_if_zero == false); CHECK(opts.old_mode == true); CHECK(opts.old_mode == true); @@ -50,7 +50,7 @@ TEST_CASE("component_input", "[components][input]") nlohmann::json js = "path"; REQUIRE(js.is_string()); auto opts = js.get(); - CHECK(opts.file.string() == "path"); + CHECK(opts.path.string() == "path"); } SECTION("should throw") diff --git a/components/output/wmtk/components/output/OutputOptions.cpp b/components/output/wmtk/components/output/OutputOptions.cpp index 05507e6501..0c44c7aab7 100644 --- a/components/output/wmtk/components/output/OutputOptions.cpp +++ b/components/output/wmtk/components/output/OutputOptions.cpp @@ -10,7 +10,7 @@ namespace wmtk::components::output { WMTK_NLOHMANN_JSON_FRIEND_TO_JSON_PROTOTYPE(OutputOptions) { - WMTK_NLOHMANN_ASSIGN_TYPE_TO_JSON(file, type) + WMTK_NLOHMANN_ASSIGN_TYPE_TO_JSON(path, type) if (nlohmann_json_t.mesh_name_path.has_value()) { nlohmann_json_j["mesh_name_path"] = nlohmann_json_t.mesh_name_path.value(); } @@ -33,17 +33,20 @@ WMTK_NLOHMANN_JSON_FRIEND_TO_JSON_PROTOTYPE(OutputOptions) WMTK_NLOHMANN_JSON_FRIEND_FROM_JSON_PROTOTYPE(OutputOptions) { if (nlohmann_json_j.is_string()) { - nlohmann_json_t.file = nlohmann_json_j.get(); - } else { - nlohmann_json_t.file = nlohmann_json_j["file"].get(); + nlohmann_json_t.path = nlohmann_json_j.get(); + } else if(nlohmann_json_j.contains("path")) { + nlohmann_json_t.path = nlohmann_json_j["path"].get(); + } else if(nlohmann_json_j.contains("file")) { + wmtk::logger().warn("OutputOptions using file is deprecated, use file"); + nlohmann_json_t.path = nlohmann_json_j["file"].get(); } if (nlohmann_json_j.contains("type")) { nlohmann_json_t.type = nlohmann_json_j["type"]; } else { - nlohmann_json_t.type = nlohmann_json_t.file.extension().string(); + nlohmann_json_t.type = nlohmann_json_t.path.extension().string(); wmtk::logger().debug( "Guessing extension type of [{}] is [{}]", - nlohmann_json_t.file, + nlohmann_json_t.path, nlohmann_json_t.type); } if (nlohmann_json_j.contains("position_attribute")) { diff --git a/components/output/wmtk/components/output/OutputOptions.hpp b/components/output/wmtk/components/output/OutputOptions.hpp index f3b7565af6..ac4acb1a2f 100644 --- a/components/output/wmtk/components/output/OutputOptions.hpp +++ b/components/output/wmtk/components/output/OutputOptions.hpp @@ -8,7 +8,7 @@ namespace wmtk::components::output { struct OutputOptions { - std::filesystem::path file; + std::filesystem::path path; std::string type; diff --git a/components/output/wmtk/components/output/output.cpp b/components/output/wmtk/components/output/output.cpp index 511d84b5a4..9b2a039a82 100644 --- a/components/output/wmtk/components/output/output.cpp +++ b/components/output/wmtk/components/output/output.cpp @@ -71,14 +71,14 @@ void output( for (int64_t d = 0; d <= mesh.top_cell_dimension(); ++d) { out[d] = true; } - ParaviewWriter writer(opts.file,name, mesh, out[0], out[1], out[2], out[3]); + ParaviewWriter writer(opts.path,name, mesh, out[0], out[1], out[2], out[3]); mesh.serialize(writer); } else if (opts.type == ".hdf5") { - output_hdf5(mesh, opts.file); + output_hdf5(mesh, opts.path); } else throw std::runtime_error( fmt::format("Unable to write file [{}] of extension [{}]", - opts.file, opts.type)); + opts.path, opts.type)); } void output(