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  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021  *****************************************************************************/
00023 
00024 #ifndef GLC_WORLDTO3DXML_H_
00025 #define GLC_WORLDTO3DXML_H_
00026 #include <QObject>
00027 #include <QXmlStreamWriter>
00028 
00029 #include "../sceneGraph/glc_world.h"
00030 #include "../glc_config.h"
00031 #include <QReadWriteLock>
00032 
00033 class QuaZip;
00034 class QuaZipFile;
00035 class QFile;
00036 class GLC_Mesh;
00037 
00040 
00041 
00042 class GLC_LIB_EXPORT GLC_WorldTo3dxml : public QObject
00043 {
00044         Q_OBJECT
00045 
00046 public:
00047         enum ExportType
00048         {
00049                 Compressed3dxml,
00050                 Exploded3dxml,
00051                 StructureOnly
00052         };
00054 
00056 
00057 public:
00058         GLC_WorldTo3dxml(const GLC_World& world, bool threaded= true);
00059         virtual ~GLC_WorldTo3dxml();
00061 
00063 
00065 
00066 public:
00068         bool exportTo3dxml(const QString& filename, GLC_WorldTo3dxml::ExportType exportType, bool exportMaterial= true);
00069 
00071         bool exportReferenceTo3DRep(const GLC_3DRep* p3DRep, const QString& fullFileName);
00072 
00074         inline void setGeneratorName(const QString& generator)
00075         {m_Generator= generator;}
00076 
00078         void setInterupt(QReadWriteLock* pReadWriteLock, bool* pInterupt);
00080 
00082 
00084 
00085 private:
00086 
00088         void writeHeader();
00089 
00091         void writeReference3D(const GLC_StructReference* pRef);
00092 
00094         void writeReferenceRep(const GLC_3DRep* p3DRep);
00095 
00097         void writeInstance3D(const GLC_StructInstance* pInstance, unsigned int parentId);
00098 
00100         void writeInstanceRep(const GLC_3DRep* p3DRep, unsigned int parentId);
00101 
00103         void setStreamWriterToFile(const QString& fileName);
00104 
00106         void addManifest();
00107 
00109         void exportAssemblyStructure();
00110 
00112         void exportAssemblyFromOccurence(const GLC_StructOccurence* pOccurence);
00113 
00115         QString matrixString(const GLC_Matrix4x4& matrix);
00116 
00118         void write3DRep(const GLC_3DRep* pRep, const QString& fileName);
00119 
00121         QString representationFileName(const GLC_3DRep* pRep);
00122 
00124         void writeGeometry(const GLC_Mesh* pMesh);
00125 
00127         void writeGeometryFace(const GLC_Mesh* pMesh, int lod, GLC_uint materialId);
00128 
00130         void writeSurfaceAttributes(const GLC_Material* pMaterial);
00131 
00133         void writeEdges(const GLC_Mesh* pMesh);
00134 
00136         void writeLineAttributes(const QColor& color);
00137 
00139         void writeMaterial(const GLC_Material* pMaterial);
00140 
00142         void writeMaterialAttributtes(const QString& name, const QString& type, const QString& value);
00143 
00145         QString colorToString(const QColor& color);
00146 
00148         void writeCatRepImageFile(const QList<GLC_Material*>& materialList);
00149 
00151         void writeCATRepresentationImage(const GLC_Material* pMat, unsigned int id);
00152 
00154         void writeAllMaterialRelatedFilesIn3dxml();
00155 
00157         void writeImageFileIn3dxml(const QList<GLC_Material*>& materialList);
00158 
00160         void writeCatMaterialRef(const QList<GLC_Material*>& materialList);
00161 
00163         void writeMaterialToCatMaterialRef(const GLC_Material* pMat, unsigned int* id);
00164 
00166         void addImageTextureTo3dxml(const QImage& image, const QString& fileName);
00167 
00169         QString xmlFileName(QString fileName);
00170 
00172         void writeExtensionAttributes(GLC_Attributes* pAttributes);
00173 
00175         void writeOccurenceDefaultViewProperty(const GLC_StructOccurence* pOccurence);
00176 
00178         bool continu();
00179 
00181         QString symplifyName(QString name);
00182 
00184         QList<unsigned int> instancePath(const GLC_StructOccurence* pOccurence);
00185 
00187 
00189 // Qt Signals
00191         signals:
00192         void currentQuantum(int);
00193 
00195         /* Private members */
00197 private:
00199         GLC_World m_World;
00200 
00202         ExportType m_ExportType;
00203 
00205         QString m_FileName;
00206 
00208         QXmlStreamWriter* m_pOutStream;
00209 
00211         QString m_Generator;
00212 
00214         unsigned int m_CurrentId;
00215 
00217         QuaZip* m_p3dxmlArchive;
00218 
00220         QuaZipFile* m_pCurrentZipFile;
00221 
00223         QFile* m_pCurrentFile;
00224 
00226         QString m_AbsolutePath;
00227 
00229         QHash<const GLC_StructReference*, unsigned int> m_ReferenceToIdHash;
00230 
00232         QHash<const GLC_StructInstance*, unsigned int> m_InstanceToIdHash;
00233 
00235         QHash<const GLC_3DRep*, unsigned int> m_ReferenceRepToIdHash;
00236 
00238         QHash<const GLC_3DRep*, QString> m_ReferenceRepTo3dxmlFileName;
00239 
00241         QSet<unsigned int> m_InstanceRep;
00242 
00244         QHash<GLC_uint, QString> m_MaterialIdToMaterialName;
00245 
00247         QHash<GLC_uint, unsigned int> m_MaterialIdToMaterialId;
00248 
00250         QHash<GLC_uint, QString> m_MaterialIdToTexture3dxmlName;
00251 
00253         QHash<GLC_uint, unsigned int> m_MaterialIdTo3dxmlImageId;
00254 
00256         bool m_ExportMaterial;
00257 
00259         QSet<QString> m_3dxmlFileSet;
00260 
00262         unsigned int m_FileNameIncrement;
00263 
00265         QList<const GLC_StructOccurence*> m_ListOfOverLoadedOccurence;
00266 
00268         QReadWriteLock* m_pReadWriteLock;
00269 
00271         bool* m_pIsInterupted;
00272 
00274         bool m_IsThreaded;
00275 
00276 };
00277 
00278 #endif /* GLC_WORLDTO3DXML_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon