Added an "update curvature" button

This commit is contained in:
Paolo Cignoni cignoni 2008-03-31 07:12:48 +00:00
parent 0dd541c568
commit 7ddbb183eb
6 changed files with 271 additions and 117 deletions

View File

@ -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<VertContainer, CurvData> *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<float>::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<FaceType> 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<VertexType> 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<FaceType> pos(v->VFp(), v);
@ -252,6 +224,7 @@ namespace vcg {
_curvatureWeight = 5.0f;
TDCurvPtr = new SimpleTempData<VertContainer, CurvData>((*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::CurvatureTensor<MESH_TYPE>ct(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::CurvatureTensor<MESH_TYPE>ct(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::CurvatureTensor<MESH_TYPE>ct(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 {

View File

@ -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;
}

View File

@ -85,6 +85,7 @@ public:
public slots:
void MeshCutSlot();
void UpdateCurvatureSlot();
void SelectForegroundSlot(bool);
void doRefineSlot(bool);
void changeNormalWeight(int);

View File

@ -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);
}

View File

@ -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);

View File

@ -5,7 +5,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>139</width>
<width>167</width>
<height>269</height>
</rect>
</property>
@ -17,7 +17,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>141</width>
<width>181</width>
<height>271</height>
</rect>
</property>
@ -28,13 +28,13 @@
<attribute name="title" >
<string>Basic</string>
</attribute>
<widget class="QWidget" name="layoutWidget" >
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>12</x>
<y>16</y>
<width>116</width>
<height>153</height>
<x>10</x>
<y>18</y>
<width>138</width>
<height>184</height>
</rect>
</property>
<layout class="QVBoxLayout" >
@ -81,23 +81,37 @@
</widget>
</item>
<item>
<widget class="QSlider" name="penRadiusSlider" >
<property name="maximum" >
<number>10</number>
</property>
<property name="singleStep" >
<number>1</number>
</property>
<property name="pageStep" >
<number>2</number>
</property>
<property name="value" >
<number>5</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
<layout class="QHBoxLayout" >
<item>
<widget class="QSlider" name="penRadiusSlider" >
<property name="maximum" >
<number>10</number>
</property>
<property name="singleStep" >
<number>1</number>
</property>
<property name="pageStep" >
<number>2</number>
</property>
<property name="value" >
<number>5</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="penRadiusSpinBox" >
<property name="maximum" >
<number>10</number>
</property>
<property name="value" >
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
@ -108,6 +122,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="updateCurvatureButton" >
<property name="text" >
<string>Update Curvature</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetButton" >
<property name="text" >
@ -122,13 +143,13 @@
<attribute name="title" >
<string>Advanced</string>
</attribute>
<widget class="QWidget" name="layoutWidget" >
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>1</x>
<y>13</y>
<width>132</width>
<height>224</height>
<x>12</x>
<y>12</y>
<width>138</width>
<height>170</height>
</rect>
</property>
<layout class="QVBoxLayout" >
@ -218,23 +239,37 @@
</widget>
</item>
<item>
<widget class="QSlider" name="normalWeightSlider" >
<property name="maximum" >
<number>10</number>
</property>
<property name="pageStep" >
<number>2</number>
</property>
<property name="value" >
<number>5</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="tickInterval" >
<number>1</number>
</property>
</widget>
<layout class="QHBoxLayout" >
<item>
<widget class="QSlider" name="normalWeightSlider" >
<property name="maximum" >
<number>10</number>
</property>
<property name="pageStep" >
<number>2</number>
</property>
<property name="value" >
<number>5</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="tickInterval" >
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="normalWeightSpinBox" >
<property name="maximum" >
<number>10</number>
</property>
<property name="value" >
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
@ -248,26 +283,57 @@
</widget>
</item>
<item>
<widget class="QSlider" name="curvatureWeightSlider" >
<property name="maximum" >
<number>10</number>
</property>
<property name="pageStep" >
<number>2</number>
</property>
<property name="value" >
<number>5</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="tickInterval" >
<number>1</number>
</property>
</widget>
<layout class="QHBoxLayout" >
<item>
<widget class="QSlider" name="curvatureWeightSlider" >
<property name="maximum" >
<number>10</number>
</property>
<property name="pageStep" >
<number>2</number>
</property>
<property name="value" >
<number>5</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="tickInterval" >
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="curvatureWeightSpinBox" >
<property name="maximum" >
<number>10</number>
</property>
<property name="value" >
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="debugTab" >
<attribute name="title" >
<string>Debug</string>
</attribute>
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>10</x>
<y>20</y>
<width>141</width>
<height>54</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QPushButton" name="gaussianButton" >
<property name="text" >
@ -298,5 +364,102 @@
<resources>
<include location="meshlab.qrc" />
</resources>
<connections/>
<connections>
<connection>
<sender>penRadiusSlider</sender>
<signal>valueChanged(int)</signal>
<receiver>penRadiusSpinBox</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>88</x>
<y>120</y>
</hint>
<hint type="destinationlabel" >
<x>116</x>
<y>120</y>
</hint>
</hints>
</connection>
<connection>
<sender>penRadiusSpinBox</sender>
<signal>valueChanged(int)</signal>
<receiver>penRadiusSlider</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>123</x>
<y>129</y>
</hint>
<hint type="destinationlabel" >
<x>89</x>
<y>130</y>
</hint>
</hints>
</connection>
<connection>
<sender>normalWeightSlider</sender>
<signal>valueChanged(int)</signal>
<receiver>normalWeightSpinBox</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>77</x>
<y>141</y>
</hint>
<hint type="destinationlabel" >
<x>100</x>
<y>142</y>
</hint>
</hints>
</connection>
<connection>
<sender>normalWeightSpinBox</sender>
<signal>valueChanged(int)</signal>
<receiver>normalWeightSlider</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>115</x>
<y>151</y>
</hint>
<hint type="destinationlabel" >
<x>79</x>
<y>153</y>
</hint>
</hints>
</connection>
<connection>
<sender>curvatureWeightSlider</sender>
<signal>valueChanged(int)</signal>
<receiver>curvatureWeightSpinBox</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>78</x>
<y>191</y>
</hint>
<hint type="destinationlabel" >
<x>104</x>
<y>192</y>
</hint>
</hints>
</connection>
<connection>
<sender>curvatureWeightSpinBox</sender>
<signal>valueChanged(int)</signal>
<receiver>curvatureWeightSlider</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel" >
<x>118</x>
<y>201</y>
</hint>
<hint type="destinationlabel" >
<x>79</x>
<y>201</y>
</hint>
</hints>
</connection>
</connections>
</ui>