Skip to content

Commit

Permalink
Rename EdgeSwap to EdgeSwapValence.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-zint committed Oct 12, 2023
1 parent 7d0389e commit e6b0226
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <wmtk/SimplicialComplex.hpp>
#include <wmtk/operations/tri_mesh/EdgeCollapseToMidpoint.hpp>
#include <wmtk/operations/tri_mesh/EdgeSplitAtMidpoint.hpp>
#include <wmtk/operations/tri_mesh/EdgeSwap.hpp>
#include <wmtk/operations/tri_mesh/EdgeSwapValence.hpp>
#include <wmtk/operations/tri_mesh/VertexTangentialLaplacianSmooth.hpp>

namespace wmtk::components::internal {
Expand Down Expand Up @@ -46,10 +46,10 @@ IsotropicRemeshing::IsotropicRemeshing(TriMesh& mesh, const double length, const
}
// flip
{
OperationSettings<tri_mesh::EdgeSwap> op_settings;
OperationSettings<tri_mesh::EdgeSwapValence> op_settings;
op_settings.must_improve_valence = true;

m_scheduler.add_operation_type<tri_mesh::EdgeSwap>("swap", op_settings);
m_scheduler.add_operation_type<tri_mesh::EdgeSwapValence>("swap", op_settings);
}
// smooth
{
Expand Down
4 changes: 2 additions & 2 deletions src/wmtk/operations/tri_mesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ set(SRC_FILES
EdgeCollapse.cpp
EdgeCollapseToMidpoint.hpp
EdgeCollapseToMidpoint.cpp
EdgeSwap.hpp
EdgeSwap.cpp
EdgeSwapValence.hpp
EdgeSwapValence.cpp
VertexAttributesUpdateBase.hpp
VertexAttributesUpdateBase.cpp
VertexLaplacianSmooth.hpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#include "EdgeSwap.hpp"
#include "EdgeSwapValence.hpp"
#include <wmtk/SimplicialComplex.hpp>
#include <wmtk/TriMesh.hpp>
#include "EdgeCollapse.hpp"
#include "EdgeSplit.hpp"
namespace wmtk::operations::tri_mesh {
EdgeSwap::EdgeSwap(Mesh& m, const Tuple& t, const OperationSettings<EdgeSwap>& settings)
EdgeSwapValence::EdgeSwapValence(
Mesh& m,
const Tuple& t,
const OperationSettings<EdgeSwapValence>& settings)
: TriMeshOperation(m)
, TupleOperation(settings.invariants, t)
, m_settings{settings}
{}

std::string EdgeSwap::name() const
std::string EdgeSwapValence::name() const

Check warning on line 16 in src/wmtk/operations/tri_mesh/EdgeSwapValence.cpp

View check run for this annotation

Codecov / codecov/patch

src/wmtk/operations/tri_mesh/EdgeSwapValence.cpp#L16

Added line #L16 was not covered by tests
{
return "tri_mesh_edge_swap";
}

bool EdgeSwap::before() const
bool EdgeSwapValence::before() const
{
if (!mesh().is_valid_slow(input_tuple())) {
return false;
Expand Down Expand Up @@ -69,12 +72,12 @@ bool EdgeSwap::before() const
return true;
}

Tuple EdgeSwap::return_tuple() const
Tuple EdgeSwapValence::return_tuple() const
{
return m_output_tuple;
}

bool EdgeSwap::execute()
bool EdgeSwapValence::execute()
{
// input
// / \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@

namespace wmtk::operations {
namespace tri_mesh {
class EdgeSwap;
class EdgeSwapValence;
}

template <>
struct OperationSettings<tri_mesh::EdgeSwap>
struct OperationSettings<tri_mesh::EdgeSwapValence>
{
bool must_improve_valence = false;
InvariantCollection invariants;
};

namespace tri_mesh {
class EdgeSwap : public TriMeshOperation, private TupleOperation
class EdgeSwapValence : public TriMeshOperation, private TupleOperation
{
public:
EdgeSwap(Mesh& m, const Tuple& t, const OperationSettings<EdgeSwap>& settings);
EdgeSwapValence(Mesh& m, const Tuple& t, const OperationSettings<EdgeSwapValence>& settings);

std::string name() const override;
Tuple return_tuple() const;
Expand All @@ -34,7 +34,7 @@ class EdgeSwap : public TriMeshOperation, private TupleOperation

private:
Tuple m_output_tuple;
const OperationSettings<EdgeSwap>& m_settings;
const OperationSettings<EdgeSwapValence>& m_settings;
};

} // namespace tri_mesh
Expand Down
14 changes: 7 additions & 7 deletions tests/components/test_component_isotropic_remeshing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <wmtk/operations/OperationFactory.hpp>
#include <wmtk/operations/tri_mesh/EdgeCollapseToMidpoint.hpp>
#include <wmtk/operations/tri_mesh/EdgeSplitAtMidpoint.hpp>
#include <wmtk/operations/tri_mesh/EdgeSwap.hpp>
#include <wmtk/operations/tri_mesh/EdgeSwapValence.hpp>
#include <wmtk/operations/tri_mesh/VertexLaplacianSmooth.hpp>
#include <wmtk/operations/tri_mesh/VertexTangentialLaplacianSmooth.hpp>
#include <wmtk_components/input/input.hpp>
Expand Down Expand Up @@ -503,9 +503,9 @@ TEST_CASE("swap_edge_for_valence", "[components][isotropic_remeshing][swap][2D]"
// swap edge to create inbalence in valence
{
const Tuple e = mesh.edge_tuple_between_v1_v2(6, 7, 5);
OperationSettings<tri_mesh::EdgeSwap> settings;
OperationSettings<tri_mesh::EdgeSwapValence> settings;
// settings.initialize_invariants(mesh);
tri_mesh::EdgeSwap op(mesh, e, settings);
tri_mesh::EdgeSwapValence op(mesh, e, settings);
const bool success = op();
REQUIRE(success);
}
Expand All @@ -523,12 +523,12 @@ TEST_CASE("swap_edge_for_valence", "[components][isotropic_remeshing][swap][2D]"
}


OperationSettings<EdgeSwap> op_settings;
OperationSettings<EdgeSwapValence> op_settings;
op_settings.must_improve_valence = true;
// op_settings.initialize_invariants(mesh);

Scheduler scheduler(mesh);
scheduler.add_operation_type<EdgeSwap>("TriMeshSwapEdgeOperation", op_settings);
scheduler.add_operation_type<EdgeSwapValence>("TriMeshSwapEdgeOperation", op_settings);
scheduler.run_operation_on_all(PrimitiveType::Edge, "TriMeshSwapEdgeOperation");

// check valence
Expand All @@ -545,10 +545,10 @@ TEST_CASE("swap_edge_for_valence", "[components][isotropic_remeshing][swap][2D]"
}
SECTION("swap_fail")
{
OperationSettings<EdgeSwap> op_settings;
OperationSettings<EdgeSwapValence> op_settings;
op_settings.must_improve_valence = true;
const Tuple e = mesh.edge_tuple_between_v1_v2(6, 7, 5);
EdgeSwap op(mesh, e, op_settings);
EdgeSwapValence op(mesh, e, op_settings);
const bool success = op();
CHECK(!success);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/test_2d_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <wmtk/operations/OperationFactory.hpp>
#include <wmtk/operations/tri_mesh/EdgeCollapse.hpp>
#include <wmtk/operations/tri_mesh/EdgeSplit.hpp>
#include <wmtk/operations/tri_mesh/EdgeSwap.hpp>
#include <wmtk/operations/tri_mesh/EdgeSwapValence.hpp>
#include <wmtk/utils/Logger.hpp>
#include "tools/DEBUG_TriMesh.hpp"
#include "tools/TriMesh_examples.hpp"
Expand Down Expand Up @@ -1111,8 +1111,8 @@ TEST_CASE("swap_edge", "[operations][swap][2D]")
REQUIRE(m.is_connectivity_valid());

const Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 0);
OperationSettings<tri_mesh::EdgeSwap> settings;
tri_mesh::EdgeSwap op(m, edge, settings);
OperationSettings<tri_mesh::EdgeSwapValence> settings;
tri_mesh::EdgeSwapValence op(m, edge, settings);
const bool success = op();
REQUIRE(success);
const Tuple ret = op.return_tuple();
Expand All @@ -1137,8 +1137,8 @@ TEST_CASE("swap_edge", "[operations][swap][2D]")
REQUIRE(m.is_connectivity_valid());

const Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 2);
OperationSettings<tri_mesh::EdgeSwap> settings;
tri_mesh::EdgeSwap op(m, edge, settings);
OperationSettings<tri_mesh::EdgeSwapValence> settings;
tri_mesh::EdgeSwapValence op(m, edge, settings);
const bool success = op();
REQUIRE(success);
const Tuple ret = op.return_tuple();
Expand All @@ -1163,8 +1163,8 @@ TEST_CASE("swap_edge", "[operations][swap][2D]")
REQUIRE(m.is_connectivity_valid());

const Tuple edge = m.edge_tuple_between_v1_v2(1, 2, 0);
OperationSettings<tri_mesh::EdgeSwap> settings;
tri_mesh::EdgeSwap op(m, edge, settings);
OperationSettings<tri_mesh::EdgeSwapValence> settings;
tri_mesh::EdgeSwapValence op(m, edge, settings);
const bool success = op();
REQUIRE(!success);
REQUIRE(m.is_connectivity_valid());
Expand Down

0 comments on commit e6b0226

Please sign in to comment.