Developer Documentation
ICPPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2020, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 #pragma once
43 
44 
45 #include <QSpinBox>
46 
53 #include <Eigen/Dense>
54 #include <Eigen/Eigenvalues>
55 #include <algorithm>
56 #include "ICPToolbarWidget.hh"
57 #include "VertexList.hh"
58 #include <ACG/Geometry/Algorithms.hh>
60 
63 
64 struct ICPParameters {
65  int maxIterations_;
66  double errorThreshold_; //mse
67  double distanceThreshold_; //units
68  double normalDotThreshold_; //% (eg. 56.3 for 56.3%)
69  bool debugOutput_;
70  bool doResize_;
71  bool interpolateNormals_;
72 };
73 
74 typedef struct ICPParameter ICPParameter;
75 
76 struct ICPContext {
77  TriMesh* sourceMesh_;
78  TriMesh* targetMesh_;
79  TriMeshObject* sourceObject_;
80  TriMeshObject* targetObject_;
81  int sourceID_;
82  int targetID_;
83  ICPParameters* params_;
84 };
85 
86 typedef struct ICPContext ICPContext;
87 
89 {
90  Q_OBJECT
91  Q_INTERFACES(BaseInterface)
92  Q_INTERFACES(ToolboxInterface)
93  Q_INTERFACES(LoggingInterface)
94  Q_INTERFACES(ScriptInterface)
95  Q_INTERFACES(LoadSaveInterface)
96  Q_INTERFACES(BackupInterface)
97 
98  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-ICP")
99 
100  signals:
101  //BaseInterface
102  void updateView();
103  void updatedObject(int _id, const UpdateType& _type);
104 
105  //LoggingInterface
106  void log(Logtype _type, QString _message);
107  void log(QString _message);
108 
109  // ToolboxInterface
110  void addToolbox( QString _name , QWidget* _widget, QIcon* _icon);
111 
112  // ScriptInterface
113  void scriptInfo(QString _functionName);
114 
115  // BackupInterface
116  void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );
117 
118  // LoadSaveInterface
119  void addEmptyObject( DataType _type, int& _id);
120  void deleteObject(int _id);
121  void deleteAllObjects();
122 
123  private:
124  ICPToolbarWidget* tool_;
125  QIcon* toolIcon_;
126 
127 
128  public:
129 
130  ICPPlugin();
131  ~ICPPlugin();
132 
133  // BaseInterface
134  QString name() { return (QString("ICP")); }
135  QString description( ) { return (QString("Implementation of the ICP algorithm")); }
136 
137  private:
138 
139  private slots:
140  void initializePlugin(); // BaseInterface
141 
142  void pluginsInitialized(); // BaseInterface
143 
148  void toolbarICP();
149 
150  // Scriptable functions
151  public slots:
152 
157  void icp(int _maxIterations, double _errorThreshold, double _distanceThreshold, double _normalDotThreshold, bool _debugOutput, bool _doResize, bool _interpolateNormals, int _sourceObjectID, int _targetObjectID);
158 
161  void doICP(ICPContext* _context);
162 
163  QString version() { return QString("1.0"); }
164 };
165 
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
Plugins can add its own toolbox to the main widget&#39;s toolbox area by using this interface.
Logtype
Log types for Message Window.
Predefined datatypes.
Definition: DataTypes.hh:83
Interface for all Plugins which do logging to the logging window of the framework.
QString description()
Return a description of what the plugin is doing.
Definition: ICPPlugin.hh:135
QString name()
Return a name for the plugin.
Definition: ICPPlugin.hh:134
Type for a MeshObject containing a triangle mesh.
Definition: TriangleMesh.hh:67
Update type class.
Definition: UpdateType.hh:59
Interface for all Plugins which provide scriptable Functions.
void icp(const std::vector< VectorT > &_points1, const std::vector< VectorT > &_points2, VectorT &_cog1, VectorT &_cog2, double &_scale1, double &_scale2, QuaternionT &_rotation)
Compute rigid transformation from first point set to second point set.
Definition: ICPT_impl.hh:85
Interface class from which all plugins have to be created.
Interface class for backup handling.
Interface for all plugins which want to Load or Save files and create Objects.