@@ -79,6 +79,7 @@ void ModeFixMask::StartMode()
7979 FormFixMask_InitAllItems ();
8080 FormFixMask_Show ();
8181 std::cout << " ModeFixMask...startMode DONE-----\n " ;
82+ std::cout << " Debug mode is available (Shift+Ctrl+F12).\n " ;
8283}
8384
8485
@@ -311,42 +312,30 @@ void ModeFixMask::KeyDown(int nChar)
311312
312313 if (nChar == VK_F1)
313314 {
314- // load state
315- if (IsShiftKeyOn () && IsCtrKeyOn ())
316- {
317- std::string fpath = " state.statelog" ;
318- std::set<int > set_frame_idx;
319- const int num_frames = ImageCore::GetInst ()->GetNumFrames ();
320- for (int i = 0 ; i < num_frames; ++i)
321- {
322- set_frame_idx.insert (i);
323- }
324-
325- LoadState (fpath, set_frame_idx);
326- }
315+ // show stroke matching
316+ const int frame_idx = formVisParam_getframeI ();
317+ std::vector<int > fixed_verts_idxs;
318+ m_matched_pos = std::vector<Eigen::Vector3f>();
319+ std::vector<EVec3f> target_pos = std::vector<Eigen::Vector3f>();
320+ FindClosestPointFromStroke (frame_idx, fixed_verts_idxs, target_pos, m_matched_pos);
327321 }
328322 else if (nChar == VK_F2)
329323 {
330- // save state
331- if (IsShiftKeyOn () && IsCtrKeyOn ())
324+ // deform all frame
325+ const int num_frames = ImageCore::GetInst ()->GetNumFrames ();
326+ for (int i = 0 ; i < num_frames; ++i)
332327 {
333- std::string fpath = " state.statelog" ;
334- std::set<int > set_frame_idx;
335- const int num_frames = ImageCore::GetInst ()->GetNumFrames ();
336- for (int i = 0 ; i < num_frames; ++i)
337- {
338- set_frame_idx.insert (i);
339- }
340- SaveState (fpath, set_frame_idx);
328+ Deform (i);
341329 }
342330 }
343331 else if (nChar == VK_F3)
344332 {
345- // show stroke matching
346- std::vector<int > fixed_verts_idxs;
347- m_matched_pos = std::vector<Eigen::Vector3f>();
348- std::vector<EVec3f> target_pos = std::vector<Eigen::Vector3f>();
349- FindClosestPointFromStroke (fixed_verts_idxs, target_pos, m_matched_pos);
333+ // deform all frame
334+ const int num_frames = ImageCore::GetInst ()->GetNumFrames ();
335+ for (int i = 0 ; i < num_frames; ++i)
336+ {
337+ ReloadMesh (i);
338+ }
350339 }
351340 else if (nChar == VK_F4)
352341 {
@@ -392,9 +381,9 @@ void ModeFixMask::KeyDown(int nChar)
392381 std::cout << " debug mode: " << (debug ? " ON" : " OFF" ) << " \n " ;
393382 if (debug)
394383 {
395- std::cout << " [F1] Load state (Shift+Ctrl+F1) " << " \n " ;
396- std::cout << " [F2] Save state (Shift+Ctrl+F2) " << " \n " ;
397- std::cout << " [F3] Show matching between strokes and mesh " << " \n " ;
384+ std::cout << " [F1] Show matching between strokes and mesh " << " \n " ;
385+ std::cout << " [F2] Deform mesh all frame " << " \n " ;
386+ std::cout << " [F3] Reload mesh all frame " << " \n " ;
398387 std::cout << " [F4] Share selected stroke" << " \n " ;
399388 std::cout << " [F5] Unshare selected stroke" << " \n " ;
400389 std::cout << " [F6] Lock selected stroke" << " \n " ;
@@ -466,7 +455,6 @@ void ModeFixMask::DrawScene(
466455 {
467456 m_strokes[frame_idx].DrawStrokes (m_show_only_selected_stroke);
468457
469- #ifdef DEBUG_MODE_FIXMASK
470458 for (int i = 0 ; i < m_matched_pos.size (); ++i)
471459 {
472460 static const float COLOR_W[4 ] = { 1 .0f , 1 .0f , 1 .0f , 0 .5f };
@@ -482,7 +470,6 @@ void ModeFixMask::DrawScene(
482470 TMesh::DrawSphere (m_matched_pos[i], 0 .3f );
483471 glDisable (GL_LIGHTING);
484472 }
485- #endif
486473 }
487474
488475 // draw control points
@@ -497,16 +484,21 @@ void ModeFixMask::DrawScene(
497484void ModeFixMask::Deform ()
498485{
499486 const int frame_idx = formVisParam_getframeI ();
487+ Deform (frame_idx);
488+ }
500489
490+
491+ void ModeFixMask::Deform (const int _frame_idx)
492+ {
501493 if (!m_exist_mesh || !m_mask_mesh.is_initialized ) return ;
502494
503- m_mask_mesh.GetMesh (frame_idx ).Set (m_tmeshes[frame_idx ]);
495+ m_mask_mesh.GetMesh (_frame_idx ).Set (m_tmeshes[_frame_idx ]);
504496
505497 std::vector<int > fixed_verts_idxs;
506498 std::vector<EVec3f> fixed_positions;
507499 std::vector<EVec3f> src_positions;
508500
509- FindClosestPointFromStroke (fixed_verts_idxs, fixed_positions, src_positions);
501+ FindClosestPointFromStroke (_frame_idx, fixed_verts_idxs, fixed_positions, src_positions);
510502
511503 // Sort by index
512504 std::vector<std::pair<int , EVec3f>> indexPointPairs;
@@ -528,7 +520,7 @@ void ModeFixMask::Deform()
528520 if (fixed_verts_idxs.size () == 0 ) return ;
529521
530522 // Deform
531- m_laplacian_deformer[frame_idx ].Deform (fixed_verts_idxs, fixed_positions);
523+ m_laplacian_deformer[_frame_idx ].Deform (fixed_verts_idxs, fixed_positions);
532524
533525 formMain_RedrawMainPanel ();
534526 formMain_ActivateMainForm ();
@@ -647,7 +639,6 @@ void ModeFixMask::ConvertMeshToMask()
647639void ModeFixMask::ReloadMesh ()
648640{
649641 const int frame_idx = formVisParam_getframeI ();
650-
651642 ReloadMesh (frame_idx);
652643}
653644
@@ -700,22 +691,20 @@ void ModeFixMask::SetShowOnlySelectedStroke()
700691
701692
702693
703- void ModeFixMask::FindClosestPointFromStroke (std::vector<int >& _idxs, std::vector<EVec3f>& _target_pos, std::vector<EVec3f>& _src_pos)
694+ void ModeFixMask::FindClosestPointFromStroke (const int _frame_idx, std::vector<int >& _idxs, std::vector<EVec3f>& _target_pos, std::vector<EVec3f>& _src_pos)
704695{
705- const int frame_idx = formVisParam_getframeI ();
706-
707696 if (!m_mask_mesh.is_initialized ) return ;
708697
709- TMesh& mesh = m_mask_mesh.GetMesh (frame_idx );
698+ TMesh& mesh = m_mask_mesh.GetMesh (_frame_idx );
710699
711- auto & strokes = m_strokes[frame_idx ].GetStroke ();
700+ auto & strokes = m_strokes[_frame_idx ].GetStroke ();
712701 const int num_stroke = strokes.size ();
713702
714703 // for stroke
715704 for (int i = 0 ; i < num_stroke; ++i) {
716705 const auto stroke = strokes[i];
717706 const int num_p = stroke.size ();
718- const int commonXYZ = m_strokes[frame_idx ].GetStrokeInst (i)->GetCommonXYZ ();
707+ const int commonXYZ = m_strokes[_frame_idx ].GetStrokeInst (i)->GetCommonXYZ ();
719708 const EVec3f vec0 = EVec3f (
720709 commonXYZ == 0 ? 1 .0f : 0 .0f ,
721710 commonXYZ == 1 ? 1 .0f : 0 .0f ,
0 commit comments