|
@@ -7,41 +7,41 @@
|
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
#include "scaf.h"
|
|
#include "scaf.h"
|
|
|
|
|
+#include "triangulate.h"
|
|
|
|
|
|
|
|
#include <Eigen/Dense>
|
|
#include <Eigen/Dense>
|
|
|
#include <Eigen/IterativeLinearSolvers>
|
|
#include <Eigen/IterativeLinearSolvers>
|
|
|
#include <Eigen/Sparse>
|
|
#include <Eigen/Sparse>
|
|
|
#include <Eigen/SparseCholesky>
|
|
#include <Eigen/SparseCholesky>
|
|
|
#include <Eigen/SparseQR>
|
|
#include <Eigen/SparseQR>
|
|
|
-#include <igl/PI.h>
|
|
|
|
|
-#include <igl/Timer.h>
|
|
|
|
|
-#include <igl/boundary_loop.h>
|
|
|
|
|
-#include <igl/cat.h>
|
|
|
|
|
-#include <igl/doublearea.h>
|
|
|
|
|
-#include <igl/flip_avoiding_line_search.h>
|
|
|
|
|
-#include <igl/flipped_triangles.h>
|
|
|
|
|
-#include <igl/grad.h>
|
|
|
|
|
-#include <igl/harmonic.h>
|
|
|
|
|
-#include <igl/local_basis.h>
|
|
|
|
|
-#include <igl/map_vertices_to_circle.h>
|
|
|
|
|
-#include <igl/polar_svd.h>
|
|
|
|
|
-#include <igl/slice.h>
|
|
|
|
|
-#include <igl/slice_into.h>
|
|
|
|
|
-#include <igl/slim.h>
|
|
|
|
|
-#include <igl/triangle/triangulate.h>
|
|
|
|
|
-#include "mapping_energy_with_jacobians.h"
|
|
|
|
|
-
|
|
|
|
|
-#include <iostream>
|
|
|
|
|
|
|
+#include "../PI.h"
|
|
|
|
|
+#include "../Timer.h"
|
|
|
|
|
+#include "../boundary_loop.h"
|
|
|
|
|
+#include "../cat.h"
|
|
|
|
|
+#include "../doublearea.h"
|
|
|
|
|
+#include "../flip_avoiding_line_search.h"
|
|
|
|
|
+#include "../flipped_triangles.h"
|
|
|
|
|
+#include "../grad.h"
|
|
|
|
|
+#include "../harmonic.h"
|
|
|
|
|
+#include "../local_basis.h"
|
|
|
|
|
+#include "../map_vertices_to_circle.h"
|
|
|
|
|
+#include "../polar_svd.h"
|
|
|
|
|
+#include "../slice.h"
|
|
|
|
|
+#include "../slice_into.h"
|
|
|
|
|
+#include "../slim.h"
|
|
|
|
|
+#include "../mapping_energy_with_jacobians.h"
|
|
|
|
|
+
|
|
|
#include <map>
|
|
#include <map>
|
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
|
#include <set>
|
|
#include <set>
|
|
|
#include <vector>
|
|
#include <vector>
|
|
|
namespace igl
|
|
namespace igl
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+namespace triangle
|
|
|
|
|
+{
|
|
|
namespace scaf
|
|
namespace scaf
|
|
|
{
|
|
{
|
|
|
-IGL_INLINE void update_scaffold(igl::SCAFData &s)
|
|
|
|
|
|
|
+IGL_INLINE void update_scaffold(igl::triangle::SCAFData &s)
|
|
|
{
|
|
{
|
|
|
s.mv_num = s.m_V.rows();
|
|
s.mv_num = s.m_V.rows();
|
|
|
s.mf_num = s.m_T.rows();
|
|
s.mf_num = s.m_T.rows();
|
|
@@ -137,7 +137,7 @@ IGL_INLINE void compute_scaffold_gradient_matrix(SCAFData &s,
|
|
|
F2.col(2).asDiagonal() * Dz;
|
|
F2.col(2).asDiagonal() * Dz;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-IGL_INLINE void mesh_improve(igl::SCAFData &s)
|
|
|
|
|
|
|
+IGL_INLINE void mesh_improve(igl::triangle::SCAFData &s)
|
|
|
{
|
|
{
|
|
|
using namespace Eigen;
|
|
using namespace Eigen;
|
|
|
MatrixXd m_uv = s.w_uv.topRows(s.mv_num);
|
|
MatrixXd m_uv = s.w_uv.topRows(s.mv_num);
|
|
@@ -245,7 +245,7 @@ IGL_INLINE void mesh_improve(igl::SCAFData &s)
|
|
|
s.W_s.resize(s.Dx_s.rows(), s.dim * s.dim);
|
|
s.W_s.resize(s.Dx_s.rows(), s.dim * s.dim);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-IGL_INLINE void add_new_patch(igl::SCAFData &s, const Eigen::MatrixXd &V_ref,
|
|
|
|
|
|
|
+IGL_INLINE void add_new_patch(igl::triangle::SCAFData &s, const Eigen::MatrixXd &V_ref,
|
|
|
const Eigen::MatrixXi &F_ref,
|
|
const Eigen::MatrixXi &F_ref,
|
|
|
const Eigen::RowVectorXd ¢er,
|
|
const Eigen::RowVectorXd ¢er,
|
|
|
const Eigen::MatrixXd &uv_init)
|
|
const Eigen::MatrixXd &uv_init)
|
|
@@ -617,14 +617,15 @@ IGL_INLINE double perform_iteration(SCAFData &s)
|
|
|
s.mesh_measure;
|
|
s.mesh_measure;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-IGL_INLINE void igl::scaf_precompute(
|
|
|
|
|
|
|
+IGL_INLINE void igl::triangle::scaf_precompute(
|
|
|
const Eigen::MatrixXd &V,
|
|
const Eigen::MatrixXd &V,
|
|
|
const Eigen::MatrixXi &F,
|
|
const Eigen::MatrixXi &F,
|
|
|
const Eigen::MatrixXd &V_init,
|
|
const Eigen::MatrixXd &V_init,
|
|
|
- igl::SCAFData &data,
|
|
|
|
|
|
|
+ igl::triangle::SCAFData &data,
|
|
|
igl::MappingEnergyType slim_energy,
|
|
igl::MappingEnergyType slim_energy,
|
|
|
Eigen::VectorXi &b,
|
|
Eigen::VectorXi &b,
|
|
|
Eigen::MatrixXd &bc,
|
|
Eigen::MatrixXd &bc,
|
|
@@ -632,7 +633,7 @@ IGL_INLINE void igl::scaf_precompute(
|
|
|
{
|
|
{
|
|
|
Eigen::MatrixXd CN;
|
|
Eigen::MatrixXd CN;
|
|
|
Eigen::MatrixXi FN;
|
|
Eigen::MatrixXi FN;
|
|
|
- igl::scaf::add_new_patch(data, V, F, Eigen::RowVector2d(0, 0), V_init);
|
|
|
|
|
|
|
+ igl::triangle::scaf::add_new_patch(data, V, F, Eigen::RowVector2d(0, 0), V_init);
|
|
|
data.soft_const_p = soft_p;
|
|
data.soft_const_p = soft_p;
|
|
|
for (int i = 0; i < b.rows(); i++)
|
|
for (int i = 0; i < b.rows(); i++)
|
|
|
data.soft_cons[b(i)] = bc.row(i);
|
|
data.soft_cons[b(i)] = bc.row(i);
|
|
@@ -664,7 +665,7 @@ IGL_INLINE void igl::scaf_precompute(
|
|
|
s.Dx_m = face_proj(F1) * G;
|
|
s.Dx_m = face_proj(F1) * G;
|
|
|
s.Dy_m = face_proj(F2) * G;
|
|
s.Dy_m = face_proj(F2) * G;
|
|
|
|
|
|
|
|
- igl::scaf::compute_scaffold_gradient_matrix(s, s.Dx_s, s.Dy_s);
|
|
|
|
|
|
|
+ igl::triangle::scaf::compute_scaffold_gradient_matrix(s, s.Dx_s, s.Dy_s);
|
|
|
|
|
|
|
|
s.Dx_m.makeCompressed();
|
|
s.Dx_m.makeCompressed();
|
|
|
s.Dy_m.makeCompressed();
|
|
s.Dy_m.makeCompressed();
|
|
@@ -682,48 +683,48 @@ IGL_INLINE void igl::scaf_precompute(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-IGL_INLINE Eigen::MatrixXd igl::scaf_solve(SCAFData &s, int iter_num)
|
|
|
|
|
|
|
+IGL_INLINE Eigen::MatrixXd igl::triangle::scaf_solve(igl::triangle::SCAFData &s, int iter_num)
|
|
|
{
|
|
{
|
|
|
using namespace std;
|
|
using namespace std;
|
|
|
using namespace Eigen;
|
|
using namespace Eigen;
|
|
|
- s.energy = igl::scaf::compute_energy(s, s.w_uv, false) / s.mesh_measure;
|
|
|
|
|
|
|
+ s.energy = igl::triangle::scaf::compute_energy(s, s.w_uv, false) / s.mesh_measure;
|
|
|
|
|
|
|
|
for (int it = 0; it < iter_num; it++)
|
|
for (int it = 0; it < iter_num; it++)
|
|
|
{
|
|
{
|
|
|
- s.total_energy = igl::scaf::compute_energy(s, s.w_uv, true) / s.mesh_measure;
|
|
|
|
|
|
|
+ s.total_energy = igl::triangle::scaf::compute_energy(s, s.w_uv, true) / s.mesh_measure;
|
|
|
s.rect_frame_V = Eigen::MatrixXd();
|
|
s.rect_frame_V = Eigen::MatrixXd();
|
|
|
- igl::scaf::mesh_improve(s);
|
|
|
|
|
|
|
+ igl::triangle::scaf::mesh_improve(s);
|
|
|
|
|
|
|
|
double new_weight = s.mesh_measure * s.energy / (s.sf_num * 100);
|
|
double new_weight = s.mesh_measure * s.energy / (s.sf_num * 100);
|
|
|
s.scaffold_factor = new_weight;
|
|
s.scaffold_factor = new_weight;
|
|
|
- igl::scaf::update_scaffold(s);
|
|
|
|
|
|
|
+ igl::triangle::scaf::update_scaffold(s);
|
|
|
|
|
|
|
|
- s.total_energy = igl::scaf::perform_iteration(s);
|
|
|
|
|
|
|
+ s.total_energy = igl::triangle::scaf::perform_iteration(s);
|
|
|
|
|
|
|
|
s.energy =
|
|
s.energy =
|
|
|
- igl::scaf::compute_energy(s, s.w_uv, false) / s.mesh_measure;
|
|
|
|
|
|
|
+ igl::triangle::scaf::compute_energy(s, s.w_uv, false) / s.mesh_measure;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return s.w_uv.topRows(s.mv_num);
|
|
return s.w_uv.topRows(s.mv_num);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-IGL_INLINE void igl::scaf_system(SCAFData &s, Eigen::SparseMatrix<double> &L, Eigen::VectorXd &rhs)
|
|
|
|
|
|
|
+IGL_INLINE void igl::triangle::scaf_system(igl::triangle::SCAFData &s, Eigen::SparseMatrix<double> &L, Eigen::VectorXd &rhs)
|
|
|
{
|
|
{
|
|
|
- s.energy = igl::scaf::compute_energy(s, s.w_uv, false) / s.mesh_measure;
|
|
|
|
|
|
|
+ s.energy = igl::triangle::scaf::compute_energy(s, s.w_uv, false) / s.mesh_measure;
|
|
|
|
|
|
|
|
- s.total_energy = igl::scaf::compute_energy(s, s.w_uv, true) / s.mesh_measure;
|
|
|
|
|
|
|
+ s.total_energy = igl::triangle::scaf::compute_energy(s, s.w_uv, true) / s.mesh_measure;
|
|
|
s.rect_frame_V = Eigen::MatrixXd();
|
|
s.rect_frame_V = Eigen::MatrixXd();
|
|
|
- igl::scaf::mesh_improve(s);
|
|
|
|
|
|
|
+ igl::triangle::scaf::mesh_improve(s);
|
|
|
|
|
|
|
|
double new_weight = s.mesh_measure * s.energy / (s.sf_num * 100);
|
|
double new_weight = s.mesh_measure * s.energy / (s.sf_num * 100);
|
|
|
s.scaffold_factor = new_weight;
|
|
s.scaffold_factor = new_weight;
|
|
|
- igl::scaf::update_scaffold(s);
|
|
|
|
|
|
|
+ igl::triangle::scaf::update_scaffold(s);
|
|
|
|
|
|
|
|
- igl::scaf::compute_jacobians(s, s.w_uv, true);
|
|
|
|
|
|
|
+ igl::triangle::scaf::compute_jacobians(s, s.w_uv, true);
|
|
|
igl::slim_update_weights_and_closest_rotations_with_jacobians(s.Ji_m, s.slim_energy, 0, s.W_m, s.Ri_m);
|
|
igl::slim_update_weights_and_closest_rotations_with_jacobians(s.Ji_m, s.slim_energy, 0, s.W_m, s.Ri_m);
|
|
|
igl::slim_update_weights_and_closest_rotations_with_jacobians(s.Ji_s, s.scaf_energy, 0, s.W_s, s.Ri_s);
|
|
igl::slim_update_weights_and_closest_rotations_with_jacobians(s.Ji_s, s.scaf_energy, 0, s.W_s, s.Ri_s);
|
|
|
|
|
|
|
|
- igl::scaf::build_weighted_arap_system(s, L, rhs);
|
|
|
|
|
|
|
+ igl::triangle::scaf::build_weighted_arap_system(s, L, rhs);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
#ifdef IGL_STATIC_LIBRARY
|