Wildmeshing Toolkit
MinEdgeLengthInvariant.cpp
Go to the documentation of this file.
1 
3 #include <wmtk/Mesh.hpp>
4 
5 namespace wmtk::invariants {
7  const Mesh& m,
8  const TypedAttributeHandle<double>& coordinate,
9  double threshold_squared)
10  : Invariant(m, true, false, false)
11  , m_coordinate_handle(coordinate)
12  , m_threshold_squared(threshold_squared)
13 {}
15 {
17 
18  auto p0 = accessor.const_vector_attribute(t.tuple());
19  auto p1 =
20  accessor.const_vector_attribute(mesh().switch_tuple(t.tuple(), PrimitiveType::Vertex));
21  const double l_squared = (p1 - p0).squaredNorm();
22  return l_squared > m_threshold_squared;
23 }
24 } // namespace wmtk::invariants
const attribute::Accessor< T, Mesh, D > create_const_accessor(const attribute::MeshAttributeHandle &handle) const
A CachingAccessor that uses tuples for accessing attributes instead of indices.
Definition: Accessor.hpp:25
ConstMapResult< D > const_vector_attribute(const ArgType &t) const
Handle that represents attributes for some mesh.
const Mesh & mesh() const
Definition: Invariant.cpp:35
bool before(const simplex::Simplex &t) const override
const TypedAttributeHandle< double > m_coordinate_handle
MinEdgeLengthInvariant(const Mesh &m, const TypedAttributeHandle< double > &coordinate, double threshold_squared)
const Tuple & tuple() const
Definition: Simplex.hpp:53