~mht/surcut

d1179f6724c0ba3c88358d2a71bb8baecaa6e212 — Martin Hafskjold Thoresen 4 years ago cabf621
Add Update Rest State button
1 files changed, 35 insertions(+), 25 deletions(-)

M main.cpp
M main.cpp => main.cpp +35 -25
@@ 123,7 123,11 @@ void draw_menu() {
    compute_things(U, TF);
  }

  if (ImGui::Button("Step ARAP")) {
  if (ImGui::Button("Update Rest State")) {
    arap::precomputation(U, TT, TV.cols(), boundary, arap_data);
  }

  if (ImGui::Button("Step ARAP"))
    step_arap();
    compute_things(U, TF);
  }


@@ 131,8 135,8 @@ void draw_menu() {
  // if (ImGui::Button("Ensure Moldability"))
  //   ensure_moldability();

  if (ImGui::Button("Remesh"))
    remesh();
  // if (ImGui::Button("Remesh"))
  //   remesh();

  ImGui::Checkbox("Blend rotations", &arap_args.should_blend);
  if (arap_args.should_blend) {


@@ 271,6 275,12 @@ void compute_things(Eigen::MatrixXd &vertices, Eigen::MatrixXi &faces,
  }
}

// Here we look at the faces that are not moldable, and try to match them up with nearby faces; by
// joining up faces like this we hope to fill in cavities, such that the final object is moldalbe.
void merge_step() {

}

// This is called before each draw call. Compute normals and set right colors.
// XXX(note): much of this should probably just be done after `step_arap`, since
// the rest is pretty constant.


@@ 514,27 524,27 @@ int ray_intersect(Eigen::Vector3d v, Eigen::Vector3d p,
  return -1;
}

// Remesh the model based on the deformed version.
// WARNING: THIS WILL DESTROY THE ORIGINAL MODEL, SO `reset` DOES NOTHING!
void remesh() {
  TetmeshIn tetmesh_in;
  TetmeshOut tetmesh_out;
  tetmesh_in.vertices = &U;
  tetmesh_in.faces = &TF;

  int error = make_tetmesh(tetmesh_in, tetmesh_out);
  if (error) {
    std::cerr << "[ERR] tetesh returned " << error << std::endl;
    exit(1);
  }

  TV = tetmesh_out.vertices;
  U = TV;
  TT = tetmesh_out.tets;
  TF = tetmesh_out.faces;
  TF2T = tetmesh_out.face2tets;
  TT2F = tetmesh_out.tet2faces;
}
// // Remesh the model based on the deformed version.
// // WARNING: THIS WILL DESTROY THE ORIGINAL MODEL, SO `reset` DOES NOTHING!
// void remesh() {  NOTE: This is not remeshing, but triangulating..
//   TetmeshIn tetmesh_in;
//   TetmeshOut tetmesh_out;
//   tetmesh_in.vertices = &U;
//   tetmesh_in.faces = &TF;
// 
//   int error = make_tetmesh(tetmesh_in, tetmesh_out);
//   if (error) {
//     std::cerr << "[ERR] tetesh returned " << error << std::endl;
//     exit(1);
//   }
// 
//   TV = tetmesh_out.vertices;
//   U = TV;
//   TT = tetmesh_out.tets;
//   TF = tetmesh_out.faces;
//   TF2T = tetmesh_out.face2tets;
//   TT2F = tetmesh_out.tet2faces;
// }

int main(int argc, char *argv[]) {
  int error;


@@ 587,7 597,7 @@ int main(int argc, char *argv[]) {
  // arap_data.with_dynamics = true;
  // arap_data.h = 0.01;
  arap::precomputation(TV, TT, TV.cols(), boundary, arap_data);
  arap_data.U0 = TV;
  // arap_data.U0 = TV;

  arap_data.vert_is_above = &is_point_above;
  arap_data.moldable = &moldable;