diff --git a/src/meshlabplugins/editsegment/cutting.h b/src/meshlabplugins/editsegment/cutting.h index 1b70689be..d90f31b27 100644 --- a/src/meshlabplugins/editsegment/cutting.h +++ b/src/meshlabplugins/editsegment/cutting.h @@ -84,7 +84,7 @@ namespace vcg { //last punta all'ultimo elemento valido --last; int num_to_remove = 0; - + while (iter != last){ if ((*iter).v->IMark() != U) { //elemento già marchiato, si può rimuovere dalla coda @@ -124,7 +124,9 @@ namespace vcg { private: MESH_TYPE * mesh; SimpleTempData *TDCurvPtr; - + + bool curvatureUpdate; + TripletHeap Q; float _normalWeight; float _curvatureWeight; @@ -158,9 +160,9 @@ namespace vcg { } - - //prende solo il più vicino - void AddNearestToQ(VertexType * v) { + + //prende solo il più vicino + void AddNearestToQ(VertexType * v) { float dist = 0.0f; float min_dist = std::numeric_limits::max(); @@ -196,37 +198,7 @@ namespace vcg { Q.push(tempTriplet); } } - /* - //prende tutti i vicini - void AddNearestToQ(VertexType * vs) { - float dist = 0.0f; - - vcg::face::JumpingPos pos(v->VFp(), v); - - VertexType* firstV = pos.VFlip(); - - VertexType* tempV=0; - - do { - pos.NextE(); - tempV = pos.VFlip(); - assert(tempV->P() != v->P()); - if (tempV->IMark() == U) { - dist = ImprovedIsophoticDist(v, tempV); - - CuttingTriplet tempTriplet; - tempTriplet.d = dist; - tempTriplet.v = tempV; - switch(v->IMark()) { - case iF: tempTriplet.m = F; break; - case iB: tempTriplet.m = B; break; - default : tempTriplet.m = (MarkType)v->IMark(); break; - } - Q.push(tempTriplet); - } - } while(tempV != firstV); - }*/ void AddNeighborhoodNearestToQ(VertexType * v /*,std::ofstream & file*/) { vcg::face::JumpingPos pos(v->VFp(), v); @@ -252,6 +224,7 @@ namespace vcg { _curvatureWeight = 5.0f; TDCurvPtr = new SimpleTempData((*mesh).vert); TDCurvPtr->Start(CurvData()); + curvatureUpdate = false; } ~MeshCutting() { @@ -292,32 +265,29 @@ namespace vcg { file.open("editsegment.log"); curvature_start_t = clock(); - //Computing principal curvatures and directions for all vertices - vcg::CurvatureTensorct(mesh, TDCurvPtr); - ct.ComputeCurvatureTensor(); - //now each vertex has principals curvatures and directions in its temp data - curvature_end_t = clock(); - //if (file) file << "Inizializzazione da input." << std::endl; + if (!curvatureUpdate) { + //Computing principal curvatures and directions for all vertices + vcg::CurvatureTensorct(mesh, TDCurvPtr); + ct.ComputeCurvatureTensor(); + curvatureUpdate = true; + //now each vertex has principals curvatures and directions in its temp data + } + curvature_end_t = clock(); //second iteration on the marked vertex for (vi=(*mesh).vert.begin(); vi!=(*mesh).vert.end(); ++vi) { if ( !vi->IsD() && (vi->IMark() != U)) - //AddNearestToQ(&(*vi),file); AddNearestToQ(&(*vi)); } - //if (file) file << "Fine inizializzazione da input. Elementi aggiunti: " << Q.size() << std::endl; - int step_counter = 0; while (vertex_to_go != 0) { //algorithm main loop if (Q.empty()) { - //if (file) file << "Coda vuota. Re-Inizializzazione." << std::endl; for (vi=(*mesh).vert.begin(); vi!=(*mesh).vert.end(); ++vi) { if ( !vi->IsD() && (vi->IMark() != U)) - //AddNearestToQ(&(*vi),file); AddNearestToQ(&(*vi)); } if (Q.empty()) break; @@ -332,13 +302,10 @@ namespace vcg { if (tempTriplet.v->IMark() == U) { tempTriplet.v->IMark() = tempTriplet.m; --vertex_to_go; - //if (file) file << "Estrazione: d=" << tempTriplet.d << std::endl; AddNearestToQ(tempTriplet.v/*, file*/); AddNeighborhoodNearestToQ(tempTriplet.v/*,file*/); - } else { - //if (file) file << "Estrazione: Elemento nullo" << std::endl; - } - + } + //rimozione degli elementi inutili nella coda ++step_counter; if (step_counter%30000 == 29999) { @@ -360,6 +327,12 @@ namespace vcg { } } + void UpdateCurvature() + { + vcg::CurvatureTensorct(mesh, TDCurvPtr); + ct.ComputeCurvatureTensor(); + } + void Colorize(bool selectForeground, bool doRefine) { FaceIterator fi; VertexIterator vi; @@ -517,8 +490,8 @@ namespace vcg { if (sec_prod != 0.0f) { if (tmp_face->FFp(sec_faceid)->IsS()) { tmp_face->SetS(); - } else { - tmp_face->ClearS(); + } else { + tmp_face->ClearS(); } tmp_face->ClearUserBit(bitflag); } else { diff --git a/src/meshlabplugins/editsegment/editsegment.cpp b/src/meshlabplugins/editsegment/editsegment.cpp index 3bc93dc63..bc98ea684 100644 --- a/src/meshlabplugins/editsegment/editsegment.cpp +++ b/src/meshlabplugins/editsegment/editsegment.cpp @@ -292,6 +292,9 @@ void EditSegment::StartEdit(QAction * mode, MeshModel & m, GLArea * parent) { meshcut_dock->setFloating(true); QObject::connect(meshCutDialog, SIGNAL(meshCutSignal()), this, SLOT(MeshCutSlot())); + + QObject::connect(meshCutDialog, SIGNAL(updateCurvatureSignal()), this, + SLOT(UpdateCurvatureSlot())); QObject::connect(meshCutDialog, SIGNAL(selectForegroundSignal(bool)),this, SLOT(SelectForegroundSlot(bool))); QObject::connect(meshCutDialog, SIGNAL(doRefineSignal(bool)),this, SLOT(doRefineSlot(bool))); @@ -501,6 +504,12 @@ void EditSegment::MeshCutSlot() { glarea->update(); } +void EditSegment::UpdateCurvatureSlot() { + if (meshCut) { + meshCut->UpdateCurvature(); + } +} + void EditSegment::SelectForegroundSlot(bool value) { selectForeground = value; } diff --git a/src/meshlabplugins/editsegment/editsegment.h b/src/meshlabplugins/editsegment/editsegment.h index 000642fce..e9dc9122a 100644 --- a/src/meshlabplugins/editsegment/editsegment.h +++ b/src/meshlabplugins/editsegment/editsegment.h @@ -85,6 +85,7 @@ public: public slots: void MeshCutSlot(); + void UpdateCurvatureSlot(); void SelectForegroundSlot(bool); void doRefineSlot(bool); void changeNormalWeight(int); diff --git a/src/meshlabplugins/editsegment/meshcutdialog.cpp b/src/meshlabplugins/editsegment/meshcutdialog.cpp index 43c65a7f9..d68238145 100644 --- a/src/meshlabplugins/editsegment/meshcutdialog.cpp +++ b/src/meshlabplugins/editsegment/meshcutdialog.cpp @@ -18,6 +18,10 @@ void MeshCutDialog::on_meshSegmentButton_clicked() { emit meshCutSignal(); } +void MeshCutDialog::on_updateCurvatureButton_clicked() { + emit updateCurvatureSignal(); +} + void MeshCutDialog::on_foreRadioButton_clicked() { emit selectForegroundSignal(true); } diff --git a/src/meshlabplugins/editsegment/meshcutdialog.h b/src/meshlabplugins/editsegment/meshcutdialog.h index 18406940b..2c7349314 100644 --- a/src/meshlabplugins/editsegment/meshcutdialog.h +++ b/src/meshlabplugins/editsegment/meshcutdialog.h @@ -22,6 +22,8 @@ private: public slots: void on_meshSegmentButton_clicked(); + void on_updateCurvatureButton_clicked(); + void on_foreRadioButton_clicked(); void on_backRadioButton_clicked(); @@ -38,6 +40,8 @@ private: signals: void meshCutSignal(); + void updateCurvatureSignal(); + void selectForegroundSignal(bool); void doRefineSignal(bool); void normalWeightSignal(int); diff --git a/src/meshlabplugins/editsegment/meshcutdialog.ui b/src/meshlabplugins/editsegment/meshcutdialog.ui index ef4377c05..97b6a8059 100644 --- a/src/meshlabplugins/editsegment/meshcutdialog.ui +++ b/src/meshlabplugins/editsegment/meshcutdialog.ui @@ -5,7 +5,7 @@ 0 0 - 139 + 167 269 @@ -17,7 +17,7 @@ 0 0 - 141 + 181 271 @@ -28,13 +28,13 @@ Basic - + - 12 - 16 - 116 - 153 + 10 + 18 + 138 + 184 @@ -81,23 +81,37 @@ - - - 10 - - - 1 - - - 2 - - - 5 - - - Qt::Horizontal - - + + + + + 10 + + + 1 + + + 2 + + + 5 + + + Qt::Horizontal + + + + + + + 10 + + + 5 + + + + @@ -108,6 +122,13 @@ + + + + Update Curvature + + + @@ -122,13 +143,13 @@ Advanced - + - 1 - 13 - 132 - 224 + 12 + 12 + 138 + 170 @@ -218,23 +239,37 @@ - - - 10 - - - 2 - - - 5 - - - Qt::Horizontal - - - 1 - - + + + + + 10 + + + 2 + + + 5 + + + Qt::Horizontal + + + 1 + + + + + + + 10 + + + 5 + + + + @@ -248,26 +283,57 @@ - - - 10 - - - 2 - - - 5 - - - Qt::Horizontal - - - 1 - - + + + + + 10 + + + 2 + + + 5 + + + Qt::Horizontal + + + 1 + + + + + + + 10 + + + 5 + + + + + + + + + + Debug + + + + + 10 + 20 + 141 + 54 + + + @@ -298,5 +364,102 @@ - + + + penRadiusSlider + valueChanged(int) + penRadiusSpinBox + setValue(int) + + + 88 + 120 + + + 116 + 120 + + + + + penRadiusSpinBox + valueChanged(int) + penRadiusSlider + setValue(int) + + + 123 + 129 + + + 89 + 130 + + + + + normalWeightSlider + valueChanged(int) + normalWeightSpinBox + setValue(int) + + + 77 + 141 + + + 100 + 142 + + + + + normalWeightSpinBox + valueChanged(int) + normalWeightSlider + setValue(int) + + + 115 + 151 + + + 79 + 153 + + + + + curvatureWeightSlider + valueChanged(int) + curvatureWeightSpinBox + setValue(int) + + + 78 + 191 + + + 104 + 192 + + + + + curvatureWeightSpinBox + valueChanged(int) + curvatureWeightSlider + setValue(int) + + + 118 + 201 + + + 79 + 201 + + + +