Developer Documentation

MeshRepairPlugin.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 #ifndef MESHREPAIRPLUGIN_HH
45 #define MESHREPAIRPLUGIN_HH
46
47 #include <QObject>
48 #include <QMenuBar>
49
50 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
51 #include <OpenFlipper/BasePlugin/LoggingInterface.hh>
52 #include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
53 #include <OpenFlipper/BasePlugin/BackupInterface.hh>
54 #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
55 #include <OpenFlipper/BasePlugin/RPCInterface.hh>
56 #include <OpenFlipper/BasePlugin/PythonInterface.hh>
57 #include <OpenFlipper/common/Types.hh>
58 #include <ObjectTypes/PolyMesh/PolyMesh.hh>
59 #include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
60
61 #include "MeshRepairToolbar.hh"
62
63 class MeshRepairPlugin : public QObject, BaseInterface , ToolboxInterface, BackupInterface, LoggingInterface, ScriptInterface, RPCInterface, PythonInterface
64 {
65 Q_OBJECT
66 Q_INTERFACES(BaseInterface)
67 Q_INTERFACES(ToolboxInterface)
68 Q_INTERFACES(BackupInterface)
69 Q_INTERFACES(LoggingInterface)
70 Q_INTERFACES(ScriptInterface)
71 Q_INTERFACES(RPCInterface)
72 Q_INTERFACES(PythonInterface)
73
74 Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-MeshRepair")
75
76 signals:
77
78 void updateView();
79
80 // Base Interface
81 void updatedObject(int _identifier, const UpdateType& _type);
82 void setSlotDescription(QString _slotName, QString _slotDescription,
83 QStringList _parameters, QStringList _descriptions);
84
85 // Logging interface
86 void log(Logtype _type, QString _message);
87 void log(QString _message);
88
89 // ToolboxInterface
90 void addToolbox( QString _name , QWidget* _widget, QIcon* _icon );
91
92 // Backup Interface
93 void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL);
94
95 // RPC Interface
96 void pluginExists( QString _pluginName , bool& _exists ) ;
97 void functionExists( QString _pluginName , QString _functionName , bool& _exists );
98
99 // ScriptInterface
100 void scriptInfo( QString _functionName );
101
102 private slots:
103
104 void initializePlugin();
105 void pluginsInitialized();
106
107 public :
108
109 MeshRepairPlugin();
110
111 ~MeshRepairPlugin() {};
112
113 QString name() {
114 return (QString("MeshRepair"));
115 };
116 QString description( ) {
117 return (QString("Functionality to repair meshes"));
118 };
119
120 private :
121
123 MeshRepairToolbarWidget* tool_;
124 QIcon* toolIcon_;
125
126 private slots:
127
129 void slotRemoveSelectedVal3Vertices();
130
132 void slotRemoveSelectedEdges();
133
135 void slotDetectSkinnyTriangleByAngle();
136
138 void slotRemoveSkinnyTriangleByAngle();
139
141 void slotDetectFoldover();
142
144 void slotDetectTriangleAspect();
145
147 void slotFlipOrientation();
148
150 void slotFixMesh();
151
153 void slotUpdateVertexNormals();
154
156 void slotUpdateFaceNormals();
157
159 void slotUpdateHalfedgeNormals();
160
162 void slotUpdateNormals();
163
165 void slotDetectEdgesLonger();
166
168 void slotDetectEdgesShorter();
169
171 void slotDetectFlatValence3Vertices();
172
174 void slotSnapBoundary();
175
177 void slotFixNonManifoldVertices();
178
179
180 //===========================================================================
183 //===========================================================================
184
185 public slots:
186
187 // ==================================================
188 // Vertex operations
189 // ==================================================
190
194 void detectFlatValence3Vertices(int _objectId, double _angle);
195
197 void removeSelectedVal3Vertices(int _objectId);
198
199 // ==================================================
200 // Edge operations
201 // ==================================================
202
208 void selectEdgesShorterThan(int _objectId,double _length);
209
215 void selectEdgesLongerThan(int _objectId,double _length);
216
221 void removeSelectedEdges(int _objectId);
222
229 void detectSkinnyTriangleByAngle(int _objectId, double _angle, bool _remove);
230
236 void detectFoldover(int _objectId, float _angle);
237
238
239 // ==================================================
240 // Face operations
241 // ==================================================
242
248 void detectTriangleAspect(int _objectId, float _aspect);
249
254 void flipOrientation(int _objectId);
255
256 // ==================================================
257 // Normal recomputations
258 // ==================================================
259
264 void updateFaceNormals(int _objectId);
265
270 void updateHalfedgeNormals(int _objectId);
271
276 void updateVertexNormals(int _objectId);
277
282 void updateNormals(int _objectId);
283
284 // ==================================================
285 // General
286 // ==================================================
287
297 void snapBoundary(int _objectId, double _eps);
298
303 void fixNonManifoldVertices(int _objectId);
304
314 void fixMesh(int _objectId, double _epsilon);
315
318 private:
326 void selectionEdgeLength(int _objectId, double _length, bool _larger);
327
336 template<typename MeshT>
337 void flipOrientation(MeshT& _mesh);
338
339
340 public slots:
341 QString version() { return QString("1.3"); };
342 };
343
344 #if defined(INCLUDE_TEMPLATES) && !defined(MESHREPAIRPLUGINT_CC)
345 #define MESHREPAIRPLUGIN_TEMPLATES
346 #include "MeshRepairPluginT_impl.hh"
347 #endif
348
349 #endif //MESHREPAIRPLUGIN_HH
MeshRepairPlugin::slotDetectFoldover
void slotDetectFoldover()
Button slot.
Definition: MeshRepairPlugin.cc:156
MeshRepairPlugin::detectFlatValence3Vertices
void detectFlatValence3Vertices(int _objectId, double _angle)
Detect valence 3 vertices with faces that lie in the plane of their adjacent triangles.
Definition: VertexFunctions.cc:51
MeshRepairPlugin::removeSelectedVal3Vertices
void removeSelectedVal3Vertices(int _objectId)
Remove all selected valence 3 vertices.
Definition: VertexFunctions.cc:107
MeshRepairPlugin::slotRemoveSelectedEdges
void slotRemoveSelectedEdges()
Button slot.
Definition: MeshRepairPlugin.cc:125
UpdateType
Update type class.
Definition: UpdateType.hh:60
MeshRepairPlugin::slotDetectTriangleAspect
void slotDetectTriangleAspect()
Button slot.
Definition: MeshRepairPlugin.cc:166
RPCInterface
Interface to call functions across plugins.
Definition: RPCInterface.hh:61
MeshRepairPlugin::pluginsInitialized
void pluginsInitialized()
Initialization of the plugin when it is loaded by the core.
Definition: MeshRepairPlugin.cc:290
UPDATE_ALL
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
TriangleMesh.hh
Logtype
Logtype
Log types for Message Window.
Definition: LoggingInterface.hh:92
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:58
MeshRepairPlugin::slotUpdateVertexNormals
void slotUpdateVertexNormals()
Button slot.
Definition: MeshRepairPlugin.cc:198
MeshRepairPlugin::slotFlipOrientation
void slotFlipOrientation()
Button slot.
Definition: MeshRepairPlugin.cc:176
LoggingInterface.hh
MeshRepairPlugin::updateHalfedgeNormals
void updateHalfedgeNormals(int _objectId)
Recomputes the halfedge normals of an object.
Definition: NormalFixing.cc:82
MeshRepairPlugin::slotRemoveSelectedVal3Vertices
void slotRemoveSelectedVal3Vertices()
Button slot.
Definition: MeshRepairPlugin.cc:115
MeshRepairPlugin::slotDetectEdgesLonger
void slotDetectEdgesLonger()
Button Slot.
Definition: MeshRepairPlugin.cc:245
MeshRepairPlugin::description
QString description()
Return a description of what the plugin is doing.
Definition: MeshRepairPlugin.hh:116
MeshRepairPlugin::detectSkinnyTriangleByAngle
void detectSkinnyTriangleByAngle(int _objectId, double _angle, bool _remove)
Detect/Remove edges where neighboring faces form angle > _angle degrees.
Definition: EdgeFunctions.cc:189
MeshRepairPlugin::slotUpdateHalfedgeNormals
void slotUpdateHalfedgeNormals()
Button slot.
Definition: MeshRepairPlugin.cc:216
MeshRepairPlugin::slotDetectFlatValence3Vertices
void slotDetectFlatValence3Vertices()
Button slot.
Definition: MeshRepairPlugin.cc:256
MeshRepairPlugin::updateFaceNormals
void updateFaceNormals(int _objectId)
Recomputes the face normals of an object.
Definition: NormalFixing.cc:53
MeshRepairPlugin::detectFoldover
void detectFoldover(int _objectId, float _angle)
Detect folded-over configurations by the dihedral angle.
Definition: EdgeFunctions.cc:252
MeshRepairPlugin
Definition: MeshRepairPlugin.hh:63
MeshRepairPlugin::slotUpdateFaceNormals
void slotUpdateFaceNormals()
Button slot.
Definition: MeshRepairPlugin.cc:207
LoggingInterface
Interface for all Plugins which do logging to the logging window of the framework.
Definition: LoggingInterface.hh:112
MeshRepairPlugin::fixMesh
void fixMesh(int _objectId, double _epsilon)
Fix a mesh.
Definition: GeneralMeshFixing.cc:107
BaseInterface.hh
MeshRepairPlugin::slotDetectSkinnyTriangleByAngle
void slotDetectSkinnyTriangleByAngle()
Button slot.
Definition: MeshRepairPlugin.cc:135
MeshRepairPlugin::tool_
MeshRepairToolbarWidget * tool_
Widget for Toolbox.
Definition: MeshRepairPlugin.hh:118
MeshRepairPlugin::updateVertexNormals
void updateVertexNormals(int _objectId)
Recomputes the vertex normals of an object.
Definition: NormalFixing.cc:114
ToolboxInterface
Plugins can add its own toolbox to the main widget&#39;s toolbox area by using this interface.
Definition: ToolboxInterface.hh:68
MeshRepairPlugin::slotFixMesh
void slotFixMesh()
Button slot.
Definition: MeshRepairPlugin.cc:186
MeshRepairPlugin::slotFixNonManifoldVertices
void slotFixNonManifoldVertices()
Button slot.
Definition: MeshRepairPlugin.cc:277
MeshRepairPlugin::slotRemoveSkinnyTriangleByAngle
void slotRemoveSkinnyTriangleByAngle()
Button slot.
Definition: MeshRepairPlugin.cc:145
MeshRepairPlugin::slotSnapBoundary
void slotSnapBoundary()
Button slot.
Definition: MeshRepairPlugin.cc:267
MeshRepairPlugin::selectEdgesLongerThan
void selectEdgesLongerThan(int _objectId, double _length)
Selects all edges of an object which are larger than the given length.
Definition: EdgeFunctions.cc:56
MeshRepairPlugin::selectEdgesShorterThan
void selectEdgesShorterThan(int _objectId, double _length)
Selects all edges of an object which are shorter than the given length.
Definition: EdgeFunctions.cc:48
MeshRepairPlugin::slotDetectEdgesShorter
void slotDetectEdgesShorter()
Button Slot.
Definition: MeshRepairPlugin.cc:234
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
ToolboxInterface.hh
MeshRepairPlugin::slotUpdateNormals
void slotUpdateNormals()
Button slot.
Definition: MeshRepairPlugin.cc:225
MeshRepairPlugin::removeSelectedEdges
void removeSelectedEdges(int _objectId)
Removes all selected edges.
Definition: EdgeFunctions.cc:136
BackupInterface.hh
PythonInterface.hh
Types.hh
MeshRepairPlugin::flipOrientation
void flipOrientation(int _objectId)
Flips the normals of all selected faces by changing the vertex order.
Definition: FaceFunctions.cc:98
MeshRepairPlugin::selectionEdgeLength
void selectionEdgeLength(int _objectId, double _length, bool _larger)
select edges based on length
Definition: EdgeFunctions.cc:65
MeshRepairToolbarWidget
Definition: MeshRepairToolbar.hh:47
MeshRepairPlugin::fixNonManifoldVertices
void fixNonManifoldVertices(int _objectId)
remove non-manifold vertices by duplicating them
Definition: GeneralMeshFixing.cc:79
MeshRepairPlugin::detectTriangleAspect
void detectTriangleAspect(int _objectId, float _aspect)
Detect triangles with aspect ratio greater than _aspect and select them.
Definition: FaceFunctions.cc:52
MeshRepairPlugin::updateNormals
void updateNormals(int _objectId)
Recomputes the face and vertex normals of an object.
Definition: NormalFixing.cc:141
BackupInterface
Interface class for backup handling.
Definition: BackupInterface.hh:59
RPCInterface.hh
PythonInterface
Interface class for exporting functions to python.
Definition: PythonInterface.hh:58
PolyMesh.hh
MeshRepairPlugin::name
QString name()
Return a name for the plugin.
Definition: MeshRepairPlugin.hh:113
ScriptInterface.hh
MeshRepairPlugin::snapBoundary
void snapBoundary(int _objectId, double _eps)
Snaps selected vertices at boundaries.
Definition: GeneralMeshFixing.cc:52