Skip to content

Commit

Permalink
add skip options to wildmeshing code
Browse files Browse the repository at this point in the history
  • Loading branch information
JcDai committed Nov 4, 2024
1 parent 9777c0a commit be6f3f4
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 39 deletions.
4 changes: 4 additions & 0 deletions applications/tetwild/tetwild_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ int main(int argc, char* argv[])
wmo.intermediate_output_name = j["output"];
wmo.envelopes = enves;
wmo.pass_through = pass_through;
wmo.skip_split = j["skip_split"];
wmo.skip_collapse = j["skip_collapse"];
wmo.skip_swap = j["skip_swap"];
wmo.skip_smooth = j["skip_smooth"];

Check warning on line 178 in applications/tetwild/tetwild_main.cpp

View check run for this annotation

Codecov / codecov/patch

applications/tetwild/tetwild_main.cpp#L175-L178

Added lines #L175 - L178 were not covered by tests

auto meshes_after_tetwild = wildmeshing(wmo);
auto main_mesh_after_tetwild = meshes_after_tetwild[0].first;
Expand Down
26 changes: 25 additions & 1 deletion applications/tetwild/tetwild_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ nlohmann::json tetwild_spec = R"(
"skip_simplification",
"target_max_amips",
"max_passes",
"intermediate_output"
"intermediate_output",
"skip_split",
"skip_collapse",
"skip_swap",
"skip_smooth"
]
},
{
Expand Down Expand Up @@ -53,6 +57,26 @@ nlohmann::json tetwild_spec = R"(
"type": "int",
"default": 10
},
{
"pointer": "/skip_split",
"type": "bool",
"default": false
},
{
"pointer": "/skip_collapse",
"type": "bool",
"default": false
},
{
"pointer": "/skip_swap",
"type": "bool",
"default": false
},
{
"pointer": "/skip_smooth",
"type": "bool",
"default": false
},
{
"pointer": "/output",
"type": "string"
Expand Down
4 changes: 4 additions & 0 deletions applications/triwild/triwild_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ int main(int argc, char* argv[])
wmo.intermediate_output_name = j["output"];
wmo.envelopes = enves;
wmo.pass_through = pass_through;
wmo.skip_split = j["skip_split"];
wmo.skip_collapse = j["skip_collapse"];
wmo.skip_swap = j["skip_swap"];
wmo.skip_smooth = j["skip_smooth"];

auto meshes_after_tetwild = wildmeshing(wmo);
auto main_mesh = meshes_after_tetwild[0].first;
Expand Down
26 changes: 25 additions & 1 deletion applications/triwild/triwild_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ nlohmann::json triwild_spec = R"(
"target_edge_length",
"target_max_amips",
"max_passes",
"intermediate_output"
"intermediate_output",
"skip_split",
"skip_collapse",
"skip_swap",
"skip_smooth"
]
},
{
Expand All @@ -37,6 +41,26 @@ nlohmann::json triwild_spec = R"(
"type": "bool",
"default": false
},
{
"pointer": "/skip_split",
"type": "bool",
"default": false
},
{
"pointer": "/skip_collapse",
"type": "bool",
"default": false
},
{
"pointer": "/skip_swap",
"type": "bool",
"default": false
},
{
"pointer": "/skip_smooth",
"type": "bool",
"default": false
},
{
"pointer": "/target_max_amips",
"type": "float",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ struct WildMeshingOptions
std::string intermediate_output_path;
std::string intermediate_output_name;

bool skip_split;
bool skip_collapse;
bool skip_swap;
bool skip_smooth;

std::vector<EnvelopeOptions> envelopes;
std::vector<attribute::MeshAttributeHandle> pass_through;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,14 @@ std::vector<std::pair<std::shared_ptr<Mesh>, std::string>> wildmeshing2d(

split_sequence->set_priority(long_edges_first);

ops.emplace_back(split_sequence);
ops_name.emplace_back("SPLIT");

ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
if (!options.skip_split) {
ops.emplace_back(split_sequence);
ops_name.emplace_back("SPLIT");

ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
}


//////////////////////////////////
Expand Down Expand Up @@ -718,11 +721,13 @@ std::vector<std::pair<std::shared_ptr<Mesh>, std::string>> wildmeshing2d(
collapse_then_round->add_transfer_strategy(s);
}

ops.emplace_back(collapse_then_round);
ops_name.emplace_back("COLLAPSE");
if (!options.skip_collapse) {
ops.emplace_back(collapse_then_round);
ops_name.emplace_back("COLLAPSE");

ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
}

//////////////////////////////////
// 3) Swap
Expand Down Expand Up @@ -804,11 +809,13 @@ std::vector<std::pair<std::shared_ptr<Mesh>, std::string>> wildmeshing2d(
auto swap = std::make_shared<TriEdgeSwap>(*mesh);
setup_swap(*swap, swap->collapse(), swap->split(), interior_edge);

ops.push_back(swap);
ops_name.push_back("swap");
if (!options.skip_swap) {
ops.push_back(swap);
ops_name.push_back("swap");

ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
}

// 4) Smoothing
// //////////////////////////////////////
Expand Down Expand Up @@ -894,13 +901,16 @@ std::vector<std::pair<std::shared_ptr<Mesh>, std::string>> wildmeshing2d(
}
// proj_smoothing->add_transfer_strategy(target_edge_length_update);

for (int i = 0; i < 1; ++i) {
ops.push_back(proj_smoothing);
ops_name.push_back("SMOOTHING");
}
if (!options.skip_smooth) {
for (int i = 0; i < 1; ++i) {
// some old code to do smoothing several times, maybe useful later
ops.push_back(proj_smoothing);
ops_name.push_back("SMOOTHING");
}

ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
}

write(
mesh,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,13 @@ std::vector<std::pair<std::shared_ptr<Mesh>, std::string>> wildmeshing3d(

split_sequence->set_priority(long_edges_first);

ops.emplace_back(split_sequence);
ops_name.emplace_back("SPLIT");
if (!options.skip_split) {
ops.emplace_back(split_sequence);
ops_name.emplace_back("SPLIT");

Check warning on line 577 in components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp

View check run for this annotation

Codecov / codecov/patch

components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp#L576-L577

Added lines #L576 - L577 were not covered by tests

ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
ops.emplace_back(rounding);
ops_name.emplace_back("rounding");

Check warning on line 580 in components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp

View check run for this annotation

Codecov / codecov/patch

components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp#L579-L580

Added lines #L579 - L580 were not covered by tests
}


//////////////////////////////////
Expand Down Expand Up @@ -675,11 +677,13 @@ std::vector<std::pair<std::shared_ptr<Mesh>, std::string>> wildmeshing3d(
collapse_then_round->add_transfer_strategy(s);
}

ops.emplace_back(collapse_then_round);
ops_name.emplace_back("COLLAPSE");
if (!options.skip_collapse) {
ops.emplace_back(collapse_then_round);
ops_name.emplace_back("COLLAPSE");

Check warning on line 682 in components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp

View check run for this annotation

Codecov / codecov/patch

components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp#L681-L682

Added lines #L681 - L682 were not covered by tests

ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
ops.emplace_back(rounding);
ops_name.emplace_back("rounding");

Check warning on line 685 in components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp

View check run for this annotation

Codecov / codecov/patch

components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp#L684-L685

Added lines #L684 - L685 were not covered by tests
}

//////////////////////////////////
// 3) Swap
Expand Down Expand Up @@ -1058,11 +1062,12 @@ std::vector<std::pair<std::shared_ptr<Mesh>, std::string>> wildmeshing3d(
swap_then_round->add_transfer_strategy(s);
}

ops.push_back(swap_then_round);
ops_name.push_back("EDGE SWAP");
ops.emplace_back(rounding);
ops_name.emplace_back("rounding");

if (!options.skip_swap) {
ops.push_back(swap_then_round);
ops_name.push_back("EDGE SWAP");
ops.emplace_back(rounding);
ops_name.emplace_back("rounding");

Check warning on line 1069 in components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp

View check run for this annotation

Codecov / codecov/patch

components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp#L1066-L1069

Added lines #L1066 - L1069 were not covered by tests
}

// 4) Smoothing
// //////////////////////////////////////
Expand Down Expand Up @@ -1148,13 +1153,16 @@ std::vector<std::pair<std::shared_ptr<Mesh>, std::string>> wildmeshing3d(
}
// proj_smoothing->add_transfer_strategy(target_edge_length_update);

for (int i = 0; i < 1; ++i) {
ops.push_back(proj_smoothing);
ops_name.push_back("SMOOTHING");
}
if (!options.skip_smooth) {
for (int i = 0; i < 1; ++i) {
// some old code to do smoothing several times, maybe useful later
ops.push_back(proj_smoothing);
ops_name.push_back("SMOOTHING");

Check warning on line 1160 in components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp

View check run for this annotation

Codecov / codecov/patch

components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp#L1159-L1160

Added lines #L1159 - L1160 were not covered by tests
}

ops.emplace_back(rounding);
ops_name.emplace_back("rounding");
ops.emplace_back(rounding);
ops_name.emplace_back("rounding");

Check warning on line 1164 in components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp

View check run for this annotation

Codecov / codecov/patch

components/wildmeshing/wmtk/components/wildmeshing/internal/wildmeshing3d.cpp#L1163-L1164

Added lines #L1163 - L1164 were not covered by tests
}

write(
mesh,
Expand Down

0 comments on commit be6f3f4

Please sign in to comment.