Commit 3064768e authored by Jan Möbius's avatar Jan Möbius

MeshCompare Gauss Curvature. refs #360

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13596 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a29ac639
...@@ -82,7 +82,7 @@ class GaussCurvaturePlugin : public QObject, BaseInterface, TextureInterface ...@@ -82,7 +82,7 @@ class GaussCurvaturePlugin : public QObject, BaseInterface, TextureInterface
/** \brief Scripting slot to trigger computation of gaussian curvature /** \brief Scripting slot to trigger computation of gaussian curvature
* *
* The curvature will be stored on the mesh on the vertex property called "Mean Curvature" * The curvature will be stored on the mesh on the vertex property called "Gaussian Curvature"
*/ */
bool computeGaussCurvature(int _objectId); bool computeGaussCurvature(int _objectId);
......
...@@ -58,7 +58,8 @@ ...@@ -58,7 +58,8 @@
MeshComparePlugin::MeshComparePlugin() : MeshComparePlugin::MeshComparePlugin() :
tool_(0), tool_(0),
maximalDistance_(-1), maximalDistance_(-1),
maxNormalDeviation_(-1) maxNormalDeviation_(-1),
maxGaussCurvatureDev_(-1)
{ {
} }
...@@ -74,6 +75,7 @@ void MeshComparePlugin::initializePlugin() ...@@ -74,6 +75,7 @@ void MeshComparePlugin::initializePlugin()
tool_ = new MeshCompareToolbarWidget(); tool_ = new MeshCompareToolbarWidget();
connect( tool_->compare, SIGNAL(clicked()), this, SLOT(compareButton()) ); connect( tool_->compare, SIGNAL(clicked()), this, SLOT(compareButton()) );
connect( tool_->clear, SIGNAL(clicked()), this, SLOT(slotClear()) );
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);
...@@ -92,7 +94,9 @@ void MeshComparePlugin::pluginsInitialized() { ...@@ -92,7 +94,9 @@ void MeshComparePlugin::pluginsInitialized() {
emit setSlotDescription(tr("lastMaximalNormalDeviation()"), tr("Get the maximal normal deviation in degree between the meshes of the last comparison."), emit setSlotDescription(tr("lastMaximalNormalDeviation()"), tr("Get the maximal normal deviation in degree between the meshes of the last comparison."),
QStringList(tr("")), QStringList(tr(""))); QStringList(tr("")), QStringList(tr("")));
emit setSlotDescription(tr("lastMaximalMeanCurvatureDeviation()"), tr("Get the maximal mean curvature deviation between the meshes of the last comparison."), emit setSlotDescription(tr("lastMaximalMeanCurvatureDeviation()"), tr("Get the maximal mean curvature deviation between the meshes of the last comparison."),
QStringList(tr("")), QStringList(tr(""))); QStringList(tr("")), QStringList(tr("")));
emit setSlotDescription(tr("lastMaximalGaussCurvatureDeviation()"), tr("Get the maximal gauss curvature deviation between the meshes of the last comparison."),
QStringList(tr("")), QStringList(tr("")));
//=========================================================== //===========================================================
// Check mean curvature plugin and disable the box in gui mode // Check mean curvature plugin and disable the box in gui mode
...@@ -102,6 +106,15 @@ void MeshComparePlugin::pluginsInitialized() { ...@@ -102,6 +106,15 @@ void MeshComparePlugin::pluginsInitialized() {
if ( OpenFlipper::Options::gui() && !meanCurvature ) if ( OpenFlipper::Options::gui() && !meanCurvature )
tool_->meanCurvature->setEnabled(false); tool_->meanCurvature->setEnabled(false);
//===========================================================
// Check gauss curvature plugin and disable the box in gui mode
//===========================================================
bool gaussCurvature = false;
emit pluginExists( "gausscurvature" , gaussCurvature );
if ( OpenFlipper::Options::gui() && !gaussCurvature )
tool_->gaussCurvature->setEnabled(false);
} }
void MeshComparePlugin::compareButton() { void MeshComparePlugin::compareButton() {
...@@ -147,6 +160,18 @@ void MeshComparePlugin::compareButton() { ...@@ -147,6 +160,18 @@ void MeshComparePlugin::compareButton() {
} }
void MeshComparePlugin::slotClear() {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
ACG::SceneGraph::MaterialNode *pMatNode = 0;
if ( o_it->getAdditionalNode(pMatNode,name(), "MeshCompareDistanceMaterial" ) )
o_it->removeAdditionalNode(pMatNode,name(),"MeshCompareDistanceMaterial");
}
}
void MeshComparePlugin::compare(int _sourceId,int _targetId) { void MeshComparePlugin::compare(int _sourceId,int _targetId) {
...@@ -206,24 +231,48 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) { ...@@ -206,24 +231,48 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) {
OpenMesh::VPropHandleT< double > meanComp; OpenMesh::VPropHandleT< double > meanComp;
if( meanCurvature && if( meanCurvature &&
((!refMesh->get_property_handle( meanRef , "Mean Curvature") ) || ((!refMesh->get_property_handle( meanRef , "Mean Curvature") ) ||
(!compMesh->get_property_handle( meanComp, "Mean Curvature") ))) { (!compMesh->get_property_handle( meanComp, "Mean Curvature") ))) {
meanCurvature = false; meanCurvature = false;
} }
// ================================================================
// Compute mean curvature on both meshes ( if plugin is available )
// ================================================================
bool gaussCurvature = false;
emit pluginExists( "gausscurvature" , gaussCurvature );
//
if ( gaussCurvature ) {
RPC::callFunction("gausscurvature","computeGaussCurvature",_sourceId);
RPC::callFunction("gausscurvature","computeGaussCurvature",_targetId);
}
OpenMesh::VPropHandleT< double > gaussRef;
OpenMesh::VPropHandleT< double > gaussComp;
if( gaussCurvature &&
((!refMesh->get_property_handle( gaussRef , "Gaussian Curvature") ) ||
(!compMesh->get_property_handle( gaussComp, "Gaussian Curvature") ))) {
gaussCurvature = false;
}
// ================================================================ // ================================================================
// Remember the maximal values as output and for specifying color coding range // Remember the maximal values as output and for specifying color coding range
// ================================================================ // ================================================================
maximalDistance_ = -1.0; maximalDistance_ = -1.0;
maxNormalDeviation_ = -1.0; maxNormalDeviation_ = -1.0;
maxMeanCurvatureDev_ = -1.0; maxMeanCurvatureDev_ = -1.0;
maxGaussCurvatureDev_ = -1.0;
// Remember distances for colorCoding after we know the maximal distance // Remember distances for colorCoding after we know the maximal distance
std::vector<double> distances; std::vector<double> distances;
std::vector<double> normalAngles; std::vector<double> normalAngles;
std::vector<double> meanCurvatures; std::vector<double> meanCurvatures;
std::vector<double> gaussCurvatures;
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) {
...@@ -289,8 +338,6 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) { ...@@ -289,8 +338,6 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) {
if (meanCurvature) { if (meanCurvature) {
refMesh->property(meanRef,v_it);
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];
...@@ -305,6 +352,22 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) { ...@@ -305,6 +352,22 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) {
} }
if (gaussCurvature) {
TriMesh::Scalar curvature = 0.0;
curvature = compMesh->property(gaussComp,v0) * projectedPoint[0];
curvature += compMesh->property(gaussComp,v1) * projectedPoint[1];
curvature += compMesh->property(gaussComp,v2) * projectedPoint[2];
const double curvatureDev = fabs( refMesh->property(gaussRef,v_it) - curvature );
gaussCurvatures.push_back( curvatureDev );
if ( curvatureDev > maxGaussCurvatureDev_ )
maxGaussCurvatureDev_ = curvatureDev;
}
} }
// Generate the colors // Generate the colors
...@@ -329,6 +392,13 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) { ...@@ -329,6 +392,13 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) {
pNode->add_color(cCoder.color_float4(meanCurvatures[i])); pNode->add_color(cCoder.color_float4(meanCurvatures[i]));
} }
} else if ( tool_->gaussCurvature->isChecked() ) {
ACG::ColorCoder cCoder(0,maxGaussCurvatureDev_);
for ( unsigned int i = 0 ; i < gaussCurvatures.size() ; ++i) {
pNode->add_color(cCoder.color_float4(gaussCurvatures[i]));
}
} }
......
...@@ -102,8 +102,12 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi ...@@ -102,8 +102,12 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi
void initializePlugin(); void initializePlugin();
void pluginsInitialized(); void pluginsInitialized();
/// Triggers comparison of the selected meshes
void compareButton(); void compareButton();
/// Clears the visualization
void slotClear();
// Scriptable functions // Scriptable functions
public slots: public slots:
...@@ -121,6 +125,8 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi ...@@ -121,6 +125,8 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi
/// Get the maximal mean curvature deviation of the last comparison (-1, if no comparison performed so far) /// Get the maximal mean curvature deviation of the last comparison (-1, if no comparison performed so far)
double lastMaximalMeanCurvatureDeviation() { return maxMeanCurvatureDev_; }; double lastMaximalMeanCurvatureDeviation() { return maxMeanCurvatureDev_; };
/// Get the maximal gauss curvature deviation of the last comparison (-1, if no comparison performed so far)
double lastMaximalGaussCurvatureDeviation() { return maxGaussCurvatureDev_; };
private: private:
/// The toolbar widget of this plugin /// The toolbar widget of this plugin
...@@ -134,6 +140,9 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi ...@@ -134,6 +140,9 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi
/// Last maximal mean curvature deviation /// Last maximal mean curvature deviation
double maxMeanCurvatureDev_; double maxMeanCurvatureDev_;
/// Last maximal gauss curvature deviation
double maxGaussCurvatureDev_;
}; };
#endif //MESHCOMPAREPLUGIN_HH #endif //MESHCOMPAREPLUGIN_HH
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>321</width> <width>321</width>
<height>156</height> <height>183</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -66,7 +66,14 @@ ...@@ -66,7 +66,14 @@
<string>Compare mean curvature between meshes</string> <string>Compare mean curvature between meshes</string>
</property> </property>
<property name="text"> <property name="text">
<string>MeanCurvature</string> <string>Mean curvature</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="gaussCurvature">
<property name="text">
<string>Gauss curvature</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -76,16 +83,27 @@ ...@@ -76,16 +83,27 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="compare"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="toolTip"> <item>
<string>Compute distance between to meshes. <widget class="QPushButton" name="compare">
<property name="toolTip">
<string>Compute distance between to meshes.
Select one source mesh(the reference) and one target mesh. The points of the reference are projected onto target and the deviation(distance,normal) gets visualized by colored points.</string> Select one source mesh(the reference) and one target mesh. The points of the reference are projected onto target and the deviation(distance,normal) gets visualized by colored points.</string>
</property> </property>
<property name="text"> <property name="text">
<string>Compare</string> <string>Compare</string>
</property> </property>
</widget> </widget>
</item>
<item>
<widget class="QPushButton" name="clear">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
......
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