Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AssimpPlugin.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
5 * www.openflipper.org *
6 * *
7 *--------------------------------------------------------------------------- *
8 * This file is part of OpenFlipper. *
9 * *
10 * OpenFlipper is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenFlipper is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenFlipper. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36 * *
37 * $Revision: 13361 $ *
38 * $LastChangedBy: moebius $ *
39 * $Date: 2012-01-12 16:33:16 +0100 (Thu, 12 Jan 2012) $ *
40 * *
41 \*===========================================================================*/
42 
43 
44 
45 
46 #ifndef ASSIMPPLUGIN_HH
47 #define ASSIMPPLUGIN_HH
48 
49 #include <QObject>
50 
60 
63 
64 #include <assimp/Importer.hpp>
65 #include <assimp/Exporter.hpp>
66 #include <assimp/postprocess.h>
67 #include <assimp/scene.h>
68 
69 
72 {
73  Q_OBJECT
74  Q_INTERFACES(FileInterface)
75  Q_INTERFACES(LoadSaveInterface)
76  Q_INTERFACES(LoggingInterface)
77  Q_INTERFACES(BaseInterface)
78  Q_INTERFACES(ScriptInterface)
79  Q_INTERFACES(RPCInterface)
80  Q_INTERFACES(AboutInfoInterface)
81 
82  #if QT_VERSION >= 0x050000
83  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Assimp")
84  #endif
85 
86  signals:
87  void openedFile( int _id );
88  void addEmptyObject( DataType _type, int& _id);
89  void load(QString _filename, DataType _type, int& _id);
90  void save(int _id , QString _filename );
91  void log(Logtype _type, QString _message);
92  void log(QString _message);
93  void updateView();
94  void updatedObject(int _identifier, const UpdateType& _type);
95 
96  void deleteObject( int _id );
97 
98  //RPCInterface
99  void pluginExists( QString _pluginName , bool& _exists );
100 
101  //AboutInfoInterface
102  void addAboutInfo(QString _text, QString _tabName );
103 public:
104  AssimpPlugin();
105 
106  QString name() { return (QString("AssimpPlugin")); }
107  QString description( ) { return (QString(tr("Load/Save Files with the assimp library"))); }
108 
110 
111  QString getSaveFilters();
112  QString getLoadFilters();
113 
114  QWidget* saveOptionsWidget(QString /*_currentFilter*/);
115  QWidget* loadOptionsWidget(QString /*_currentFilter*/);
116 
117 public slots:
118 
120  int loadObject(QString _filename);
121 
123  int loadObject(QString _filename, DataType _type);
124 
125  bool saveObject(int _id, QString _filename);
126 
127  QString version() { return QString("1.0"); }
128 
129 private slots:
130 
131  void fileOpened( int /*_id*/ ){}
132 
133  void noguiSupported( ) {}
134 
135  void initializePlugin();
136 
137 private:
138 
140  int convertAiSceneToOpenMesh(const aiScene* _scene, QString _objectName);
141 
143  bool convertOpenMeshToAiScene(aiScene* _scene, BaseObjectData* _object);
144 
146  void convertAiMeshToPolyMesh(PolyMesh* _polyMesh, aiMesh* _mesh);
147 
149  void convertAiMeshToTriMesh(TriMesh* _triMesh, aiMesh* _mesh);
150 
152  bool convertPolyMeshToAiMesh(PolyMesh* _polyMesh, aiMesh* _mesh);
153 
155  bool convertTriMeshToAiMesh(TriMesh* _triMesh, aiMesh* _mesh);
156 
158  void mapVertices(PolyMesh* _polyMesh, aiMesh* _mesh);
159 
161  void mapVertices(TriMesh* _triMesh, aiMesh* _mesh);
162 
163 private:
164  //Option Widgets
165  QWidget* loadOptions_;
166  QWidget* saveOptions_;
167 
168  DataType type_;
169 
171  std::map<unsigned int, OpenMesh::VertexHandle> vertexHandles_;
172 };
173 
174 #endif // ASSIMPPLUGIN_HH
Interface to call functions across plugins.
Definition: RPCInterface.hh:71
bool convertPolyMeshToAiMesh(PolyMesh *_polyMesh, aiMesh *_mesh)
converts a polymesh to an aiMesh
Interface for all plugins which want to Load or Save files and create Objects.
int loadObject(QString _filename)
Loads Object and converts it to a triangle mesh if possible.
Interface for all Plugins which provide scriptable Functions.
bool convertOpenMeshToAiScene(aiScene *_scene, BaseObjectData *_object)
converts a polymesh or trimesh to an aiScene
Interface for all Plugins which do logging to the logging window of the framework.
Update type class.
Definition: UpdateType.hh:70
int convertAiSceneToOpenMesh(const aiScene *_scene, QString _objectName)
converts an aiScene to a polymesh or trimesh
std::map< unsigned int, OpenMesh::VertexHandle > vertexHandles_
maps indices of vertices in an aiMesh to OpenMesh VertexHandles
QWidget * loadOptionsWidget(QString)
QString name()
Return a name for the plugin.
QWidget * saveOptionsWidget(QString)
void convertAiMeshToTriMesh(TriMesh *_triMesh, aiMesh *_mesh)
converts _mesh into _triMesh
Interface class from which all plugins have to be created.
Logtype
Log types for Message Window.
bool convertTriMeshToAiMesh(TriMesh *_triMesh, aiMesh *_mesh)
converts a trimesh to an aiMesh
Interface class for file handling.
Predefined datatypes.
Definition: DataTypes.hh:96
QString description()
Return a description of what the plugin is doing.
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
About Info interface.
void convertAiMeshToPolyMesh(PolyMesh *_polyMesh, aiMesh *_mesh)
converts _mesh into _polyMesh
QString getLoadFilters()
QString getSaveFilters()
void mapVertices(PolyMesh *_polyMesh, aiMesh *_mesh)
add a vertex from _mesh to _polyMesh and stores the index to handle mapping