MeshComparePlugin.hh 8.23 KB
Newer Older
1 2 3
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
Martin Schultz's avatar
Martin Schultz committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
39 40 41
*                                                                            *
\*===========================================================================*/

Jan Möbius's avatar
Jan Möbius committed
42

43 44 45 46 47 48 49 50 51 52 53 54 55




#ifndef MESHCOMPAREPLUGIN_HH
#define MESHCOMPAREPLUGIN_HH

#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/BackupInterface.hh>
#include <OpenFlipper/BasePlugin/TextureInterface.hh>
56
#include <OpenFlipper/BasePlugin/RPCInterface.hh>
Jan Möbius's avatar
Jan Möbius committed
57
#include <OpenFlipper/BasePlugin/PythonInterface.hh>
58 59
#include <OpenFlipper/common/Types.hh>

Jan Möbius's avatar
Jan Möbius committed
60 61
#include <ACG/Scenegraph/PointNode.hh>

62 63
#include "MeshCompareToolbarWidget.hh"

64 65 66 67
#ifdef WITH_QWT
  #include "QwtFunctionPlot.hh"
#endif

Jan Möbius's avatar
Jan Möbius committed
68
class MeshComparePlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, ScriptInterface, BackupInterface, TextureInterface, RPCInterface, PythonInterface
69 70 71 72 73 74 75 76
{
  Q_OBJECT
  Q_INTERFACES(BaseInterface)
  Q_INTERFACES(ToolboxInterface)
  Q_INTERFACES(LoggingInterface)
  Q_INTERFACES(ScriptInterface)
  Q_INTERFACES(BackupInterface)
  Q_INTERFACES(TextureInterface)
77
  Q_INTERFACES(RPCInterface)
Jan Möbius's avatar
Jan Möbius committed
78
  Q_INTERFACES(PythonInterface)
79

Matthias Möller's avatar
Matthias Möller committed
80 81
  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-MeshCompare")

82 83 84 85 86 87 88 89 90 91 92 93
  signals:
    //BaseInterface
    void updateView();
    void updatedObject(int _id, const UpdateType& _type);
    void setSlotDescription(QString     _slotName,   QString     _slotDescription,
                            QStringList _parameters, QStringList _descriptions);

    //LoggingInterface
    void log(Logtype _type, QString _message);
    void log(QString _message);
    
    // ToolboxInterface
94
    void addToolbox( QString  _name  , QWidget* _widget ,QIcon* _icon);
95 96 97 98
    
    // BackupInterface
    void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );

99 100 101
    // RPC Interface
    void pluginExists( QString _pluginName , bool& _exists  );

102 103 104 105 106 107
  public:

    MeshComparePlugin();
    ~MeshComparePlugin();

    // BaseInterface
Jan Möbius's avatar
Jan Möbius committed
108
    QString name() { return (QString("MeshCompare")); };
109 110 111 112
    QString description( ) { return (QString("Compare two meshes")); };

  private slots:

113 114
    void initializePlugin();
    void pluginsInitialized();
115

116
    /// Triggers comparison of the selected meshes
117
    void compareButton();
118

119 120 121
    /// Clears the visualization
    void slotClear();

122 123 124
    /// Called when an object gets updated
    void slotObjectUpdated( int _identifier, const UpdateType& _type );

125 126
    void noguiSupported( ) {} ;

127 128
  // Scriptable functions
  public slots:
129 130 131
       
    QString version() { return QString("1.0"); };

132 133 134 135 136 137
    /** Compares two meshes. Use the two getter functions to retrieve the maximal deviations.
     *
     * The source will be the reference. The difference will be rendered as points on the target mesh.
     *
     * @param _sourceId Id of the reference mesh
     * @param _targetId Id of the mesh that should be compared to the reference mesh.
138 139 140 141
     * @param _computeDist   Compute distance between meshes
     * @param _computeNormal Compute normal deviation between meshes
     * @param _computeGauss  Compute gauss curvature deviation between meshes
     * @param _computeMean   Compute mean curvature deviation between meshes
142
     */
143 144 145 146 147
    void compare(int _sourceId,int _targetId,
                 bool _computeDist   = true,
                 bool _computeNormal = true,
                 bool _computeGauss  = true ,
                 bool _computeMean   = true);
148 149 150 151 152 153 154

    /// Get the maximal distance of the last comparison (-1, if no comparison performed so far)
    double lastMaximalDistance() { return maximalDistance_; };

    /// Get the maximal normal deviation of the last comparison in degree (-1, if no comparison performed so far)
    double lastMaximalNormalDeviation() { return maxNormalDeviation_; };

155 156 157
    /// Get the maximal mean curvature deviation of the last comparison (-1, if no comparison performed so far)
    double lastMaximalMeanCurvatureDeviation() { return maxMeanCurvatureDev_; };

158 159
    /// Get the maximal gauss curvature deviation of the last comparison (-1, if no comparison performed so far)
    double lastMaximalGaussCurvatureDeviation() { return maxGaussCurvatureDev_; };
160

161 162 163 164 165
  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);

Jan Möbius's avatar
Jan Möbius committed
166 167 168 169 170 171 172 173
  private:

    /** \brief Visualize data
     *
     *  This function visualizes the data via rendering points and pushes it to the histogram.
     *
     * @param _data     Vector of data points
     * @param _maxValue Maximal value found in the data
Jan Möbius's avatar
Jan Möbius committed
174
     * @param _pnode    The point node that will be used to visualize the data
Jan Möbius's avatar
Jan Möbius committed
175 176 177
     */
    void visualizeData( const std::vector<double>& _data, double _maxValue, ACG::SceneGraph::PointNode* _pnode);

178 179 180 181 182 183 184 185 186
  private:
    /// The toolbar widget of this plugin
    MeshCompareToolbarWidget* tool_;

    /// Last maximal computed distance
    double maximalDistance_;

    /// Last maximal computed normal deviation in degree
    double maxNormalDeviation_;
187 188 189

    /// Last maximal mean curvature deviation
    double maxMeanCurvatureDev_;
190 191 192

    /// Last maximal gauss curvature deviation
    double maxGaussCurvatureDev_;
193

194 195 196 197
    #ifdef WITH_QWT
      QwtFunctionPlot* plot_;
    #endif

198 199 200
};

#endif //MESHCOMPAREPLUGIN_HH