Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions COMMON/LaplacianSurfaceEditing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ void LaplacianDeformer::Deform(

m_times = 1;

if (!m_is_set_solver || m_fixed_verts_idxs != _fixed_verts_idxs)
{
SetSolver(_fixed_verts_idxs);
}
SetSolver(_fixed_verts_idxs);
Solve(_fixed_positions);

std::cout << "deformed...\n";
Expand Down
14 changes: 13 additions & 1 deletion RoiPainter4D/RoiPainter4D/FormFixMask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ System::Void FormFixMask::m_btn_sharestroke_Click(System::Object^ sender, System


System::Void FormFixMask::m_btn_loadstate_Click(System::Object^ sender, System::EventArgs^ e)
{
LoadState();
}


System::Void FormFixMask::m_btn_savestate_Click(System::Object^ sender, System::EventArgs^ e)
{
SaveState();
}


void FormFixMask::LoadState()
{
std::string fpath;

Expand All @@ -99,7 +111,7 @@ System::Void FormFixMask::m_btn_loadstate_Click(System::Object^ sender, System::
}


System::Void FormFixMask::m_btn_savestate_Click(System::Object^ sender, System::EventArgs^ e)
void FormFixMask::SaveState()
{
std::string fpath;

Expand Down
4 changes: 4 additions & 0 deletions RoiPainter4D/RoiPainter4D/FormFixMask.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ namespace RoiPainter4D {
System::Void m_btn_savestate_Click(System::Object^ sender, System::EventArgs^ e);
System::Void m_checkbox_showonlyselectedstroke_CheckedChanged(System::Object^ sender, System::EventArgs^ e);
public:
void LoadState();
void SaveState();
int GetCPSize();
bool GetShowOnlySelectedStroke();
int GetMCScale();
Expand All @@ -369,6 +371,8 @@ namespace RoiPainter4D {
inline void FormFixMask_Show() { FormFixMask::GetInst()->Show(); }
inline void FormFixMask_Hide() { FormFixMask::GetInst()->Hide(); }
inline void FormFixMask_InitAllItems() { FormFixMask::GetInst()->InitAllItems(); }
inline void FormFixMask_LoadState() { FormFixMask::GetInst()->LoadState(); }
inline void FormFixMask_SaveState() { FormFixMask::GetInst()->SaveState(); }
inline int FormFixMask_GetCPSize() { return FormFixMask::GetInst()->GetCPSize(); }
inline bool FormFixMask_GetShowOnlySelectedStroke() { return FormFixMask::GetInst()->GetShowOnlySelectedStroke(); }
inline int FormFixMask_GetMCScale() { return FormFixMask::GetInst()->GetMCScale(); }
Expand Down
75 changes: 32 additions & 43 deletions RoiPainter4D/RoiPainter4D/Mode/ModeFixMask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void ModeFixMask::StartMode()
FormFixMask_InitAllItems();
FormFixMask_Show();
std::cout << "ModeFixMask...startMode DONE-----\n";
std::cout << "Debug mode is available (Shift+Ctrl+F12).\n";
}


Expand Down Expand Up @@ -311,42 +312,30 @@ void ModeFixMask::KeyDown(int nChar)

if (nChar == VK_F1)
{
// load state
if (IsShiftKeyOn() && IsCtrKeyOn())
{
std::string fpath = "state.statelog";
std::set<int> set_frame_idx;
const int num_frames = ImageCore::GetInst()->GetNumFrames();
for (int i = 0; i < num_frames; ++i)
{
set_frame_idx.insert(i);
}

LoadState(fpath, set_frame_idx);
}
// show stroke matching
const int frame_idx = formVisParam_getframeI();
std::vector<int> fixed_verts_idxs;
m_matched_pos = std::vector<Eigen::Vector3f>();
std::vector<EVec3f> target_pos = std::vector<Eigen::Vector3f>();
FindClosestPointFromStroke(frame_idx, fixed_verts_idxs, target_pos, m_matched_pos);
}
else if (nChar == VK_F2)
{
// save state
if (IsShiftKeyOn() && IsCtrKeyOn())
// deform all frame
const int num_frames = ImageCore::GetInst()->GetNumFrames();
for (int i = 0; i < num_frames; ++i)
{
std::string fpath = "state.statelog";
std::set<int> set_frame_idx;
const int num_frames = ImageCore::GetInst()->GetNumFrames();
for (int i = 0; i < num_frames; ++i)
{
set_frame_idx.insert(i);
}
SaveState(fpath, set_frame_idx);
Deform(i);
}
}
else if (nChar == VK_F3)
{
// show stroke matching
std::vector<int> fixed_verts_idxs;
m_matched_pos = std::vector<Eigen::Vector3f>();
std::vector<EVec3f> target_pos = std::vector<Eigen::Vector3f>();
FindClosestPointFromStroke(fixed_verts_idxs, target_pos, m_matched_pos);
// deform all frame
const int num_frames = ImageCore::GetInst()->GetNumFrames();
for (int i = 0; i < num_frames; ++i)
{
ReloadMesh(i);
}
}
else if (nChar == VK_F4)
{
Expand Down Expand Up @@ -392,9 +381,9 @@ void ModeFixMask::KeyDown(int nChar)
std::cout << "debug mode: " << (debug ? "ON" : "OFF") << "\n";
if (debug)
{
std::cout << "[F1] Load state (Shift+Ctrl+F1)" << "\n";
std::cout << "[F2] Save state (Shift+Ctrl+F2)" << "\n";
std::cout << "[F3] Show matching between strokes and mesh" << "\n";
std::cout << "[F1] Show matching between strokes and mesh" << "\n";
std::cout << "[F2] Deform mesh all frame" << "\n";
std::cout << "[F3] Reload mesh all frame" << "\n";
std::cout << "[F4] Share selected stroke" << "\n";
std::cout << "[F5] Unshare selected stroke" << "\n";
std::cout << "[F6] Lock selected stroke" << "\n";
Expand Down Expand Up @@ -466,7 +455,6 @@ void ModeFixMask::DrawScene(
{
m_strokes[frame_idx].DrawStrokes(m_show_only_selected_stroke);

#ifdef DEBUG_MODE_FIXMASK
for (int i = 0; i < m_matched_pos.size(); ++i)
{
static const float COLOR_W[4] = { 1.0f, 1.0f, 1.0f, 0.5f };
Expand All @@ -482,7 +470,6 @@ void ModeFixMask::DrawScene(
TMesh::DrawSphere(m_matched_pos[i], 0.3f);
glDisable(GL_LIGHTING);
}
#endif
}

// draw control points
Expand All @@ -497,16 +484,21 @@ void ModeFixMask::DrawScene(
void ModeFixMask::Deform()
{
const int frame_idx = formVisParam_getframeI();
Deform(frame_idx);
}


void ModeFixMask::Deform(const int _frame_idx)
{
if (!m_exist_mesh || !m_mask_mesh.is_initialized) return;

m_mask_mesh.GetMesh(frame_idx).Set(m_tmeshes[frame_idx]);
m_mask_mesh.GetMesh(_frame_idx).Set(m_tmeshes[_frame_idx]);

std::vector<int> fixed_verts_idxs;
std::vector<EVec3f> fixed_positions;
std::vector<EVec3f> src_positions;

FindClosestPointFromStroke(fixed_verts_idxs, fixed_positions, src_positions);
FindClosestPointFromStroke(_frame_idx, fixed_verts_idxs, fixed_positions, src_positions);

// Sort by index
std::vector<std::pair<int, EVec3f>> indexPointPairs;
Expand All @@ -528,7 +520,7 @@ void ModeFixMask::Deform()
if (fixed_verts_idxs.size() == 0) return;

// Deform
m_laplacian_deformer[frame_idx].Deform(fixed_verts_idxs, fixed_positions);
m_laplacian_deformer[_frame_idx].Deform(fixed_verts_idxs, fixed_positions);

formMain_RedrawMainPanel();
formMain_ActivateMainForm();
Expand Down Expand Up @@ -647,7 +639,6 @@ void ModeFixMask::ConvertMeshToMask()
void ModeFixMask::ReloadMesh()
{
const int frame_idx = formVisParam_getframeI();

ReloadMesh(frame_idx);
}

Expand Down Expand Up @@ -700,22 +691,20 @@ void ModeFixMask::SetShowOnlySelectedStroke()



void ModeFixMask::FindClosestPointFromStroke(std::vector<int>& _idxs, std::vector<EVec3f>& _target_pos, std::vector<EVec3f>& _src_pos)
void ModeFixMask::FindClosestPointFromStroke(const int _frame_idx, std::vector<int>& _idxs, std::vector<EVec3f>& _target_pos, std::vector<EVec3f>& _src_pos)
{
const int frame_idx = formVisParam_getframeI();

if (!m_mask_mesh.is_initialized) return;

TMesh& mesh = m_mask_mesh.GetMesh(frame_idx);
TMesh& mesh = m_mask_mesh.GetMesh(_frame_idx);

auto& strokes = m_strokes[frame_idx].GetStroke();
auto& strokes = m_strokes[_frame_idx].GetStroke();
const int num_stroke = strokes.size();

// for stroke
for (int i = 0; i < num_stroke; ++i) {
const auto stroke = strokes[i];
const int num_p = stroke.size();
const int commonXYZ = m_strokes[frame_idx].GetStrokeInst(i)->GetCommonXYZ();
const int commonXYZ = m_strokes[_frame_idx].GetStrokeInst(i)->GetCommonXYZ();
const EVec3f vec0 = EVec3f(
commonXYZ == 0 ? 1.0f : 0.0f,
commonXYZ == 1 ? 1.0f : 0.0f,
Expand Down
3 changes: 2 additions & 1 deletion RoiPainter4D/RoiPainter4D/Mode/ModeFixMask.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class ModeFixMask :
void DrawScene(const EVec3f& cuboid, const EVec3f& camP, const EVec3f& camF);
// -----------------------------------------------------------------
void Deform();
void Deform(const int);

void Do();
void Undo();
Expand All @@ -112,7 +113,7 @@ class ModeFixMask :


private:
void FindClosestPointFromStroke(std::vector<int>&, std::vector<EVec3f>&, std::vector<EVec3f>&);
void FindClosestPointFromStroke(const int, std::vector<int>&, std::vector<EVec3f>&, std::vector<EVec3f>&);

//Add?

Expand Down
Binary file added RoiPainter4D/x64/Release/zlib1.dll
Binary file not shown.