Skip to content

Commit

Permalink
remove debugging code
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahdhn committed Jan 16, 2025
1 parent b6a4d95 commit 5ec5e13
Showing 1 changed file with 3 additions and 219 deletions.
222 changes: 3 additions & 219 deletions apps/SurfaceTracking/splitter.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ split_edges(rxmesh::Context context,
ShmemAllocator shrd_alloc;

CavityManager2<blockThreads, CavityOp::E> cavity(
block, context, shrd_alloc, true, false);
block, context, shrd_alloc, true);


if (cavity.patch_id() == INVALID32) {
Expand All @@ -55,108 +55,8 @@ split_edges(rxmesh::Context context,
if (edge_status(eh) == UNSEEN) {
// make sure it is not boundary edge

#if 0
if ((!iter[1].is_valid() && iter[3].is_valid()) ||
(iter[1].is_valid() && !iter[3].is_valid())) {
// boundary edge

/*
a
/ |
c |
\ |
b
*/
const VertexHandle ah = iter[0];
const VertexHandle bh = iter[2];
const VertexHandle ch = iter[1].is_valid() ? iter[1] : iter[3];

bool split_it = true;

if (ah == bh || bh == ch || ch == ah) {
split_it = false;
}

// vertices position
const vec3<T> va(
position(ah, 0), position(ah, 1), position(ah, 2));

const vec3<T> vb(
position(bh, 0), position(bh, 1), position(bh, 2));

const vec3<T> vc(
position(ch, 0), position(ch, 1), position(ch, 2));


// test the predicate
if (split_it) {
if (predicate == EdgeSplitPredicate::Length) {
// is it a long edge
if (glm::distance2(va, vb) < splitter_max_edge_length) {
split_it = false;
}
} else if (predicate == EdgeSplitPredicate::Angle) {
// is it opposite to large angles
if (tri_angle(va, vc, vb) < max_triangle_angle) {
split_it = false;
}
} else {
assert(1 != 1);
}
}

// splitting degenerate triangles causes problems
if (split_it) {
const T area0 = tri_area(va, vb, vc);
if (area0 < min_triangle_area) {
split_it = false;
}
}

// Check angles of new triangles
if (split_it) {
// mid point (new) vertex
const vec3<T> ve = T(0.5) * (va + vb);

// current min and max angles
T cur_min1, cur_max1;
triangle_min_max_angle(va, vb, vc, cur_min1, cur_max1);


// new triangles angle
T min1, min2, max1, max2;

triangle_min_max_angle(va, ve, vc, min1, max1);
triangle_min_max_angle(vc, ve, vb, min2, max2);


if (min1 < min_triangle_angle ||
min2 < min_triangle_angle) {
split_it = false;
}
if (split_it) {
// if new angle is greater than the allowed angle, and
// doesn't improve the current max angle, prevent the
// split

if (max1 > max_triangle_angle ||
max2 > max_triangle_angle) {
split_it = false;
}
}
}


if (split_it) {
cavity.create(eh);
} else {
edge_status(eh) = SKIP;
}


} else
#endif
if (iter[1].is_valid() && iter[3].is_valid()) {
if (iter[1].is_valid() && iter[3].is_valid() &&
iter[0].is_valid() && iter[2].is_valid()) {
// interior edge

assert(iter.size() == 4);
Expand Down Expand Up @@ -295,122 +195,6 @@ split_edges(rxmesh::Context context,
cavity.for_each_cavity(block, [&](uint16_t c, uint16_t size) {
assert(size == 4);

#if 0
//assert(size == 4 || size == 2);

if (size == 2) {

auto get_boundary_vertices = [&](VertexHandle v0,
VertexHandle v1,
VertexHandle v2,
VertexHandle v3) {
VertexHandle b0, b1;

if (is_vertex_bd(v0) == 1) {
b0 = v0;
}

if (is_vertex_bd(v1) == 1) {
if (!b0.is_valid()) {
b0 = v1;
} else {
b1 = v1;
}
}

if (is_vertex_bd(v2) == 1) {
if (!b0.is_valid()) {
b0 = v2;
} else {
b1 = v2;
}
}

if (is_vertex_bd(v3) == 1) {
if (!b0.is_valid()) {
b0 = v3;
} else {
b1 = v3;
}
}

return std::pair<VertexHandle, VertexHandle>(b0, b1);
};

auto e0 = cavity.get_cavity_edge(c, 0);
auto e1 = cavity.get_cavity_edge(c, 1);

VertexHandle e0_v0, e0_v1, e1_v0, e1_v1;

cavity.get_vertices(e0.get_edge_handle(), e0_v0, e0_v1);
cavity.get_vertices(e1.get_edge_handle(), e1_v0, e1_v1);

// boundary vertex
auto [b0, b1] =
get_boundary_vertices(e0_v0, e0_v1, e1_v0, e1_v1);

// internal vertex
VertexHandle i0 = (e0_v0 != b0 && e0_v0 != b1) ? e0_v0 : e0_v1;


assert(b0.is_valid());
assert(b1.is_valid());
assert(i0.is_valid());

assert(is_vertex_bd(b0) == 1);
assert(is_vertex_bd(b1) == 1);
assert(is_vertex_bd(i0) == 0);

assert(i0 == e1_v0 || i0 == e1_v1);

const VertexHandle new_v = cavity.add_vertex();

if (new_v.is_valid()) {
is_vertex_bd(new_v) = 1;
is_vertex_bd(i0) = 1;

position(new_v, 0) =
T(0.5) * (position(b0, 0) + position(b1, 0));
position(new_v, 1) =
T(0.5) * (position(b0, 1) + position(b1, 1));
position(new_v, 2) =
T(0.5) * (position(b0, 2) + position(b1, 2));

DEdgeHandle new_e = cavity.add_edge(new_v, i0);
if (new_e.is_valid()) {

// the boundary vertex in e0
VertexHandle e0_b =
(e0_v0 == b0 || e0_v0 == b1) ? e0_v0 : e0_v1;

// the boundary vertex in e1
VertexHandle e1_b =
(e1_v0 == b0 || e1_v0 == b1) ? e1_v0 : e1_v1;

DEdgeHandle new_e0_b = cavity.add_edge(new_v, e0_b);
// DEdgeHandle new_e1_b = cavity.add_edge(new_v, e1_b);

if (new_e0_b.is_valid() /*&& new_e1_b.is_valid()*/) {
cavity.add_face(
new_e0_b,
(e0_b == e0_v0) ? e0.get_flip_dedge() : e0,
new_e.get_flip_dedge());
// printf("f = %u, %u, %u",
// new_v,
// (e0_b == e0_v0) ? e0_v1 : e0_v1,
// i0);
//
// cavity.add_face(
// new_e1_b.get_flip_dedge(),
// new_e,
// (i0 == e1_v0) ? e1.get_flip_dedge() : e1);
}
}
}


} else
#endif
if (size == 4) {


Expand Down

0 comments on commit 5ec5e13

Please sign in to comment.