Skip to content

Commit

Permalink
adding flag accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
mtao committed Dec 7, 2024
1 parent c7d306c commit 52dcfe0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions tests/multimesh/consolidate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ TEST_CASE("consolidate_multimesh", "[mesh][consolidate_multimesh]")

// CHECK_THROWS(m.tuple_from_id(PrimitiveType::Vertex, 4));

REQUIRE(executor.flag_accessors[2].index_access().const_scalar_attribute(2) == 0);
REQUIRE(executor.flag_accessors[2].index_access().const_scalar_attribute(7) == 0);
REQUIRE(executor.flag_accessors[2].index_access().is_active(2) == false);
REQUIRE(executor.flag_accessors[2].index_access().is_active(7) == false);
CHECK(fv_accessor.vector_attribute(0)[1] == 5);
CHECK(fv_accessor.vector_attribute(1)[0] == 5);
CHECK(fv_accessor.vector_attribute(3)[0] == 5);
Expand Down
10 changes: 5 additions & 5 deletions tests/operations/collapse_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ TEST_CASE("collapse_edge", "[operations][collapse][2D]")

// CHECK_THROWS(m.tuple_from_id(PrimitiveType::Vertex, 4));

REQUIRE(face_flag_accessor.index_access().const_scalar_attribute(2) == 0);
REQUIRE(face_flag_accessor.index_access().const_scalar_attribute(7) == 0);
REQUIRE(face_flag_accessor.index_access().is_active(2) == false);
REQUIRE(face_flag_accessor.index_access().is_active(7) == false);
CHECK(fv_accessor.vector_attribute(0)[1] == 5);
CHECK(fv_accessor.vector_attribute(1)[0] == 5);
CHECK(fv_accessor.vector_attribute(3)[0] == 5);
Expand All @@ -84,8 +84,8 @@ TEST_CASE("collapse_edge", "[operations][collapse][2D]")

// CHECK_THROWS(m.tuple_from_id(PrimitiveType::Vertex, 4));

REQUIRE(face_flag_accessor.index_access().const_scalar_attribute(0) == 0);
REQUIRE(face_flag_accessor.index_access().const_scalar_attribute(1) == 0);
REQUIRE(face_flag_accessor.index_access().is_active(0) == false);
REQUIRE(face_flag_accessor.index_access().is_active(1) == false);

CHECK(fv_accessor.vector_attribute(2)[0] == 0);
CHECK(fv_accessor.vector_attribute(5)[2] == 0);
Expand Down Expand Up @@ -125,7 +125,7 @@ TEST_CASE("collapse_edge", "[operations][collapse][2D]")

// CHECK_THROWS(m.tuple_from_id(PrimitiveType::Vertex, 0));

REQUIRE(face_flag_accessor.index_access().const_scalar_attribute(1) == 0);
REQUIRE(face_flag_accessor.index_access().is_active(1) == false);

CHECK(fv_accessor.vector_attribute(0)[2] == 1);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/operations/split_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ TEST_CASE("delete_simplices", "[operations][2D]")
executor.simplex_ids_to_delete = TMOE::get_split_simplices_to_delete(edge, m);

executor.delete_simplices();
REQUIRE(executor.flag_accessors[1].index_access().const_scalar_attribute(edge_index) == 0);
REQUIRE(executor.flag_accessors[2].index_access().const_scalar_attribute(face_index) == 0);
REQUIRE(executor.flag_accessors[1].index_access().is_active(edge_index) == false);
REQUIRE(executor.flag_accessors[2].index_access().is_active(face_index) == false);
REQUIRE(executor.ff_accessor.index_access().const_vector_attribute(face_index)[0] == -1);
REQUIRE(executor.ff_accessor.index_access().const_vector_attribute(face_index)[1] == 2);
REQUIRE(executor.ff_accessor.index_access().const_vector_attribute(face_index)[2] == 1);
Expand Down
4 changes: 2 additions & 2 deletions tests/test_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ TEST_CASE("consolidate", "[mesh][consolidate]")

// CHECK_THROWS(m.tuple_from_id(PrimitiveType::Vertex, 4));

REQUIRE(executor.flag_accessors[2].index_access().scalar_attribute(2) == 0);
REQUIRE(executor.flag_accessors[2].index_access().scalar_attribute(7) == 0);
REQUIRE(executor.flag_accessors[2].index_access().is_active(2) == false);
REQUIRE(executor.flag_accessors[2].index_access().is_active(7) == false);
CHECK(fv_accessor.vector_attribute(0)[1] == 5);
CHECK(fv_accessor.vector_attribute(1)[0] == 5);
CHECK(fv_accessor.vector_attribute(3)[0] == 5);
Expand Down
4 changes: 2 additions & 2 deletions tests/tools/DEBUG_EdgeMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void DEBUG_EdgeMesh::print_ve() const
auto e_flag_accessor = get_flag_accessor(PrimitiveType::Edge);
for (int64_t id = 0; id < capacity(PrimitiveType::Edge); ++id) {
auto ev = ev_accessor.const_vector_attribute(id);
if (e_flag_accessor.const_scalar_attribute(tuple_from_id(PrimitiveType::Edge, id)) == 0) {
if (!e_flag_accessor.is_active(tuple_from_id(PrimitiveType::Edge, id))) {
std::cout << "edge " << id << " is deleted" << std::endl;
} else {
std::cout << ev(0) << " " << ev(1) << std::endl;
Expand Down Expand Up @@ -111,6 +111,6 @@ auto DEBUG_EdgeMesh::get_emoe(const Tuple& t) -> EdgeMeshOperationExecutor
bool DEBUG_EdgeMesh::is_simplex_deleted(PrimitiveType type, const int64_t id) const
{
const auto flag_accessor = get_flag_accessor(type);
return flag_accessor.index_access().scalar_attribute(id) == 0;
return !flag_accessor.index_access().is_active(id) ;
}
} // namespace wmtk::tests
2 changes: 1 addition & 1 deletion tests/tools/DEBUG_TetMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ int64_t DEBUG_TetMesh::valid_primitive_count(PrimitiveType type) const
int64_t cnt = 0;
const auto& flag_accessor = get_const_flag_accessor(type);
for (int i = 0; i < capacity(type); i++) {
if (flag_accessor.index_access().const_scalar_attribute(i) != 0) {
if (flag_accessor.index_access().is_active(i)) {
cnt++;
}
}
Expand Down
3 changes: 1 addition & 2 deletions tests/tools/DEBUG_TriMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ void DEBUG_TriMesh::print_vf() const
auto f_flag_accessor = get_flag_accessor(PrimitiveType::Triangle);
for (int64_t id = 0; id < capacity(PrimitiveType::Triangle); ++id) {
auto fv = fv_accessor.const_vector_attribute(id);
if (f_flag_accessor.const_scalar_attribute(tuple_from_id(PrimitiveType::Triangle, id)) ==
0) {
if (!f_flag_accessor.is_active(tuple_from_id(PrimitiveType::Triangle, id))) {
std::cout << "face " << id << " is deleted" << std::endl;
} else {
std::cout << fv(0) << " " << fv(1) << " " << fv(2) << std::endl;
Expand Down

0 comments on commit 52dcfe0

Please sign in to comment.