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<double>, 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], positions[1], positions[2], positions[3], positions[4], positions[5]}};
52 std::array<std::array<int, 4>, 4> old_tets = {
53 {{{0, 1, 4, 5}}, {{1, 2, 4, 5}}, {{2, 3, 4, 5}}, {{3, 0, 4, 5}}}};
54 std::array<std::array<int, 4>, 4> new_tets = {
55 {{{0, 1, 2, 4}}, {{0, 2, 3, 4}}, {{0, 1, 2, 5}}, {{0, 2, 3, 5}}}};
57 double old_energy_max = std::numeric_limits<double>::lowest();
58 double new_energy_max = std::numeric_limits<double>::lowest();
60 for (
int i = 0; i < 4; ++i) {
62 positions[old_tets[i][0]],
63 positions[old_tets[i][1]],
64 positions[old_tets[i][2]],
65 positions[old_tets[i][3]]) > 0) {
67 positions_double[old_tets[i][0]][0],
68 positions_double[old_tets[i][0]][1],
69 positions_double[old_tets[i][0]][2],
70 positions_double[old_tets[i][1]][0],
71 positions_double[old_tets[i][1]][1],
72 positions_double[old_tets[i][1]][2],
73 positions_double[old_tets[i][2]][0],
74 positions_double[old_tets[i][2]][1],
75 positions_double[old_tets[i][2]][2],
76 positions_double[old_tets[i][3]][0],
77 positions_double[old_tets[i][3]][1],
78 positions_double[old_tets[i][3]][2],
81 if (energy > old_energy_max) old_energy_max = energy;
84 positions_double[old_tets[i][1]][0],
85 positions_double[old_tets[i][1]][1],
86 positions_double[old_tets[i][1]][2],
87 positions_double[old_tets[i][0]][0],
88 positions_double[old_tets[i][0]][1],
89 positions_double[old_tets[i][0]][2],
90 positions_double[old_tets[i][2]][0],
91 positions_double[old_tets[i][2]][1],
92 positions_double[old_tets[i][2]][2],
93 positions_double[old_tets[i][3]][0],
94 positions_double[old_tets[i][3]][1],
95 positions_double[old_tets[i][3]][2],
98 if (energy > old_energy_max) old_energy_max = energy;
102 positions[new_tets[i][0]],
103 positions[new_tets[i][1]],
104 positions[new_tets[i][2]],
105 positions[new_tets[i][3]]) > 0) {
107 positions_double[new_tets[i][0]][0],
108 positions_double[new_tets[i][0]][1],
109 positions_double[new_tets[i][0]][2],
110 positions_double[new_tets[i][1]][0],
111 positions_double[new_tets[i][1]][1],
112 positions_double[new_tets[i][1]][2],
113 positions_double[new_tets[i][2]][0],
114 positions_double[new_tets[i][2]][1],
115 positions_double[new_tets[i][2]][2],
116 positions_double[new_tets[i][3]][0],
117 positions_double[new_tets[i][3]][1],
118 positions_double[new_tets[i][3]][2],
121 if (energy > new_energy_max) new_energy_max = energy;
124 positions_double[new_tets[i][1]][0],
125 positions_double[new_tets[i][1]][1],
126 positions_double[new_tets[i][1]][2],
127 positions_double[new_tets[i][0]][0],
128 positions_double[new_tets[i][0]][1],
129 positions_double[new_tets[i][0]][2],
130 positions_double[new_tets[i][2]][0],
131 positions_double[new_tets[i][2]][1],
132 positions_double[new_tets[i][2]][2],
133 positions_double[new_tets[i][3]][0],
134 positions_double[new_tets[i][3]][1],
135 positions_double[new_tets[i][3]][2],
138 if (energy > new_energy_max) new_energy_max = energy;
142 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
bool before(const simplex::Simplex &t) const override
Swap44EnergyBeforeInvariantDouble(const Mesh &m, const attribute::TypedAttributeHandle< double > &coordinate, int64_t collapse_index, double eps=1.0001)
const attribute::TypedAttributeHandle< double > m_coordinate_handle
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