glc_worldto3dxml.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  Version 2.0.0 Beta 1, packaged on April 2010.
00006 
00007  http://glc-lib.sourceforge.net
00008 
00009  GLC-lib is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  GLC-lib is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with GLC-lib; if not, write to the Free Software
00021  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023  *****************************************************************************/
00025 
00026 #ifndef GLC_WORLDTO3DXML_H_
00027 #define GLC_WORLDTO3DXML_H_
00028 #include <QObject>
00029 #include <QXmlStreamWriter>
00030 
00031 #include "../sceneGraph/glc_world.h"
00032 #include "../glc_config.h"
00033 #include <QReadWriteLock>
00034 
00035 class QuaZip;
00036 class QuaZipFile;
00037 class QFile;
00038 class GLC_Mesh;
00039 
00042 
00043 
00044 class GLC_LIB_EXPORT GLC_WorldTo3dxml : public QObject
00045 {
00046         Q_OBJECT
00047 
00048 public:
00049         enum ExportType
00050         {
00051                 Compressed3dxml,
00052                 Exploded3dxml
00053         };
00055 
00057 
00058 public:
00059         GLC_WorldTo3dxml(const GLC_World& world);
00060         virtual ~GLC_WorldTo3dxml();
00062 
00064 
00066 
00067 public:
00069         bool exportToFile(const QString& filename, GLC_WorldTo3dxml::ExportType exportType, bool exportMaterial= true);
00070 
00072         inline void setGeneratorName(const QString& generator)
00073         {m_Generator= generator;}
00074 
00076         void setInterupt(QReadWriteLock* pReadWriteLock, bool* pInterupt);
00078 
00080 
00082 
00083 private:
00084 
00086         void writeHeader();
00087 
00089         void writeReference3D(const GLC_StructReference* pRef);
00090 
00092         void writeReferenceRep(const GLC_3DRep* p3DRep);
00093 
00095         void writeInstance3D(const GLC_StructInstance* pInstance, unsigned int parentId);
00096 
00098         void writeInstanceRep(const GLC_3DRep* p3DRep, unsigned int parentId);
00099 
00101         void setStreamWriterToFile(const QString& fileName);
00102 
00104         void addManifest();
00105 
00107         void exportAssemblyStructure();
00108 
00110         void exportAssemblyFromOccurence(const GLC_StructOccurence* pOccurence);
00111 
00113         QString matrixString(const GLC_Matrix4x4& matrix);
00114 
00116         void write3DRep(const GLC_3DRep* pRep, const QString& fileName);
00117 
00119         QString representationFileName(const GLC_3DRep* pRep);
00120 
00122         void writeGeometry(const GLC_Mesh* pMesh);
00123 
00125         void writeGeometryFace(const GLC_Mesh* pMesh, int lod, GLC_uint materialId);
00126 
00128         void writeSurfaceAttributes(const GLC_Material* pMaterial);
00129 
00131         void writeEdges(const GLC_Mesh* pMesh);
00132 
00134         void writeLineAttributes(const QColor& color);
00135 
00137         void writeMaterial(const GLC_Material* pMaterial);
00138 
00140         void writeMaterialAttributtes(const QString& name, const QString& type, const QString& value);
00141 
00143         QString colorToString(const QColor& color);
00144 
00146         void writeCatRepImageFile(const QList<GLC_Material*>& materialList);
00147 
00149         void writeCATRepresentationImage(const GLC_Material* pMat, unsigned int id);
00150 
00152         void writeAllMaterialRelatedFilesIn3dxml();
00153 
00155         void writeImageFileIn3dxml(const QList<GLC_Material*>& materialList);
00156 
00158         void writeCatMaterialRef(const QList<GLC_Material*>& materialList);
00159 
00161         void writeMaterialToCatMaterialRef(const GLC_Material* pMat, unsigned int* id);
00162 
00164         void addImageTextureTo3dxml(const QImage& image, const QString& fileName);
00165 
00167         QString xmlFileName(const QString& fileName);
00168 
00170         void writeExtensionAttributes(GLC_Attributes* pAttributes);
00171 
00173         void writeOccurenceDefaultViewProperty(const GLC_StructOccurence* pOccurence);
00174 
00176         bool continu();
00177 
00179 
00181 // Qt Signals
00183         signals:
00184         void currentQuantum(int);
00185 
00187         /* Private members */
00189 private:
00191         GLC_World m_World;
00192 
00194         QString m_FileName;
00195 
00197         QXmlStreamWriter* m_pOutStream;
00198 
00200         QString m_Generator;
00201 
00203         unsigned int m_CurrentId;
00204 
00206         QuaZip* m_p3dxmlArchive;
00207 
00209         QuaZipFile* m_pCurrentZipFile;
00210 
00212         QFile* m_pCurrentFile;
00213 
00215         QString m_AbsolutePath;
00216 
00218         QHash<const GLC_StructReference*, unsigned int> m_ReferenceToIdHash;
00219 
00221         QHash<const GLC_StructInstance*, unsigned int> m_InstanceToIdHash;
00222 
00224         QHash<const GLC_3DRep*, unsigned int> m_ReferenceRepToIdHash;
00225 
00227         QHash<const GLC_3DRep*, QString> m_ReferenceRepTo3dxmlFileName;
00228 
00230         QSet<unsigned int> m_InstanceRep;
00231 
00233         QHash<GLC_uint, QString> m_MaterialIdToMaterialName;
00234 
00236         QHash<GLC_uint, unsigned int> m_MaterialIdToMaterialId;
00237 
00239         QHash<GLC_uint, QString> m_MaterialIdToTexture3dxmlName;
00240 
00242         QHash<GLC_uint, unsigned int> m_MaterialIdTo3dxmlImageId;
00243 
00245         bool m_ExportMaterial;
00246 
00248         QSet<QString> m_3dxmlFileSet;
00249 
00251         unsigned int m_FileNameIncrement;
00252 
00254         QList<const GLC_StructOccurence*> m_ListOfOverLoadedOccurence;
00255 
00257         QReadWriteLock* m_pReadWriteLock;
00258 
00260         bool* m_pIsInterupted;
00261 
00262 };
00263 
00264 #endif /* GLC_WORLDTO3DXML_H_ */

SourceForge.net Logo

©2005 Laurent Ribon