it's now possible to change the value of the curvature and normal weights in the isophotic-distance function

This commit is contained in:
Paolo Cignoni cignoni 2008-01-07 11:38:33 +00:00
parent f9df63adfb
commit 889e031fc4
6 changed files with 112 additions and 17 deletions

View File

@ -118,15 +118,14 @@ namespace vcg {
SimpleTempData<VertContainer, CurvData> *TDCurvPtr;
//TripletQueue Q;
TripletHeap Q;
float _normalWeight;
float _curvatureWeight;
float ImprovedIsophoticDist(VertexType * p, VertexType * q) {
float dist;
float kpq = 0.0f;
const float e = 2.71828182845904523536;
const float W1 = 5.0f;
const float W2 = 5.0f;
Matrix33<float> n_nMatrix;
Point3<float> ViVj = p->P() - q->P();
Point3<float> Tij;
@ -146,7 +145,7 @@ namespace vcg {
if (kpq < 0)
kpq = powf(e,fabs(kpq)) -1;
dist = (p->P() - q->P()).Norm() + (W1 * (p->N() - q->N()).Norm()) + (W2 * kpq);
dist = (p->P() - q->P()).Norm() + (_normalWeight * (p->N() - q->N()).Norm()) + (_curvatureWeight * kpq);
assert(dist>=0.0f);
return dist;
@ -213,6 +212,8 @@ namespace vcg {
MeshCutting(MESH_TYPE * ms) {
mesh = ms;
_normalWeight = 5.0f;
_curvatureWeight = 5.0f;
TDCurvPtr = new SimpleTempData<VertContainer, CurvData>((*mesh).vert);
TDCurvPtr->Start(CurvData());
}
@ -225,7 +226,10 @@ namespace vcg {
v->IMark() = m;
}
void MeshCut() {
void MeshCut(float NormalWeight, float CurvatureWeight) {
_normalWeight = NormalWeight;
_curvatureWeight = CurvatureWeight;
clock_t curvature_start_t;
clock_t curvature_end_t;

View File

@ -244,6 +244,9 @@ EditSegment::EditSegment() {
meshCutDialog = 0;
meshcut_dock = 0;
normalWeight = 5;
curvatureWeight = 5;
selectForeground = true;
doRefine = true;
}
@ -302,6 +305,8 @@ void EditSegment::StartEdit(QAction * mode, MeshModel & m, GLArea * parent) {
SLOT(ColorizeGaussianSlot()));
QObject::connect(meshCutDialog, SIGNAL(colorizeMeanSignal()), this,
SLOT(ColorizeMeanSlot()));
QObject::connect(meshCutDialog, SIGNAL(normalWeightSignal(int)),this, SLOT(changeNormalWeight(int)));
QObject::connect(meshCutDialog, SIGNAL(curvatureWeightSignal(int)),this, SLOT(changeCurvatureWeight(int)));
}
meshcut_dock->setVisible(true);
@ -502,7 +507,7 @@ void EditSegment::DrawXORCircle(MeshModel &m, GLArea * gla, bool doubleDraw) {
void EditSegment::MeshCutSlot() {
if (meshCut) {
meshCut->MeshCut();
meshCut->MeshCut(normalWeight,curvatureWeight);
meshCut->Colorize(selectForeground, doRefine);
}
glarea->update();
@ -516,6 +521,14 @@ void EditSegment::doRefineSlot(bool value) {
doRefine = value;
}
void EditSegment::changeCurvatureWeight(int value) {
curvatureWeight = value;
}
void EditSegment::changeNormalWeight(int value) {
normalWeight = value;
}
void EditSegment::ColorizeGaussianSlot() {
if (meshCut) {
meshCut->ColorizeCurvature(true);

View File

@ -38,6 +38,8 @@ private:
bool selectForeground;
bool doRefine;
float curvatureWeight;
float normalWeight;
QPoint current_point;
QPoint previous_point;
@ -87,6 +89,8 @@ public slots:
void MeshCutSlot();
void SelectForegroundSlot(bool);
void doRefineSlot(bool);
void changeNormalWeight(int);
void changeCurvatureWeight(int);
void ColorizeGaussianSlot();
void ColorizeMeanSlot();

View File

@ -31,6 +31,13 @@ void MeshCutDialog::on_refineCheckBox_clicked() {
emit doRefineSignal(ui.refineCheckBox->isChecked());
}
void MeshCutDialog::on_normalWeightSlider_valueChanged() {
emit normalWeightSignal(ui.normalWeightSlider->value());
}
void MeshCutDialog::on_curvatureWeightSlider_valueChanged() {
emit curvatureWeightSignal(ui.curvatureWeightSlider->value());
}
//debug function
void MeshCutDialog::on_gaussianButton_clicked() {

View File

@ -31,12 +31,15 @@ private:
void on_meanButton_clicked();
void on_resetButton_clicked();
void on_normalWeightSlider_valueChanged();
void on_curvatureWeightSlider_valueChanged();
signals:
void meshCutSignal();
void selectForegroundSignal(bool);
void doRefineSignal(bool);
void normalWeightSignal(int);
void curvatureWeightSignal(int);
void colorizeGaussianSignal();
void colorizeMeanSignal();

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>137</width>
<height>171</height>
<width>138</width>
<height>237</height>
</rect>
</property>
<property name="windowTitle" >
@ -17,8 +17,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>151</width>
<height>251</height>
<width>141</width>
<height>241</height>
</rect>
</property>
<property name="currentIndex" >
@ -31,10 +31,10 @@
<widget class="QWidget" name="" >
<property name="geometry" >
<rect>
<x>12</x>
<y>12</y>
<width>116</width>
<height>104</height>
<x>10</x>
<y>13</y>
<width>114</width>
<height>198</height>
</rect>
</property>
<layout class="QVBoxLayout" >
@ -71,6 +71,70 @@
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Normal Weight</string>
</property>
</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>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Curvature Weight</string>
</property>
</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>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="meshSegmentButton" >
<property name="text" >
@ -92,13 +156,13 @@
<attribute name="title" >
<string>Advanced</string>
</attribute>
<widget class="QWidget" name="" >
<widget class="QWidget" name="layoutWidget" >
<property name="geometry" >
<rect>
<x>1</x>
<y>11</y>
<width>132</width>
<height>126</height>
<height>129</height>
</rect>
</property>
<layout class="QVBoxLayout" >