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

MeshCompare Mean Curvature. refs #360

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13589 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 74b1a7ec
...@@ -89,6 +89,12 @@ void MeshComparePlugin::pluginsInitialized() { ...@@ -89,6 +89,12 @@ 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("")));
// Check mean curvature plugin and disable the box in gui mode
bool meanCurvature = false;
emit pluginExists( "meancurvature" , meanCurvature );
if ( OpenFlipper::Options::gui() && !meanCurvature )
tool_->meanCurvature->setEnabled(false);
} }
void MeshComparePlugin::compareButton() { void MeshComparePlugin::compareButton() {
...@@ -173,19 +179,44 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) { ...@@ -173,19 +179,44 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) {
pNode->reserve(refMesh->n_vertices(),refMesh->n_vertices(),refMesh->n_vertices() ); pNode->reserve(refMesh->n_vertices(),refMesh->n_vertices(),refMesh->n_vertices() );
} }
// Get a bsp for the target, as we will project the reference mesh onto the target mesh. // Get a bsp for the target, as we will project the reference mesh onto the target mesh.
// It will be build automatically at this point. // It will be build automatically at this point.
TriMeshObject::OMTriangleBSP* compBSP = target->requestTriangleBsp(); TriMeshObject::OMTriangleBSP* compBSP = target->requestTriangleBsp();
// ================================================================
// Compute mean curvature on both meshes ( if plugin is available )
// ================================================================
bool meanCurvature = false;
emit pluginExists( "meancurvature" , meanCurvature );
//
if ( meanCurvature ) {
RPC::callFunction("meancurvature","computeMeanCurvature",_sourceId);
RPC::callFunction("meancurvature","computeMeanCurvature",_targetId);
}
OpenMesh::VPropHandleT< double > meanRef;
OpenMesh::VPropHandleT< double > meanComp;
if( meanCurvature &&
((!refMesh->get_property_handle( meanRef , "Mean Curvature") ) ||
(!compMesh->get_property_handle( meanComp, "Mean Curvature") ))) {
meanCurvature = 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_ = 0.0; // ================================================================
maxNormalDeviation_ = 0.0; maximalDistance_ = -1.0;
maxNormalDeviation_ = -1.0;
maxMeanCurvatureDev_ = -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;
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) {
...@@ -202,14 +233,17 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) { ...@@ -202,14 +233,17 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) {
// 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::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::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();
// project original point to current mesh // project original point to current mesh
TriMesh::Point projectedPoint; TriMesh::Point projectedPoint;
...@@ -245,6 +279,25 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) { ...@@ -245,6 +279,25 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) {
if (normalDeviation > maxNormalDeviation_) if (normalDeviation > maxNormalDeviation_)
maxNormalDeviation_ = normalDeviation; maxNormalDeviation_ = normalDeviation;
if (meanCurvature) {
refMesh->property(meanRef,v_it);
TriMesh::Scalar curvature = 0.0;
curvature = compMesh->property(meanComp,v0) * projectedPoint[0];
curvature += compMesh->property(meanComp,v1) * projectedPoint[1];
curvature += compMesh->property(meanComp,v2) * projectedPoint[2];
const double curvatureDev = fabs( refMesh->property(meanRef,v_it) - curvature );
meanCurvatures.push_back( curvatureDev );
if ( curvatureDev > maxMeanCurvatureDev_ )
maxMeanCurvatureDev_ = curvatureDev;
}
} }
// Generate the colors // Generate the colors
...@@ -256,14 +309,23 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) { ...@@ -256,14 +309,23 @@ void MeshComparePlugin::compare(int _sourceId,int _targetId) {
for ( unsigned int i = 0 ; i < distances.size() ; ++i) { for ( unsigned int i = 0 ; i < distances.size() ; ++i) {
pNode->add_color(cCoder.color_float4(distances[i])); pNode->add_color(cCoder.color_float4(distances[i]));
} }
} else { } else if ( tool_->normalAngle->isChecked() ) {
ACG::ColorCoder cCoder(0,maxNormalDeviation_); ACG::ColorCoder cCoder(0,maxNormalDeviation_);
for ( unsigned int i = 0 ; i < normalAngles.size() ; ++i) { for ( unsigned int i = 0 ; i < normalAngles.size() ; ++i) {
pNode->add_color(cCoder.color_float4(normalAngles[i])); pNode->add_color(cCoder.color_float4(normalAngles[i]));
} }
} else if ( tool_->meanCurvature->isChecked() ) {
ACG::ColorCoder cCoder(0,maxMeanCurvatureDev_);
for ( unsigned int i = 0 ; i < meanCurvatures.size() ; ++i) {
pNode->add_color(cCoder.color_float4(meanCurvatures[i]));
}
} }
emit updateView(); emit updateView();
} }
......
...@@ -52,11 +52,12 @@ ...@@ -52,11 +52,12 @@
#include <OpenFlipper/BasePlugin/ScriptInterface.hh> #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh> #include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/BasePlugin/TextureInterface.hh> #include <OpenFlipper/BasePlugin/TextureInterface.hh>
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
#include <OpenFlipper/common/Types.hh> #include <OpenFlipper/common/Types.hh>
#include "MeshCompareToolbarWidget.hh" #include "MeshCompareToolbarWidget.hh"
class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, ScriptInterface, BackupInterface, TextureInterface class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, ScriptInterface, BackupInterface, TextureInterface, RPCInterface
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(BaseInterface) Q_INTERFACES(BaseInterface)
...@@ -65,6 +66,7 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi ...@@ -65,6 +66,7 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi
Q_INTERFACES(ScriptInterface) Q_INTERFACES(ScriptInterface)
Q_INTERFACES(BackupInterface) Q_INTERFACES(BackupInterface)
Q_INTERFACES(TextureInterface) Q_INTERFACES(TextureInterface)
Q_INTERFACES(RPCInterface)
signals: signals:
//BaseInterface //BaseInterface
...@@ -83,6 +85,9 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi ...@@ -83,6 +85,9 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi
// BackupInterface // BackupInterface
void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL ); void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );
// RPC Interface
void pluginExists( QString _pluginName , bool& _exists );
public: public:
MeshComparePlugin(); MeshComparePlugin();
...@@ -123,6 +128,9 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi ...@@ -123,6 +128,9 @@ class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, Loggi
/// Last maximal computed normal deviation in degree /// Last maximal computed normal deviation in degree
double maxNormalDeviation_; double maxNormalDeviation_;
/// Last maximal mean curvature deviation
double maxMeanCurvatureDev_;
}; };
#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>131</height> <height>156</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -57,6 +57,19 @@ ...@@ -57,6 +57,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QRadioButton" name="meanCurvature">
<property name="toolTip">
<string>Compare mean curvature between meshes</string>
</property>
<property name="statusTip">
<string>Compare mean curvature between meshes</string>
</property>
<property name="text">
<string>MeanCurvature</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
......
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