11 int64_t collapse_index,
14 , m_coordinate_handle(coordinate)
15 , m_collapse_index(collapse_index)
32 std::array<Tuple, 5> v;
34 for (int64_t i = 0; i < 5; ++i) {
38 assert(iter_tuple == e0);
41 std::array<Eigen::Vector3<Rational>, 7> positions = {
47 accessor.const_vector_attribute(e0),
48 accessor.const_vector_attribute(e1)}};
50 std::array<Eigen::Vector3d, 7> positions_double = {
51 {positions[0].cast<
double>(),
52 positions[1].cast<double>(),
53 positions[2].cast<
double>(),
54 positions[3].cast<double>(),
55 positions[4].cast<
double>(),
56 positions[5].cast<double>(),
57 positions[6].cast<
double>()}};
59 std::array<std::array<int, 4>, 5> old_tets = {
60 {{{0, 1, 5, 6}}, {{1, 2, 5, 6}}, {{2, 3, 5, 6}}, {{3, 4, 5, 6}}, {{4, 0, 5, 6}}}};
62 std::array<std::array<int, 4>, 6> new_tets = {
70 double old_energy_max = std::numeric_limits<double>::lowest();
71 double new_energy_max = std::numeric_limits<double>::lowest();
73 for (
int i = 0; i < 5; ++i) {
75 positions[old_tets[i][0]],
76 positions[old_tets[i][1]],
77 positions[old_tets[i][2]],
78 positions[old_tets[i][3]]) > 0) {
80 positions_double[old_tets[i][0]][0],
81 positions_double[old_tets[i][0]][1],
82 positions_double[old_tets[i][0]][2],
83 positions_double[old_tets[i][1]][0],
84 positions_double[old_tets[i][1]][1],
85 positions_double[old_tets[i][1]][2],
86 positions_double[old_tets[i][2]][0],
87 positions_double[old_tets[i][2]][1],
88 positions_double[old_tets[i][2]][2],
89 positions_double[old_tets[i][3]][0],
90 positions_double[old_tets[i][3]][1],
91 positions_double[old_tets[i][3]][2],
95 if (energy > old_energy_max) old_energy_max = energy;
98 positions_double[old_tets[i][1]][0],
99 positions_double[old_tets[i][1]][1],
100 positions_double[old_tets[i][1]][2],
101 positions_double[old_tets[i][0]][0],
102 positions_double[old_tets[i][0]][1],
103 positions_double[old_tets[i][0]][2],
104 positions_double[old_tets[i][2]][0],
105 positions_double[old_tets[i][2]][1],
106 positions_double[old_tets[i][2]][2],
107 positions_double[old_tets[i][3]][0],
108 positions_double[old_tets[i][3]][1],
109 positions_double[old_tets[i][3]][2],
113 if (energy > old_energy_max) old_energy_max = energy;
117 for (
int i = 0; i < 6; ++i) {
119 positions[new_tets[i][0]],
120 positions[new_tets[i][1]],
121 positions[new_tets[i][2]],
122 positions[new_tets[i][3]]) > 0) {
124 positions_double[new_tets[i][0]][0],
125 positions_double[new_tets[i][0]][1],
126 positions_double[new_tets[i][0]][2],
127 positions_double[new_tets[i][1]][0],
128 positions_double[new_tets[i][1]][1],
129 positions_double[new_tets[i][1]][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],
139 if (energy > new_energy_max) new_energy_max = energy;
142 positions_double[new_tets[i][1]][0],
143 positions_double[new_tets[i][1]][1],
144 positions_double[new_tets[i][1]][2],
145 positions_double[new_tets[i][0]][0],
146 positions_double[new_tets[i][0]][1],
147 positions_double[new_tets[i][0]][2],
148 positions_double[new_tets[i][2]][0],
149 positions_double[new_tets[i][2]][1],
150 positions_double[new_tets[i][2]][2],
151 positions_double[new_tets[i][3]][0],
152 positions_double[new_tets[i][3]][1],
153 positions_double[new_tets[i][3]][2],
157 if (energy > new_energy_max) new_energy_max = energy;
161 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
const attribute::TypedAttributeHandle< Rational > m_coordinate_handle
Swap56EnergyBeforeInvariant(const Mesh &m, const attribute::TypedAttributeHandle< Rational > &coordinate, int64_t collapse_index, double eps=1.0001)
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