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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef MESHREPAIRPLUGIN_HH
51 #define MESHREPAIRPLUGIN_HH
52 
53 #include <QObject>
54 #include <QMenuBar>
55 
65 
66 #include "MeshRepairToolbar.hh"
67 
69 {
70  Q_OBJECT
71  Q_INTERFACES(BaseInterface)
72  Q_INTERFACES(ToolboxInterface)
73  Q_INTERFACES(BackupInterface)
74  Q_INTERFACES(LoggingInterface)
75  Q_INTERFACES(ScriptInterface)
76  Q_INTERFACES(RPCInterface)
77 
78 #if QT_VERSION >= 0x050000
79  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-MeshRepair")
80 #endif
81 
82 signals:
83 
84  void updateView();
85 
86  // Base Interface
87  void updatedObject(int _identifier, const UpdateType& _type);
88  void setSlotDescription(QString _slotName, QString _slotDescription,
89  QStringList _parameters, QStringList _descriptions);
90 
91  // Logging interface
92  void log(Logtype _type, QString _message);
93  void log(QString _message);
94 
95  // ToolboxInterface
96  void addToolbox( QString _name , QWidget* _widget, QIcon* _icon );
97 
98  // Backup Interface
99  void createBackup( int _objectid, QString _name, UpdateType _type = UPDATE_ALL);
100 
101  // RPC Interface
102  void pluginExists( QString _pluginName , bool& _exists ) ;
103  void functionExists( QString _pluginName , QString _functionName , bool& _exists );
104 
105  // ScriptInterface
106  void scriptInfo( QString _functionName );
107 
108 private slots:
109 
110  void initializePlugin();
111  void pluginsInitialized();
112 
113 public :
114 
116 
117  ~MeshRepairPlugin() {};
118 
119  QString name() {
120  return (QString("Mesh Repair"));
121  };
122  QString description( ) {
123  return (QString("Functionality to repair meshes"));
124  };
125 
126 private :
127 
130  QIcon* toolIcon_;
131 
132 private slots:
133 
136 
139 
142 
145 
147  void slotDetectFoldover();
148 
151 
153  void slotFlipOrientation();
154 
156  void slotFixMesh();
157 
160 
162  void slotUpdateFaceNormals();
163 
166 
168  void slotUpdateNormals();
169 
171  void slotDetectEdgesLonger();
172 
174  void slotDetectEdgesShorter();
175 
178 
180  void slotSnapBoundary();
181 
184 
185 
186  //===========================================================================
189  //===========================================================================
190 
191 public slots:
192 
193  // ==================================================
194  // Vertex operations
195  // ==================================================
196 
200  void detectFlatValence3Vertices(int _objectId, double _angle);
201 
203  void removeSelectedVal3Vertices(int _objectId);
204 
205  // ==================================================
206  // Edge operations
207  // ==================================================
208 
214  void selectEdgesShorterThan(int _objectId,double _length);
215 
221  void selectEdgesLongerThan(int _objectId,double _length);
222 
227  void removeSelectedEdges(int _objectId);
228 
235  void detectSkinnyTriangleByAngle(int _objectId, double _angle, bool _remove);
236 
242  void detectFoldover(int _objectId, float _angle);
243 
244 
245  // ==================================================
246  // Face operations
247  // ==================================================
248 
254  void detectTriangleAspect(int _objectId, float _aspect);
255 
260  void flipOrientation(int _objectId);
261 
262  // ==================================================
263  // Normal recomputations
264  // ==================================================
265 
270  void updateFaceNormals(int _objectId);
271 
276  void updateHalfedgeNormals(int _objectId);
277 
282  void updateVertexNormals(int _objectId);
283 
288  void updateNormals(int _objectId);
289 
290  // ==================================================
291  // General
292  // ==================================================
293 
303  void snapBoundary(int _objectId, double _eps);
304 
309  void fixNonManifoldVertices(int _objectId);
310 
320  void fixMesh(int _objectId, double _epsilon);
321 
324 private:
332  void selectionEdgeLength(int _objectId, double _length, bool _larger);
333 
342  template<typename MeshT>
343  void flipOrientation(MeshT& _mesh);
344 
345 
346 public slots:
347  QString version() { return QString("1.3"); };
348 };
349 
350 #if defined(INCLUDE_TEMPLATES) && !defined(MESHREPAIRPLUGINT_CC)
351 #define MESHREPAIRPLUGIN_TEMPLATES
352 #include "MeshRepairPluginT.cc"
353 #endif
354 
355 #endif //MESHREPAIRPLUGIN_HH
void updateFaceNormals(int _objectId)
Recomputes the face normals of an object.
Definition: NormalFixing.cc:60
void slotDetectSkinnyTriangleByAngle()
Button slot.
void slotDetectFlatValence3Vertices()
Button slot.
void slotRemoveSkinnyTriangleByAngle()
Button slot.
void fixNonManifoldVertices(int _objectId)
remove non-manifold vertices by duplicating them
void slotSnapBoundary()
Button slot.
void detectFoldover(int _objectId, float _angle)
Detect folded-over configurations by the dihedral angle.
Logtype
Log types for Message Window.
void detectSkinnyTriangleByAngle(int _objectId, double _angle, bool _remove)
Detect/Remove edges where neighboring faces form angle > _angle degrees.
void selectEdgesLongerThan(int _objectId, double _length)
Selects all edges of an object which are larger than the given length.
void slotFixMesh()
Button slot.
void detectTriangleAspect(int _objectId, float _aspect)
Detect triangles with aspect ratio greater than _aspect and select them.
void pluginsInitialized()
Initialization of the plugin when it is loaded by the core.
void flipOrientation(int _objectId)
Flips the normals of all selected faces by changing the vertex order.
QString description()
Return a description of what the plugin is doing.
void slotFlipOrientation()
Button slot.
Interface for all Plugins which provide scriptable Functions.
void selectEdgesShorterThan(int _objectId, double _length)
Selects all edges of an object which are shorter than the given length.
void slotUpdateNormals()
Button slot.
Interface class from which all plugins have to be created.
QString name()
Return a name for the plugin.
void detectFlatValence3Vertices(int _objectId, double _angle)
Detect valence 3 vertices with faces that lie in the plane of their adjacent triangles.
Update type class.
Definition: UpdateType.hh:70
Plugins can add its own toolbox to the main widget&#39;s toolbox area by using this interface.
void selectionEdgeLength(int _objectId, double _length, bool _larger)
select edges based on length
Interface for all Plugins which do logging to the logging window of the framework.
void slotRemoveSelectedEdges()
Button slot.
void updateHalfedgeNormals(int _objectId)
Recomputes the halfedge normals of an object.
Definition: NormalFixing.cc:89
void slotUpdateFaceNormals()
Button slot.
void updateNormals(int _objectId)
Recomputes the face and vertex normals of an object.
void slotFixNonManifoldVertices()
Button slot.
void fixMesh(int _objectId, double _epsilon)
Fix a mesh.
void slotDetectEdgesShorter()
Button Slot.
void slotDetectFoldover()
Button slot.
void removeSelectedEdges(int _objectId)
Removes all selected edges.
void removeSelectedVal3Vertices(int _objectId)
Remove all selected valence 3 vertices.
void updateVertexNormals(int _objectId)
Recomputes the vertex normals of an object.
void slotUpdateVertexNormals()
Button slot.
void slotUpdateHalfedgeNormals()
Button slot.
void snapBoundary(int _objectId, double _eps)
Snaps selected vertices at boundaries.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
MeshRepairToolbarWidget * tool_
Widget for Toolbox.
void slotRemoveSelectedVal3Vertices()
Button slot.
void slotDetectTriangleAspect()
Button slot.
Interface to call functions across plugins.
Definition: RPCInterface.hh:71
void slotDetectEdgesLonger()
Button Slot.
Interface class for backup handling.