Skip to content

Commit a01e0ca

Browse files
committed
Changed metric interface
1 parent c8c0496 commit a01e0ca

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

src/optimization/cone_metric.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ bool DifferentiableConeMetric::flip_ccw(int _h, bool Ptolemy)
8282
return Mesh<Scalar>::flip_ccw(_h, Ptolemy);
8383
}
8484

85+
void DifferentiableConeMetric::undo_flips()
86+
{
87+
std::vector<int> flip_seq = m_flip_seq;
88+
for (auto h_iter = flip_seq.rbegin(); h_iter != flip_seq.rend(); ++h_iter) {
89+
int h = *h_iter;
90+
flip_ccw(h);
91+
flip_ccw(h);
92+
flip_ccw(h);
93+
}
94+
m_flip_seq = {};
95+
}
96+
97+
8598
bool DifferentiableConeMetric::constraint(
8699
VectorX& constraint,
87100
MatrixX& J_constraint,

src/optimization/cone_metric.hh

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public:
2626

2727
// Flip method: need to be able to flip metric
2828
virtual bool flip_ccw(int _h, bool Ptolemy = true);
29+
void undo_flips();
2930

3031
// Metric change methods: need to be able to clone metric and change metric coordinates
3132
virtual std::unique_ptr<DifferentiableConeMetric> clone_cone_metric() const = 0;
@@ -88,7 +89,40 @@ public:
8889

8990
bool flip_ccw(int _h, bool Ptolemy = true) override;
9091

91-
private:
92+
MatrixX get_flip_jacobian() const
93+
{
94+
typedef Eigen::Triplet<Scalar> T;
95+
std::vector<T> tripletList;
96+
int num_edges = e2he.size();
97+
tripletList.reserve(5 * num_edges);
98+
for (int i = 0; i < num_edges; ++i) {
99+
for (auto it : m_transition_jacobian_lol[i]) {
100+
tripletList.push_back(T(i, it.first, it.second));
101+
}
102+
}
103+
104+
// Create the matrix from the triplets
105+
MatrixX transition_jacobian;
106+
transition_jacobian.resize(num_edges, num_edges);
107+
transition_jacobian.reserve(tripletList.size());
108+
transition_jacobian.setFromTriplets(tripletList.begin(), tripletList.end());
109+
110+
return transition_jacobian;
111+
}
112+
113+
// Reset Jacobian
114+
void reset()
115+
{
116+
// Initialize jacobian to the identity
117+
int num_edges = e2he.size();
118+
m_transition_jacobian_lol =
119+
std::vector<std::map<int, Scalar>>(num_edges, std::map<int, Scalar>());
120+
for (int e = 0; e < num_edges; ++e) {
121+
m_transition_jacobian_lol[e][e] = 1.0;
122+
}
123+
}
124+
125+
protected:
92126
std::vector<int> m_embed;
93127
std::vector<int> m_proj;
94128
MatrixX m_projection;
@@ -122,7 +156,7 @@ public:
122156

123157
bool flip_ccw(int _h, bool Ptolemy = true) override;
124158

125-
private:
159+
protected:
126160
std::vector<int> m_embed;
127161
std::vector<int> m_proj;
128162
MatrixX m_projection;

src/optimization/layout.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ bool check_uv(
140140
}
141141

142142
// Check length consistency
143-
if (!float_equal(compute_uv_length_error(F, uv, F_uv), 0.0)) {
144-
spdlog::warn("Inconsistent uv lengths across edges");
143+
double uv_length_error = compute_uv_length_error(F, uv, F_uv);
144+
if (!float_equal(uv_length_error, 0.0)) {
145+
spdlog::warn("Inconsistent uv length error {} across edges", uv_length_error);
145146
}
146147

147148
// Check mesh face areas

0 commit comments

Comments
 (0)