GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_worldto3dxml.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  *****************************************************************************/
23 
24 #ifndef GLC_WORLDTO3DXML_H_
25 #define GLC_WORLDTO3DXML_H_
26 #include <QObject>
27 #include <QXmlStreamWriter>
28 
29 #include "../sceneGraph/glc_world.h"
30 #include "../glc_config.h"
31 #include <QReadWriteLock>
32 
33 class QuaZip;
34 class QuaZipFile;
35 class QFile;
36 class GLC_Mesh;
37 
40 
41 
42 class GLC_LIB_EXPORT GLC_WorldTo3dxml : public QObject
43 {
44  Q_OBJECT
45 
46 public:
48  {
51  StructureOnly
52  };
54 
56 
57 public:
58  GLC_WorldTo3dxml(const GLC_World& world, bool threaded= true);
59  virtual ~GLC_WorldTo3dxml();
61 
63 
65 
66 public:
68  bool exportTo3dxml(const QString& filename, GLC_WorldTo3dxml::ExportType exportType, bool exportMaterial= true);
69 
71  bool exportReferenceTo3DRep(const GLC_3DRep* p3DRep, const QString& fullFileName);
72 
74  inline void setGeneratorName(const QString& generator)
75  {m_Generator= generator;}
76 
78  void setInterupt(QReadWriteLock* pReadWriteLock, bool* pInterupt);
80 
82 
84 
85 private:
86 
88  void writeHeader();
89 
91  void writeReference3D(const GLC_StructReference* pRef);
92 
94  void writeReferenceRep(const GLC_3DRep* p3DRep);
95 
97  void writeInstance3D(const GLC_StructInstance* pInstance, unsigned int parentId);
98 
100  void writeInstanceRep(const GLC_3DRep* p3DRep, unsigned int parentId);
101 
103  void setStreamWriterToFile(const QString& fileName);
104 
106  void addManifest();
107 
109  void exportAssemblyStructure();
110 
112  void exportAssemblyFromOccurence(const GLC_StructOccurence* pOccurence);
113 
115  QString matrixString(const GLC_Matrix4x4& matrix);
116 
118  void write3DRep(const GLC_3DRep* pRep, const QString& fileName);
119 
121  QString representationFileName(const GLC_3DRep* pRep);
122 
124  void writeGeometry(const GLC_Mesh* pMesh);
125 
127  void writeGeometryFace(const GLC_Mesh* pMesh, int lod, GLC_uint materialId);
128 
130  void writeSurfaceAttributes(const GLC_Material* pMaterial);
131 
133  void writeEdges(const GLC_Mesh* pMesh);
134 
136  void writeLineAttributes(const QColor& color);
137 
139  void writeMaterial(const GLC_Material* pMaterial);
140 
142  void writeMaterialAttributtes(const QString& name, const QString& type, const QString& value);
143 
145  QString colorToString(const QColor& color);
146 
148  void writeCatRepImageFile(const QList<GLC_Material*>& materialList);
149 
151  void writeCATRepresentationImage(const GLC_Material* pMat, unsigned int id);
152 
154  void writeAllMaterialRelatedFilesIn3dxml();
155 
157  void writeImageFileIn3dxml(const QList<GLC_Material*>& materialList);
158 
160  void writeCatMaterialRef(const QList<GLC_Material*>& materialList);
161 
163  void writeMaterialToCatMaterialRef(const GLC_Material* pMat, unsigned int* id);
164 
166  void addImageTextureTo3dxml(const QImage& image, const QString& fileName);
167 
169  QString xmlFileName(QString fileName);
170 
172  void writeExtensionAttributes(GLC_Attributes* pAttributes);
173 
175  void writeOccurenceDefaultViewProperty(const GLC_StructOccurence* pOccurence);
176 
178  bool continu();
179 
181  QString symplifyName(QString name);
182 
184  QList<unsigned int> instancePath(const GLC_StructOccurence* pOccurence);
185 
187 
189 // Qt Signals
191  signals:
192  void currentQuantum(int);
193 
195  /* Private members */
197 private:
200 
203 
205  QString m_FileName;
206 
208  QXmlStreamWriter* m_pOutStream;
209 
211  QString m_Generator;
212 
214  unsigned int m_CurrentId;
215 
218 
220  QuaZipFile* m_pCurrentZipFile;
221 
224 
226  QString m_AbsolutePath;
227 
229  QHash<const GLC_StructReference*, unsigned int> m_ReferenceToIdHash;
230 
232  QHash<const GLC_StructInstance*, unsigned int> m_InstanceToIdHash;
233 
235  QHash<const GLC_3DRep*, unsigned int> m_ReferenceRepToIdHash;
236 
238  QHash<const GLC_3DRep*, QString> m_ReferenceRepTo3dxmlFileName;
239 
241  QSet<unsigned int> m_InstanceRep;
242 
244  QHash<GLC_uint, QString> m_MaterialIdToMaterialName;
245 
247  QHash<GLC_uint, unsigned int> m_MaterialIdToMaterialId;
248 
250  QHash<GLC_uint, QString> m_MaterialIdToTexture3dxmlName;
251 
253  QHash<GLC_uint, unsigned int> m_MaterialIdTo3dxmlImageId;
254 
257 
259  QSet<QString> m_3dxmlFileSet;
260 
262  unsigned int m_FileNameIncrement;
263 
265  QList<const GLC_StructOccurence*> m_ListOfOverLoadedOccurence;
266 
268  QReadWriteLock* m_pReadWriteLock;
269 
272 
275 
276 };
277 
278 #endif /* GLC_WORLDTO3DXML_H_ */

©2005-2013 Laurent Ribon