Skip to content

Commit

Permalink
abstracting simplex inversion invariant to allow for inverted meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
mtao committed Dec 23, 2024
1 parent 4dd7919 commit b124232
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/wmtk/invariants/SimplexInversionInvariant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool SimplexInversionInvariant<T>::after(
const Eigen::Vector2<T> p2 = accessor.const_vector_attribute(
mymesh.switch_tuples(ccw_tuple, {PrimitiveType::Edge, PrimitiveType::Vertex}));

if (utils::wmtk_orient2d(p0, p1, p2) <= 0) return false;
if (!is_oriented(p0, p1, p2)) return false;
}

return true;
Expand All @@ -78,9 +78,7 @@ bool SimplexInversionInvariant<T>::after(
T p1 =
accessor.const_scalar_attribute(mymesh.switch_tuple(tuple, PrimitiveType::Vertex));

// was orient1d(p0,p1) >= 0, whic his equivalent to
// orient1d(p1,p0)
if (is_oriented(p1, p0)) return false;
if (!is_oriented(p0, p1)) return false;
}

return true;
Expand All @@ -94,17 +92,17 @@ bool SimplexInversionInvariant<T>::is_oriented(
const Eigen::Ref<const Vector1<T>>& p0,
const Eigen::Ref<const Vector1<T>>& p1) const
{
return is_oriented(p0.x(), p0.x());
return is_oriented(p0.x(), p1.x());
}
template <typename T>
bool SimplexInversionInvariant<T>::is_oriented(const T& p0, const T& p1) const
{
//
const int orient = utils::wmtk_orient1d(p0, p1);
if (m_inverted) {
return orient >= 0;
return orient < 0;
} else {
return orient <= 0;
return orient > 0;
}
}
template <typename T>
Expand All @@ -116,9 +114,9 @@ bool SimplexInversionInvariant<T>::is_oriented(
//
const int orient = utils::wmtk_orient2d(p0, p1, p2);
if (m_inverted) {
return orient >= 0;
return orient < 0;
} else {
return orient <= 0;
return orient > 0;
}
}
template <typename T>
Expand All @@ -130,9 +128,9 @@ bool SimplexInversionInvariant<T>::is_oriented(
{
const int orient = utils::wmtk_orient3d(p0, p1, p2, p3);
if (m_inverted) {
return orient >= 0;
return orient < 0;
} else {
return orient <= 0;
return orient > 0;
}
//
}
Expand Down

0 comments on commit b124232

Please sign in to comment.