11 int64_t collapse_index,
14 , m_coordinate_handle(coordinate)
15 , m_collapse_index(collapse_index)
34 std::array<Tuple, 4> v;
36 for (int64_t i = 0; i < 4; ++i) {
40 assert(iter_tuple == e0);
42 std::array<Eigen::Vector3<Rational>, 6> positions = {
47 accessor.const_vector_attribute(e0),
48 accessor.const_vector_attribute(e1)}};
49 std::array<Eigen::Vector3d, 6> positions_double = {
50 {positions[0].cast<
double>(),
51 positions[1].cast<double>(),
52 positions[2].cast<
double>(),
53 positions[3].cast<double>(),
54 positions[4].cast<
double>(),
55 positions[5].cast<double>()}};
57 std::array<std::array<int, 4>, 4> old_tets = {
58 {{{0, 1, 4, 5}}, {{1, 2, 4, 5}}, {{2, 3, 4, 5}}, {{3, 0, 4, 5}}}};
59 std::array<std::array<int, 4>, 4> new_tets = {
60 {{{0, 1, 2, 4}}, {{0, 2, 3, 4}}, {{0, 1, 2, 5}}, {{0, 2, 3, 5}}}};
62 double old_energy_max = std::numeric_limits<double>::lowest();
63 double new_energy_max = std::numeric_limits<double>::lowest();
65 for (
int i = 0; i < 4; ++i) {
67 positions[old_tets[i][0]],
68 positions[old_tets[i][1]],
69 positions[old_tets[i][2]],
70 positions[old_tets[i][3]]) > 0) {
72 positions_double[old_tets[i][0]][0],
73 positions_double[old_tets[i][0]][1],
74 positions_double[old_tets[i][0]][2],
75 positions_double[old_tets[i][1]][0],
76 positions_double[old_tets[i][1]][1],
77 positions_double[old_tets[i][1]][2],
78 positions_double[old_tets[i][2]][0],
79 positions_double[old_tets[i][2]][1],
80 positions_double[old_tets[i][2]][2],
81 positions_double[old_tets[i][3]][0],
82 positions_double[old_tets[i][3]][1],
83 positions_double[old_tets[i][3]][2],
86 old_energy_max = std::max(energy, old_energy_max);
89 positions_double[old_tets[i][1]][0],
90 positions_double[old_tets[i][1]][1],
91 positions_double[old_tets[i][1]][2],
92 positions_double[old_tets[i][0]][0],
93 positions_double[old_tets[i][0]][1],
94 positions_double[old_tets[i][0]][2],
95 positions_double[old_tets[i][2]][0],
96 positions_double[old_tets[i][2]][1],
97 positions_double[old_tets[i][2]][2],
98 positions_double[old_tets[i][3]][0],
99 positions_double[old_tets[i][3]][1],
100 positions_double[old_tets[i][3]][2],
103 old_energy_max = std::max(energy, old_energy_max);
107 positions[new_tets[i][0]],
108 positions[new_tets[i][1]],
109 positions[new_tets[i][2]],
110 positions[new_tets[i][3]]) > 0) {
112 positions_double[new_tets[i][0]][0],
113 positions_double[new_tets[i][0]][1],
114 positions_double[new_tets[i][0]][2],
115 positions_double[new_tets[i][1]][0],
116 positions_double[new_tets[i][1]][1],
117 positions_double[new_tets[i][1]][2],
118 positions_double[new_tets[i][2]][0],
119 positions_double[new_tets[i][2]][1],
120 positions_double[new_tets[i][2]][2],
121 positions_double[new_tets[i][3]][0],
122 positions_double[new_tets[i][3]][1],
123 positions_double[new_tets[i][3]][2],
126 new_energy_max = std::max(energy, new_energy_max);
129 positions_double[new_tets[i][1]][0],
130 positions_double[new_tets[i][1]][1],
131 positions_double[new_tets[i][1]][2],
132 positions_double[new_tets[i][0]][0],
133 positions_double[new_tets[i][0]][1],
134 positions_double[new_tets[i][0]][2],
135 positions_double[new_tets[i][2]][0],
136 positions_double[new_tets[i][2]][1],
137 positions_double[new_tets[i][2]][2],
138 positions_double[new_tets[i][3]][0],
139 positions_double[new_tets[i][3]][1],
140 positions_double[new_tets[i][3]][2],
143 new_energy_max = std::max(energy, new_energy_max);
147 return old_energy_max > new_energy_max *
m_eps;
const attribute::Accessor< T, Mesh, D > create_const_accessor(const attribute::MeshAttributeHandle &handle) const
Tuple switch_tuples(const Tuple &tuple, const ContainerType &op_sequence) const
virtual Tuple switch_tuple(const Tuple &tuple, PrimitiveType type) const =0
switch the orientation of the Tuple of the given dimension
const attribute::TypedAttributeHandle< Rational > m_coordinate_handle
Swap44EnergyBeforeInvariant(const Mesh &m, const attribute::TypedAttributeHandle< Rational > &coordinate, int64_t collapse_index, double eps=1.0001)
bool before(const simplex::Simplex &t) const override
Handle that represents attributes for some mesh.
const Mesh & mesh() const
const Tuple & tuple() const
constexpr wmtk::PrimitiveType PT
constexpr wmtk::PrimitiveType PF
double Tet_AMIPS_energy(const std::array< double, 12 > &T)
void top_dimension_cofaces(const Simplex &simplex, SimplexCollection &simplex_collection, const bool sort_and_clean)
Get all top dimension cofaces of the given simplex.
int wmtk_orient3d(const Eigen::Ref< const Eigen::Vector3< Rational >> &p0, const Eigen::Ref< const Eigen::Vector3< Rational >> &p1, const Eigen::Ref< const Eigen::Vector3< Rational >> &p2, const Eigen::Ref< const Eigen::Vector3< Rational >> &p3)
constexpr PrimitiveType PV
constexpr PrimitiveType PE