Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DecimaterPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, 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 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 #ifndef DECIMATERPLUGIN_HH
51 #define DECIMATERPLUGIN_HH
52
53 //== INCLUDES =================================================================
54
55 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
56 #include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
57 #include <OpenFlipper/BasePlugin/BackupInterface.hh>
58 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
59 #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
60 #include <OpenFlipper/BasePlugin/RPCInterface.hh>
61 #include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
62 #include <OpenFlipper/BasePlugin/ProcessInterface.hh>
63
64 #include <OpenFlipper/common/Types.hh>
65
66 #include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
67
68 #include "DecimaterInfo.hh"
69
70 #include "DecimaterToolbarWidget.hh"
71
72 #include "DecimateThread.hh"
73
74 #include <OpenMesh/Tools/Decimater/DecimaterT.hh>
75 #include <OpenMesh/Tools/Decimater/McDecimaterT.hh>
76 #include <OpenMesh/Tools/Decimater/MixedDecimaterT.hh>
77 #include <OpenMesh/Tools/Decimater/ModQuadricT.hh>
78 #include <OpenMesh/Tools/Decimater/ModNormalFlippingT.hh>
79 #include <OpenMesh/Tools/Decimater/ModHausdorffT.hh>
80 #include <OpenMesh/Tools/Decimater/ModNormalDeviationT.hh>
81 #include <OpenMesh/Tools/Decimater/ModEdgeLengthT.hh>
82 #include <OpenMesh/Tools/Decimater/ModAspectRatioT.hh>
83 #include <OpenMesh/Tools/Decimater/ModRoundnessT.hh>
84 #include <OpenMesh/Tools/Decimater/ModIndependentSetsT.hh>
85
86 #include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
87
88 #include <ACG/Utils/SmartPointer.hh>
89 #include <vector>
90
91 #include <QObject>
92 #include <QMenuBar>
93 #include <QTimer>
94
95
96 //== CLASS DEFINITION =========================================================
97
100 class DecimaterPlugin : public QObject, BaseInterface, ToolboxInterface, LoggingInterface, ScriptInterface, BackupInterface, RPCInterface, LoadSaveInterface, ProcessInterface
101 {
102 Q_OBJECT
103 Q_INTERFACES(BaseInterface)
104 Q_INTERFACES(ToolboxInterface)
105 Q_INTERFACES(BackupInterface)
106 Q_INTERFACES(LoggingInterface)
107 Q_INTERFACES(ScriptInterface)
108 Q_INTERFACES(RPCInterface)
109 Q_INTERFACES(LoadSaveInterface)
110 Q_INTERFACES(ProcessInterface)
111
112 #if QT_VERSION >= 0x050000
113 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Decimater")
114 #endif
115 signals:
116
117 // BaseInterface
118 void updateView();
119 void updatedObject(int _id, const UpdateType& _type);
120 void setSlotDescription(QString _slotName, QString _slotDescription,
121 QStringList _parameters, QStringList _descriptions);
122
123 // LoggingInterface
124 void log(Logtype _type, QString _message);
125 void log(QString _message);
126
127 // RPC Interface
128 void pluginExists( QString _pluginName , bool& _exists ) ;
129 void functionExists( QString _pluginName , QString _functionName , bool& _exists );
130
131 // ToolboxInterface
132 void addToolbox( QString _name , QWidget* _widget, QIcon* _icon );
133
134 // ScriptInterface
135 void scriptInfo( QString _functionName );
136
137 // BackupInterface
138 void createBackup( int _id , QString _name, UpdateType _type = UPDATE_ALL );
139
140 // ProcessInterface
141 void startJob( QString _jobId, QString _description , int _min , int _max , bool _blocking = false);
142 void cancelJob(QString _jobId );
143 void finishJob(QString _jobId );
144 void setJobState(QString, int);
145 void setJobName(QString _jobId, QString _name );
146 void setJobDescription(QString _jobId, QString _text );
147
148 //self defined signals
149 void jobCanceled(QString _jobId);
150
151 private slots:
152 // BaseInterface
153 void initializePlugin();
154 void pluginsInitialized();
155
156 void slotObjectUpdated( int _identifier , const UpdateType& _type ); // BaseInterface
157 void slotObjectSelectionChanged( int _identifier ); // BaseInterface
158
159 void objectDeleted(int _id); //LoadSaveInterface
160
161 void slotAboutToRestore(int _id); //BackupInterface
162
163 // Tell system that this plugin runs without ui
164 void noguiSupported( ) {} ;
165
166 // ProcessInterface
167 void canceledJob (QString _job );
168
169 public :
170
172 DecimaterPlugin();
173
175 ~DecimaterPlugin() {};
176
178 QString name(){ return (QString("Decimater")); };
179
181 QString description() { return (QString(tr("Mesh Decimation ..."))); };
182
183
184 private :
185 typedef DecimateThread::BaseDecimaterType BaseDecimaterType;
186 typedef DecimateThread::DecimaterType DecimaterType;
187 typedef DecimateThread::McDecimaterType McDecimaterType;
188 typedef DecimateThread::MixedDecimaterType MixedDecimaterType;
189
190 typedef OpenMesh::Decimater::ModAspectRatioT< TriMesh >::Handle ModAspectRatioH;
191 typedef OpenMesh::Decimater::ModEdgeLengthT< TriMesh >::Handle ModEdgeLengthH;
192 typedef OpenMesh::Decimater::ModHausdorffT< TriMesh >::Handle ModHausdorffH;
193 typedef OpenMesh::Decimater::ModIndependentSetsT< TriMesh >::Handle ModIndependentH;
194 typedef OpenMesh::Decimater::ModNormalDeviationT< TriMesh >::Handle ModNormalDeviationH;
195 typedef OpenMesh::Decimater::ModNormalFlippingT< TriMesh >::Handle ModNormalFlippingH;
196 typedef OpenMesh::Decimater::ModQuadricT< TriMesh >::Handle ModQuadricH;
197 typedef OpenMesh::Decimater::ModRoundnessT< TriMesh >::Handle ModRoundnessH;
198
200 DecimaterToolbarWidget* tool_;
201
202 //saves the decimater and the object id
203 struct DecimaterInit
204 {
205 ptr::shared_ptr<BaseDecimaterType> decimater;
206 int objId;
207 ModAspectRatioH hModAspectRatio;
208 ModEdgeLengthH hModEdgeLength;
209 ModHausdorffH hModHausdorff;
210 ModIndependentH hModIndependent;
211 ModNormalDeviationH hModNormalDeviation;
212 ModNormalFlippingH hModNormalFlipping;
213 ModQuadricH hModQuadric;
214 ModRoundnessH hModRoundness;
215 };
216 std::vector< ptr::shared_ptr<DecimaterInit> > decimater_objects_;
217 QIcon* toolIcon_;
218
219 int runningJobs_;
220
221 private slots:
222
224 void slot_decimate();
225 void slot_decimate_finished(QString _jobId); //postprocess after threads finished
226
228 void slot_initialize();
229 void slot_initialize_object(int obj_id, bool clear = false);
230
231 private slots:
233 void slotUpdateRoundness(int _value);
234 void slotUpdateRoundness(double _value);
235 void slotUpdateAspectRatio(int _value);
236 void slotUpdateAspectRatio(double _value);
237
239 void slotUpdateDistance ();
240 void slotUpdateNormalDev ();
241 void slotUpdateVertices ();
242 void slotUpdateTriangles ();
243 void slotUpdateEdgeLength ();
244
246 void slotUpdateNumVertices();
247 void slotUpdateNumTriangles();
248
249 void slotMixedCounterValueChanged(double);
250 void slotMixedSliderValueChanged(int);
251 void slotDisableDecimation();
252
253 private:
254 void initialize_object(BaseObjectData *obj);
255
256 //===========================================================================
259 //===========================================================================
260
261 public slots:
262
269 void decimate(int _objID, QVariantMap _constraints);
270
273 public slots:
274 QString version() { return QString("1.0"); };
275
276 };
277
278
279 #endif //DECIMATERPLUGIN_HH
ModEdgeLengthT.hh
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:76
OpenMesh::Decimater::ModRoundnessT
Use Roundness of triangles to control decimation.
Definition: ModRoundnessT.hh:91
OpenMesh::Decimater::ModAspectRatioT
Use aspect ratio to control decimation.
Definition: ModAspectRatioT.hh:87
DecimaterPlugin::slotUpdateRoundness
void slotUpdateRoundness(int _value)
roundness slider - spinbox sync
Definition: DecimaterPlugin.cc:194
DecimaterT.hh
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:103
BackupInterface.hh
BaseObjectData
Definition: BaseObjectData.hh:105
DecimaterPlugin::slot_decimate
void slot_decimate()
decimating called from button in toolbox
Definition: DecimaterPlugin.cc:429
TriangleMesh.hh
OpenMesh::Decimater::ModEdgeLengthT
Use edge length to control decimation.
Definition: ModEdgeLengthT.hh:81
UpdateType
Update type class.
Definition: UpdateType.hh:70
UPDATE_ALL
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
DecimaterPlugin::decimate
void decimate(int _objID, QVariantMap _constraints)
decimate an object
Definition: DecimaterPlugin.cc:531
LoggingInterface.hh
ModHausdorffT.hh
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:123
OpenMesh::Decimater::ModQuadricT
Mesh decimation module computing collapse priority based on error quadrics.
Definition: ModQuadricT.hh:83
ProcessInterface.hh
RPCInterface
Interface to call functions across plugins.
Definition: RPCInterface.hh:71
McDecimaterT.hh
LoadSaveInterface.hh
DecimaterToolbarWidget
Definition: DecimaterToolbarWidget.hh:62
DecimaterPlugin
Definition: DecimaterPlugin.hh:100
DecimaterPlugin::slotUpdateAspectRatio
void slotUpdateAspectRatio(int _value)
sync between values of aspect ratio slider and spinbox in the toolbox
Definition: DecimaterPlugin.cc:230
DecimaterPlugin::slot_initialize
void slot_initialize()
init called from button in toolbox
Definition: DecimaterPlugin.cc:254
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:67
DecimaterPlugin::description
QString description()
Description of the Plugin.
Definition: DecimaterPlugin.hh:181
ModRoundnessT.hh
DecimaterPlugin::slotUpdateNumVertices
void slotUpdateNumVertices()
update number of vertices information
Definition: DecimaterPlugin.cc:865
RPCInterface.hh
LoadSaveInterface
Interface for all plugins which want to Load or Save files and create Objects.
Definition: LoadSaveInterface.hh:68
OpenMesh::Decimater::ModHausdorffT
Use Hausdorff distance to control decimation.
Definition: ModHausdorffT.hh:85
ProcessInterface
Interface class for Thread handling.
Definition: ProcessInterface.hh:75
OpenMesh::Decimater::ModNormalDeviationT
Use Normal deviation to control decimation.
Definition: ModNormalDeviationT.hh:94
DecimaterPlugin::~DecimaterPlugin
~DecimaterPlugin()
Default destructor.
Definition: DecimaterPlugin.hh:175
DecimaterPlugin::tool_
DecimaterToolbarWidget * tool_
Widget for Toolbox.
Definition: DecimaterPlugin.hh:200
ModNormalDeviationT.hh
DecimaterPlugin::name
QString name()
Name of the Plugin.
Definition: DecimaterPlugin.hh:178
BackupInterface
Interface class for backup handling.
Definition: BackupInterface.hh:75
ModQuadricT.hh
DecimaterPlugin::DecimaterPlugin
DecimaterPlugin()
Default constructor.
Definition: DecimaterPlugin.cc:72
ScriptInterface.hh
BaseInterface.hh
DecimaterPlugin::slotUpdateDistance
void slotUpdateDistance()
slider / spinbox updates
Definition: DecimaterPlugin.cc:1027
ModAspectRatioT.hh
ToolboxInterface
Plugins can add its own toolbox to the main widget's toolbox area by using this interface.
Definition: ToolboxInterface.hh:85
DecimaterPlugin::canceledJob
void canceledJob(QString _job)
A job has been canceled.
Definition: DecimaterPlugin.cc:496
Types.hh
OpenMesh::Decimater::ModNormalFlippingT
Definition: ModNormalFlippingT.hh:85
DecimaterPlugin::DecimaterInit
Definition: DecimaterPlugin.hh:203
OpenMesh::Decimater::ModIndependentSetsT
Definition: ModIndependentSetsT.hh:76
ModNormalFlippingT.hh
DecimaterPlugin::pluginsInitialized
void pluginsInitialized()
Initialization of the plugin when it is loaded by the core.
Definition: DecimaterPlugin.cc:165
ToolboxInterface.hh
DecimaterPlugin::slotUpdateNumTriangles
void slotUpdateNumTriangles()
gets and sets the current maximum number of triangles
Definition: DecimaterPlugin.cc:917