Commit aced0307 authored by Jan Möbius's avatar Jan Möbius
Browse files

Implemented Histogram, Only compute selected property when clicking compare. closes #360

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14048 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f4e79d36
include (plugin) include(plugin)
openflipper_plugin (INSTALLDATA Icons)
find_package(Qwt5)
if(Qwt5_Qt4_FOUND)
add_definitions(-DWITH_QWT)
openflipper_plugin(INCDIRS ${Qwt5_INCLUDE_DIR}
LIBRARIES ${Qwt5_Qt4_LIBRARY}
INSTALLDATA Icons
)
else()
openflipper_plugin(INSTALLDATA Icons)
endif()
...@@ -55,12 +55,16 @@ ...@@ -55,12 +55,16 @@
#include <ACG/Scenegraph/PointNode.hh> #include <ACG/Scenegraph/PointNode.hh>
#include <ACG/Utils/ColorCoder.hh> #include <ACG/Utils/ColorCoder.hh>
MeshComparePlugin::MeshComparePlugin() : MeshComparePlugin::MeshComparePlugin() :
tool_(0), tool_(0),
maximalDistance_(-1), maximalDistance_(-1),
maxNormalDeviation_(-1), maxNormalDeviation_(-1),
maxMeanCurvatureDev_(-1), maxMeanCurvatureDev_(-1),
maxGaussCurvatureDev_(-1) maxGaussCurvatureDev_(-1)
#ifdef WITH_QWT
,plot_(0)
#endif
{ {
} }
...@@ -80,6 +84,21 @@ void MeshComparePlugin::initializePlugin() ...@@ -80,6 +84,21 @@ void MeshComparePlugin::initializePlugin()
QIcon* toolIcon = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"MeshCompare.png"); QIcon* toolIcon = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"MeshCompare.png");
emit addToolbox( tr("Mesh Compare") , tool_ , toolIcon); emit addToolbox( tr("Mesh Compare") , tool_ , toolIcon);
connect(tool_->doClamp,SIGNAL(toggled( bool)),this,SLOT(slotClampBox(bool)));
#ifdef WITH_QWT
QVBoxLayout* layout = new QVBoxLayout(tool_->frame);
plot_ = new QwtFunctionPlot(0);
plot_->setMinimumHeight(150);
layout->addWidget(plot_);
#else
// Hide the extra frame
tool_->frame->hide();
#endif
} }
} }
...@@ -192,6 +211,13 @@ void MeshComparePlugin::slotClear() { ...@@ -192,6 +211,13 @@ void MeshComparePlugin::slotClear() {
} }
void MeshComparePlugin::slotClampBox(bool _checked) {
if ( _checked ) {
tool_->minVal->setValue(tool_->minValue->text().toDouble());
tool_->maxVal->setValue(tool_->maxValue->text().toDouble());
}
}
void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, bool _computeNormal, bool _computeGauss , bool _computeMean) { void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, bool _computeNormal, bool _computeGauss , bool _computeMean) {
...@@ -297,30 +323,30 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b ...@@ -297,30 +323,30 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b
for ( TriMesh::VertexIter v_it = refMesh->vertices_begin() ; v_it != refMesh->vertices_end(); ++ v_it) { for ( TriMesh::VertexIter v_it = refMesh->vertices_begin() ; v_it != refMesh->vertices_end(); ++ v_it) {
TriMeshObject::OMTriangleBSP::NearestNeighbor nearest = compBSP->nearest( refMesh->point(v_it) ); TriMeshObject::OMTriangleBSP::NearestNeighbor nearest = compBSP->nearest(refMesh->point(v_it));
TriMesh::FaceHandle closestFace = nearest.handle; TriMesh::FaceHandle closestFace = nearest.handle;
// Remember the maximal distance between the meshes // Remember the maximal distance between the meshes
if ( nearest.dist > maximalDistance_ ) if (nearest.dist > maximalDistance_)
maximalDistance_ = nearest.dist; maximalDistance_ = nearest.dist;
// Remember distance for color coding // Remember distance for color coding
distances.push_back(nearest.dist); distances.push_back(nearest.dist);
// Get the vertices around that face and their properties // Get the vertices around that face and their properties
TriMesh::CFVIter fv_it = compMesh->cfv_iter(closestFace); TriMesh::CFVIter fv_it = compMesh->cfv_iter(closestFace);
const TriMesh::Point& p0 = compMesh->point(fv_it); const TriMesh::Point& p0 = compMesh->point(fv_it);
const TriMesh::Normal n0 = compMesh->normal(fv_it); const TriMesh::Normal n0 = compMesh->normal(fv_it);
const TriMesh::VertexHandle& v0 = fv_it.handle(); const TriMesh::VertexHandle& v0 = fv_it.handle();
const TriMesh::Point& p1 = compMesh->point(++fv_it); const TriMesh::Point& p1 = compMesh->point(++fv_it);
const TriMesh::Normal n1 = compMesh->normal(fv_it); const TriMesh::Normal n1 = compMesh->normal(fv_it);
const TriMesh::VertexHandle& v1 = fv_it.handle(); const TriMesh::VertexHandle& v1 = fv_it.handle();
const TriMesh::Point& p2 = compMesh->point(++fv_it); const TriMesh::Point& p2 = compMesh->point(++fv_it);
const TriMesh::Normal n2 = compMesh->normal(fv_it); const TriMesh::Normal n2 = compMesh->normal(fv_it);
const TriMesh::VertexHandle& v2 = fv_it.handle(); const TriMesh::VertexHandle& v2 = fv_it.handle();
// project original point to current mesh // project original point to current mesh
TriMesh::Point projectedPoint; TriMesh::Point projectedPoint;
...@@ -333,61 +359,60 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b ...@@ -333,61 +359,60 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b
// compute Barycentric coordinates // compute Barycentric coordinates
ACG::Geometry::baryCoord(projectedPoint, p0, p1, p2, projectedPoint); ACG::Geometry::baryCoord(projectedPoint, p0, p1, p2, projectedPoint);
// interpolate normal on the compare mesh at the projected point via barycentric coordinates. if ( _computeNormal) {
TriMesh::Normal normal; // interpolate normal on the compare mesh at the projected point via barycentric coordinates.
normal = n0 * projectedPoint[0]; TriMesh::Normal normal;
normal += n1 * projectedPoint[1]; normal = n0 * projectedPoint[0];
normal += n2 * projectedPoint[2]; normal += n1 * projectedPoint[1];
normal.normalize(); normal += n2 * projectedPoint[2];
normal.normalize();
// Compute normal deviation in degrees
double normalDeviation = (refMesh->normal(v_it) | normal);
if (normalDeviation < -1.0) // Compute normal deviation in degrees
normalDeviation = -1.0; double normalDeviation = (refMesh->normal(v_it) | normal);
else if (normalDeviation > 1.0)
normalDeviation = 1.0;
normalDeviation = 180.0 / M_PI * acos(normalDeviation); if (normalDeviation < -1.0)
normalDeviation = -1.0;
else if (normalDeviation > 1.0)
normalDeviation = 1.0;
// Remember normal deviation for color coding normalDeviation = 180.0 / M_PI * acos(normalDeviation);
normalAngles.push_back(normalDeviation);
if (normalDeviation > maxNormalDeviation_) // Remember normal deviation for color coding
maxNormalDeviation_ = normalDeviation; normalAngles.push_back(normalDeviation);
if (normalDeviation > maxNormalDeviation_)
maxNormalDeviation_ = normalDeviation;
}
if (meanCurvature) { if (meanCurvature) {
TriMesh::Scalar curvature = 0.0; TriMesh::Scalar curvature = 0.0;
curvature = compMesh->property(meanComp,v0) * projectedPoint[0]; curvature = compMesh->property(meanComp, v0) * projectedPoint[0];
curvature += compMesh->property(meanComp,v1) * projectedPoint[1]; curvature += compMesh->property(meanComp, v1) * projectedPoint[1];
curvature += compMesh->property(meanComp,v2) * projectedPoint[2]; curvature += compMesh->property(meanComp, v2) * projectedPoint[2];
const double curvatureDev = fabs( refMesh->property(meanRef,v_it) - curvature ); const double curvatureDev = fabs(refMesh->property(meanRef, v_it) - curvature);
meanCurvatures.push_back( curvatureDev ); meanCurvatures.push_back(curvatureDev);
if ( curvatureDev > maxMeanCurvatureDev_ ) if (curvatureDev > maxMeanCurvatureDev_)
maxMeanCurvatureDev_ = curvatureDev; maxMeanCurvatureDev_ = curvatureDev;
} }
if (gaussCurvature) { if (gaussCurvature) {
TriMesh::Scalar curvature = 0.0; TriMesh::Scalar curvature = 0.0;
curvature = compMesh->property(gaussComp,v0) * projectedPoint[0]; curvature = compMesh->property(gaussComp, v0) * projectedPoint[0];
curvature += compMesh->property(gaussComp,v1) * projectedPoint[1]; curvature += compMesh->property(gaussComp, v1) * projectedPoint[1];
curvature += compMesh->property(gaussComp,v2) * projectedPoint[2]; curvature += compMesh->property(gaussComp, v2) * projectedPoint[2];
const double curvatureDev = fabs( refMesh->property(gaussRef,v_it) - curvature );
gaussCurvatures.push_back( curvatureDev ); const double curvatureDev = fabs(refMesh->property(gaussRef, v_it) - curvature);
if ( curvatureDev > maxGaussCurvatureDev_ ) gaussCurvatures.push_back(curvatureDev);
maxGaussCurvatureDev_ = curvatureDev;
} if (curvatureDev > maxGaussCurvatureDev_)
maxGaussCurvatureDev_ = curvatureDev;
}
} }
...@@ -404,7 +429,7 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b ...@@ -404,7 +429,7 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b
if ( tool_->doClamp->isChecked() ) { if ( tool_->doClamp->isChecked() ) {
min = tool_->minVal->value(); min = tool_->minVal->value();
max = tool_->maxVal->value(); max = std::min(tool_->maxVal->value(),maximalDistance_);
} else } else
max = maximalDistance_; max = maximalDistance_;
...@@ -414,13 +439,19 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b ...@@ -414,13 +439,19 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b
pNode->add_color(cCoder.color_float4(distances[i])); pNode->add_color(cCoder.color_float4(distances[i]));
} }
#ifdef WITH_QWT
plot_->setMinMax(min,max);
plot_->setFunction( distances );
plot_->replot();
#endif
} else if ( tool_->normalAngle->isChecked() ) { } else if ( tool_->normalAngle->isChecked() ) {
tool_->maxValue->setText( QString::number(maxNormalDeviation_) ); tool_->maxValue->setText( QString::number(maxNormalDeviation_) );
if ( tool_->doClamp->isChecked() ) { if ( tool_->doClamp->isChecked() ) {
min = tool_->minVal->value(); min = tool_->minVal->value();
max = tool_->maxVal->value(); max = std::min(tool_->maxVal->value(),maxNormalDeviation_);
} else } else
max = maxNormalDeviation_; max = maxNormalDeviation_;
...@@ -430,13 +461,19 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b ...@@ -430,13 +461,19 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b
pNode->add_color(cCoder.color_float4(normalAngles[i])); pNode->add_color(cCoder.color_float4(normalAngles[i]));
} }
#ifdef WITH_QWT
plot_->setMinMax(min,max);
plot_->setFunction( normalAngles );
plot_->replot();
#endif
} else if ( tool_->meanCurvature->isChecked() ) { } else if ( tool_->meanCurvature->isChecked() ) {
tool_->maxValue->setText( QString::number(maxMeanCurvatureDev_) ); tool_->maxValue->setText( QString::number(maxMeanCurvatureDev_) );
if ( tool_->doClamp->isChecked() ) { if ( tool_->doClamp->isChecked() ) {
min = tool_->minVal->value(); min = tool_->minVal->value();
max = tool_->maxVal->value(); max = std::min(tool_->maxVal->value(),maxMeanCurvatureDev_);
} else } else
max = maxMeanCurvatureDev_; max = maxMeanCurvatureDev_;
...@@ -446,13 +483,18 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b ...@@ -446,13 +483,18 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b
pNode->add_color(cCoder.color_float4(meanCurvatures[i])); pNode->add_color(cCoder.color_float4(meanCurvatures[i]));
} }
#ifdef WITH_QWT
plot_->setMinMax(min,max);
plot_->setFunction( meanCurvatures );
plot_->replot();
#endif
} else if ( tool_->gaussCurvature->isChecked() ) { } else if ( tool_->gaussCurvature->isChecked() ) {
tool_->maxValue->setText( QString::number(maxGaussCurvatureDev_) ); tool_->maxValue->setText( QString::number(maxGaussCurvatureDev_) );
if ( tool_->doClamp->isChecked() ) { if ( tool_->doClamp->isChecked() ) {
min = tool_->minVal->value(); min = tool_->minVal->value();
max = tool_->maxVal->value(); max = std::min(tool_->maxVal->value(),maxGaussCurvatureDev_);
} else } else
max = maxGaussCurvatureDev_; max = maxGaussCurvatureDev_;
...@@ -462,11 +504,14 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b ...@@ -462,11 +504,14 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId,bool _computeDist, b
pNode->add_color(cCoder.color_float4(gaussCurvatures[i])); pNode->add_color(cCoder.color_float4(gaussCurvatures[i]));
} }
#ifdef WITH_QWT
plot_->setMinMax(min,max);
plot_->setFunction( gaussCurvatures );
plot_->replot();
#endif
} }
emit updateView(); emit updateView();
} }
......
...@@ -57,6 +57,10 @@ ...@@ -57,6 +57,10 @@
#include "MeshCompareToolbarWidget.hh" #include "MeshCompareToolbarWidget.hh"
#ifdef WITH_QWT
#include "QwtFunctionPlot.hh"
#endif
class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, ScriptInterface, BackupInterface, TextureInterface, RPCInterface class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, ScriptInterface, BackupInterface, TextureInterface, RPCInterface
{ {
Q_OBJECT Q_OBJECT
...@@ -147,6 +151,11 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi ...@@ -147,6 +151,11 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi
/// Get the maximal gauss curvature deviation of the last comparison (-1, if no comparison performed so far) /// Get the maximal gauss curvature deviation of the last comparison (-1, if no comparison performed so far)
double lastMaximalGaussCurvatureDeviation() { return maxGaussCurvatureDev_; }; double lastMaximalGaussCurvatureDeviation() { return maxGaussCurvatureDev_; };
private slots:
/// If the checkbox is changed to be checked, the values in the labels will be written into the spin boxes.
void slotClampBox(bool _checked);
private: private:
/// The toolbar widget of this plugin /// The toolbar widget of this plugin
MeshCompareToolbarWidget* tool_; MeshCompareToolbarWidget* tool_;
...@@ -163,6 +172,10 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi ...@@ -163,6 +172,10 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi
/// Last maximal gauss curvature deviation /// Last maximal gauss curvature deviation
double maxGaussCurvatureDev_; double maxGaussCurvatureDev_;
#ifdef WITH_QWT
QwtFunctionPlot* plot_;
#endif
}; };
#endif //MESHCOMPAREPLUGIN_HH #endif //MESHCOMPAREPLUGIN_HH
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>297</width> <width>304</width>
<height>258</height> <height>368</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -82,6 +82,13 @@ ...@@ -82,6 +82,13 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="frame">
<property name="title">
<string>Histogramm</string>
</property>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment