00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00025
00026 #include "glc_worldto3dxml.h"
00027
00028 #include "../quazip/quazip.h"
00029 #include "../quazip/quazipfile.h"
00030 #include "../glc_exception.h"
00031 #include "../geometry/glc_mesh.h"
00032
00033 #include <QFileInfo>
00034
00035 GLC_WorldTo3dxml::GLC_WorldTo3dxml(const GLC_World& world)
00036 : QObject()
00037 , m_World(world)
00038 , m_FileName()
00039 , m_pOutStream(NULL)
00040 , m_Generator("GLC_LIB")
00041 , m_CurrentId(0)
00042 , m_p3dxmlArchive(NULL)
00043 , m_pCurrentZipFile(NULL)
00044 , m_pCurrentFile(NULL)
00045 , m_AbsolutePath()
00046 , m_ReferenceToIdHash()
00047 , m_InstanceToIdHash()
00048 , m_ReferenceRepToIdHash()
00049 , m_ReferenceRepTo3dxmlFileName()
00050 , m_InstanceRep()
00051 , m_MaterialIdToMaterialName()
00052 , m_MaterialIdToMaterialId()
00053 , m_MaterialIdToTexture3dxmlName()
00054 , m_MaterialIdTo3dxmlImageId()
00055 , m_ExportMaterial(true)
00056 , m_3dxmlFileSet()
00057 , m_FileNameIncrement(0)
00058 , m_ListOfOverLoadedOccurence()
00059 , m_pReadWriteLock(NULL)
00060 , m_pIsInterupted(NULL)
00061 {
00062 m_World.rootOccurence()->updateOccurenceNumber(1);
00063 }
00064
00065 GLC_WorldTo3dxml::~GLC_WorldTo3dxml()
00066 {
00067 delete m_p3dxmlArchive;
00068 delete m_pCurrentZipFile;
00069 delete m_pCurrentFile;
00070 }
00071
00072 bool GLC_WorldTo3dxml::exportToFile(const QString& filename, GLC_WorldTo3dxml::ExportType exportType, bool exportMaterial)
00073 {
00074 m_3dxmlFileSet.clear();
00075 m_ListOfOverLoadedOccurence.clear();
00076 m_FileNameIncrement= 0;
00077 m_ExportMaterial= exportMaterial;
00078 m_FileName= filename;
00079 bool isExported= false;
00080 if (exportType == Compressed3dxml)
00081 {
00082 m_p3dxmlArchive= new QuaZip(m_FileName);
00083 isExported= m_p3dxmlArchive->open(QuaZip::mdCreate);
00084
00085 addManifest();
00086
00087 }
00088 else
00089 {
00090 m_AbsolutePath= QFileInfo(m_FileName).absolutePath() + QDir::separator();
00091 QFile exportFile(m_FileName);
00092 isExported= exportFile.open(QIODevice::WriteOnly);
00093 exportFile.close();
00094 }
00095 if (isExported)
00096 {
00097 if (m_ExportMaterial)
00098 {
00099 writeAllMaterialRelatedFilesIn3dxml();
00100 }
00101
00102
00103 exportAssemblyStructure();
00104
00105 int previousQuantumValue= 0;
00106 int currentQuantumValue= 0;
00107 emit currentQuantum(currentQuantumValue);
00108
00109 int currentRepIndex= 0;
00110 const int size= m_ReferenceRepTo3dxmlFileName.size();
00111
00112 QHash<const GLC_3DRep*, QString>::const_iterator iRep= m_ReferenceRepTo3dxmlFileName.constBegin();
00113 while ((m_ReferenceRepTo3dxmlFileName.constEnd() != iRep) && continu())
00114 {
00115 write3DRep(iRep.key(), iRep.value());
00116 ++iRep;
00117
00118
00119 ++currentRepIndex;
00120 currentQuantumValue = static_cast<int>((static_cast<double>(currentRepIndex) / size) * 100);
00121 if (currentQuantumValue > previousQuantumValue)
00122 {
00123 emit currentQuantum(currentQuantumValue);
00124 }
00125 previousQuantumValue= currentQuantumValue;
00126 }
00127 }
00128
00129 emit currentQuantum(100);
00130 return isExported;
00131 }
00132
00133 void GLC_WorldTo3dxml::setInterupt(QReadWriteLock* pReadWriteLock, bool* pInterupt)
00134 {
00135 m_pReadWriteLock= pReadWriteLock;
00136 m_pIsInterupted= pInterupt;
00137 }
00138
00139 void GLC_WorldTo3dxml::writeHeader()
00140 {
00141 const QString title(QFileInfo(m_FileName).fileName());
00142
00143 m_pOutStream->writeStartElement("Header");
00144 m_pOutStream->writeTextElement("SchemaVersion", "4.0");
00145 m_pOutStream->writeTextElement("Title", title);
00146 m_pOutStream->writeTextElement("Generator", m_Generator);
00147 m_pOutStream->writeTextElement("Created", QDate::currentDate().toString("YYYY-MM-DD"));
00148 m_pOutStream->writeEndElement();
00149 }
00150
00151 void GLC_WorldTo3dxml::writeReference3D(const GLC_StructReference* pRef)
00152 {
00153 m_pOutStream->writeStartElement("Reference3D");
00154 m_pOutStream->writeAttribute("xsi:type", "Reference3DType");
00155 m_pOutStream->writeAttribute("id", QString::number(++m_CurrentId));
00156 m_pOutStream->writeAttribute("name", pRef->name());
00157 if (pRef->containsAttributes())
00158 {
00159 m_pOutStream->writeStartElement("Reference3DExtensionType");
00160 writeExtensionAttributes(pRef->attributesHandle());
00161 m_pOutStream->writeEndElement();
00162 }
00163 m_pOutStream->writeEndElement();
00164
00165 m_ReferenceToIdHash.insert(pRef, m_CurrentId);
00166 }
00167
00168 void GLC_WorldTo3dxml::writeReferenceRep(const GLC_3DRep* p3DRep)
00169 {
00170 const QString id(QString::number(++m_CurrentId));
00171 m_ReferenceRepToIdHash.insert(p3DRep, m_CurrentId);
00172 const QString associateFile(representationFileName(p3DRep));
00173 m_ReferenceRepTo3dxmlFileName.insert(p3DRep, QString(associateFile).remove("urn:3DXML:"));
00174
00175 m_pOutStream->writeStartElement("ReferenceRep");
00176 m_pOutStream->writeAttribute("xsi:type", "ReferenceRepType");
00177 m_pOutStream->writeAttribute("id", id);
00178 m_pOutStream->writeAttribute("name", p3DRep->name());
00179 m_pOutStream->writeAttribute("format", "TESSELLATED");
00180 m_pOutStream->writeAttribute("version", "1.2");
00181 m_pOutStream->writeAttribute("associatedFile", associateFile);
00182 m_pOutStream->writeTextElement("PLM_ExternalID", p3DRep->name());
00183 m_pOutStream->writeTextElement("V_discipline", "Design");
00184 m_pOutStream->writeTextElement("V_usage", "3DShape");
00185 m_pOutStream->writeTextElement("V_nature", "1");
00186 m_pOutStream->writeEndElement();
00187
00188
00189 }
00190 void GLC_WorldTo3dxml::writeInstance3D(const GLC_StructInstance* pInstance, unsigned int parentId)
00191 {
00192 const GLC_StructReference* pRef= pInstance->structReference();
00193 const unsigned int referenceId= m_ReferenceToIdHash.value(pRef);
00194 const QString instanceMatrix(matrixString(pInstance->relativeMatrix()));
00195
00196 m_pOutStream->writeStartElement("Instance3D");
00197 m_pOutStream->writeAttribute("xsi:type", "Instance3DType");
00198 m_pOutStream->writeAttribute("id", QString::number(++m_CurrentId));
00199 m_pOutStream->writeAttribute("name", pInstance->name());
00200 m_pOutStream->writeTextElement("IsAggregatedBy", QString::number(parentId));
00201 m_pOutStream->writeTextElement("IsInstanceOf", QString::number(referenceId));
00202 m_pOutStream->writeTextElement("RelativeMatrix", instanceMatrix);
00203 if (pRef->containsAttributes())
00204 {
00205 m_pOutStream->writeStartElement("Instance3DExtensionType");
00206 writeExtensionAttributes(pRef->attributesHandle());
00207 m_pOutStream->writeEndElement();
00208 }
00209
00210 m_pOutStream->writeEndElement();
00211
00212 m_InstanceToIdHash.insert(pInstance, m_CurrentId);
00213 }
00214
00215 void GLC_WorldTo3dxml::writeInstanceRep(const GLC_3DRep* p3DRep, unsigned int parentId)
00216 {
00217 const unsigned int referenceId= m_ReferenceRepToIdHash.value(p3DRep);
00218 m_pOutStream->writeStartElement("InstanceRep");
00219 m_pOutStream->writeAttribute("xsi:type", "InstanceRepType");
00220 m_pOutStream->writeAttribute("id", QString::number(++m_CurrentId));
00221 m_pOutStream->writeAttribute("name", p3DRep->name());
00222 m_pOutStream->writeTextElement("IsAggregatedBy", QString::number(parentId));
00223 m_pOutStream->writeTextElement("IsInstanceOf", QString::number(referenceId));
00224 m_pOutStream->writeEndElement();
00225
00226 m_InstanceRep.insert(parentId);
00227
00228 }
00229 void GLC_WorldTo3dxml::setStreamWriterToFile(const QString& fileName)
00230 {
00231 delete m_pOutStream;
00232 m_pOutStream= NULL;
00233
00234 bool success= false;
00235 if (NULL != m_p3dxmlArchive)
00236 {
00237 if (NULL != m_pCurrentZipFile)
00238 {
00239 m_pCurrentZipFile->close();
00240 delete m_pOutStream;
00241 delete m_pCurrentZipFile;
00242 }
00243 QuaZipNewInfo quazipNewInfo(fileName);
00244 m_pCurrentZipFile= new QuaZipFile(m_p3dxmlArchive);
00245 success= m_pCurrentZipFile->open(QIODevice::WriteOnly, quazipNewInfo);
00246 if (success)
00247 {
00248 m_pOutStream= new QXmlStreamWriter(m_pCurrentZipFile);
00249 }
00250 }
00251 else
00252 {
00253 delete m_pCurrentFile;
00254 m_pCurrentFile= new QFile(m_AbsolutePath + fileName);
00255 success= m_pCurrentFile->open(QIODevice::WriteOnly);
00256 if (success)
00257 {
00258 m_pOutStream= new QXmlStreamWriter(m_pCurrentFile);
00259 }
00260 }
00261
00262 if (NULL == m_pOutStream)
00263 {
00264 QString message(QString("GLC_WorldTo3dxml::setStreamWriterToFile Unable to create ") + fileName);
00265 GLC_Exception fileException(message);
00266 throw(fileException);
00267 }
00268 else
00269 {
00270 m_pOutStream->setAutoFormatting(true);
00271 }
00272 }
00273
00274 void GLC_WorldTo3dxml::addManifest()
00275 {
00276 setStreamWriterToFile("Manifest.xml");
00277 m_pOutStream->writeStartDocument();
00278
00279 m_pOutStream->writeStartElement("Manifest");
00280 m_pOutStream->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
00281 m_pOutStream->writeAttribute("xsi:noNamespaceSchemaLocation", "Manifest.xsd");
00282 m_pOutStream->writeTextElement("Root", QFileInfo(m_FileName).fileName());
00283 m_pOutStream->writeEndElement();
00284 m_pOutStream->writeEndElement();
00285
00286 m_pOutStream->writeEndDocument();
00287 }
00288
00289 void GLC_WorldTo3dxml::exportAssemblyStructure()
00290 {
00291 m_ReferenceToIdHash.clear();
00292 m_InstanceToIdHash.clear();
00293 m_ReferenceRepToIdHash.clear();
00294 m_ReferenceRepTo3dxmlFileName.clear();
00295 m_InstanceRep.clear();
00296
00297
00298 setStreamWriterToFile(QFileInfo(m_FileName).fileName());
00299 m_pOutStream->writeStartDocument();
00300 m_pOutStream->writeStartElement("Model_3dxml");
00301 m_pOutStream->writeAttribute("xmlns", "http://www.3ds.com/xsd/3DXML");
00302 m_pOutStream->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
00303 m_pOutStream->writeAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
00304
00305 writeHeader();
00306
00307
00308 m_pOutStream->writeStartElement("ProductStructure");
00309 m_pOutStream->writeAttribute("root", "1");
00310 exportAssemblyFromOccurence(m_World.rootOccurence());
00311 m_pOutStream->writeEndElement();
00312
00313 if (!m_ListOfOverLoadedOccurence.isEmpty())
00314 {
00315 m_pOutStream->writeStartElement("DefaultView");
00316 const int size= m_ListOfOverLoadedOccurence.size();
00317 for (int i= 0; i < size; ++i)
00318 {
00319 writeOccurenceDefaultViewProperty(m_ListOfOverLoadedOccurence.at(i));
00320 }
00321 m_pOutStream->writeEndElement();
00322 }
00323
00324 m_pOutStream->writeEndElement();
00325
00326 m_pOutStream->writeEndDocument();
00327 }
00328
00329 void GLC_WorldTo3dxml::exportAssemblyFromOccurence(const GLC_StructOccurence* pOccurence)
00330 {
00331 if (pOccurence->isOrphan())
00332 {
00333 writeReference3D(pOccurence->structReference());
00334 }
00335 else
00336 {
00337
00338 GLC_StructReference* pCurrentRef= pOccurence->structReference();
00339 if (!m_ReferenceToIdHash.contains(pCurrentRef))
00340 {
00341 writeReference3D(pCurrentRef);
00342
00343 if (pCurrentRef->hasRepresentation())
00344 {
00345 GLC_3DRep* pCurrentRep= dynamic_cast<GLC_3DRep*>(pCurrentRef->representationHandle());
00346 if (NULL != pCurrentRep && !m_ReferenceRepToIdHash.contains(pCurrentRep))
00347 {
00348 writeReferenceRep(pCurrentRep);
00349 }
00350 }
00351 }
00352
00353 GLC_StructInstance* pCurrentInstance= pOccurence->structInstance();
00354 if (!m_InstanceToIdHash.contains(pCurrentInstance))
00355 {
00356
00357 const unsigned int parentId= m_ReferenceToIdHash.value(pOccurence->parent()->structReference());
00358 writeInstance3D(pCurrentInstance, parentId);
00359
00360
00361 if (pCurrentRef->hasRepresentation())
00362 {
00363 GLC_3DRep* pCurrentRep= dynamic_cast<GLC_3DRep*>(pCurrentRef->representationHandle());
00364 const unsigned int parentId= m_ReferenceToIdHash.value(pCurrentRef);
00365 if (NULL != pCurrentRep && !m_InstanceRep.contains(parentId))
00366 {
00367 writeInstanceRep(pCurrentRep, parentId);
00368 }
00369 }
00370 }
00371 }
00372
00373
00374 const int childCount= pOccurence->childCount();
00375 for (int i= 0; i < childCount; ++i)
00376 {
00377 exportAssemblyFromOccurence(pOccurence->child(i));
00378 }
00379
00380
00381 if (m_World.collection()->contains(pOccurence->id()))
00382 {
00383 GLC_3DViewInstance* pInstance= m_World.collection()->instanceHandle(pOccurence->id());
00384 Q_ASSERT(NULL != pInstance);
00385 const bool isVisible= pInstance->isVisible();
00386 const bool isOverload= !isVisible || !pInstance->renderPropertiesHandle()->isDefault();
00387 if (isOverload)
00388 {
00389 m_ListOfOverLoadedOccurence.append(pOccurence);
00390 }
00391 }
00392
00393 }
00394
00395 QString GLC_WorldTo3dxml::matrixString(const GLC_Matrix4x4& matrix)
00396 {
00397 QString resultMatrix;
00398 const QChar spaceChar(' ');
00399
00400 resultMatrix+= QString::number(matrix.data()[0]) + spaceChar;
00401 resultMatrix+= QString::number(matrix.data()[1]) + spaceChar;
00402 resultMatrix+= QString::number(matrix.data()[2]) + spaceChar;
00403
00404 resultMatrix+= QString::number(matrix.data()[4]) + spaceChar;
00405 resultMatrix+= QString::number(matrix.data()[5]) + spaceChar;
00406 resultMatrix+= QString::number(matrix.data()[6]) + spaceChar;
00407
00408 resultMatrix+= QString::number(matrix.data()[8]) + spaceChar;
00409 resultMatrix+= QString::number(matrix.data()[9]) + spaceChar;
00410 resultMatrix+= QString::number(matrix.data()[10]) + spaceChar;
00411
00412
00413 resultMatrix+= QString::number(matrix.data()[12]) + spaceChar;
00414 resultMatrix+= QString::number(matrix.data()[13]) + spaceChar;
00415 resultMatrix+= QString::number(matrix.data()[14]);
00416
00417 return resultMatrix;
00418 }
00419
00420 void GLC_WorldTo3dxml::write3DRep(const GLC_3DRep* pRep, const QString& fileName)
00421 {
00422 setStreamWriterToFile(fileName);
00423
00424 m_pOutStream->writeStartDocument();
00425 m_pOutStream->writeStartElement("XMLRepresentation");
00426 m_pOutStream->writeAttribute("version", "1.2");
00427 m_pOutStream->writeAttribute("xmlns", "http://www.3ds.com/xsd/3DXML");
00428 m_pOutStream->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
00429 m_pOutStream->writeAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
00430 m_pOutStream->writeAttribute("xsi:schemaLocation", "http://www.3ds.com/xsd/3DXML ./3DXMLMesh.xsd");
00431
00432 m_pOutStream->writeStartElement("Root");
00433 m_pOutStream->writeAttribute("xsi:type", "BagRepType");
00434 m_pOutStream->writeAttribute("id", QString::number(++m_CurrentId));
00435 const int bodyCount= pRep->numberOfBody();
00436 for (int i= 0; i < bodyCount; ++i)
00437 {
00438 GLC_Mesh* pMesh= dynamic_cast<GLC_Mesh*>(pRep->geomAt(i));
00439 if (NULL != pMesh)
00440 {
00441 writeGeometry(pMesh);
00442 }
00443 }
00444 m_pOutStream->writeEndElement();
00445
00446 m_pOutStream->writeEndElement();
00447
00448 m_pOutStream->writeEndDocument();
00449 }
00450
00451 QString GLC_WorldTo3dxml::representationFileName(const GLC_3DRep* pRep)
00452 {
00453 Q_ASSERT(m_ReferenceRepToIdHash.contains(pRep));
00454 QString repName= pRep->name();
00455 QString fileName;
00456 if (repName.isEmpty())
00457 {
00458 fileName= "urn:3DXML:Representation_0.3DRep";
00459 }
00460 else
00461 {
00462 fileName= "urn:3DXML:" + repName + ".3DRep";
00463 }
00464 return xmlFileName(fileName);
00465 }
00466
00467 void GLC_WorldTo3dxml::writeGeometry(const GLC_Mesh* pMesh)
00468 {
00469
00470 QList<GLC_uint> materialList= pMesh->materialIds();
00471 const int materialCount= materialList.size();
00472
00473 m_pOutStream->writeStartElement("Rep");
00474 m_pOutStream->writeAttribute("xsi:type", "PolygonalRepType");
00475 m_pOutStream->writeAttribute("id", QString::number(++m_CurrentId));
00476 const double masterAccuracy= pMesh->getLodAccuracy(0);
00477 m_pOutStream->writeAttribute("accuracy", QString::number(masterAccuracy));
00478 m_pOutStream->writeAttribute("solid", "1");
00479 const int lodCount= pMesh->lodCount();
00480 if (lodCount > 1)
00481 {
00482
00483 for (int i= 1; i < lodCount; ++i)
00484 {
00485 const double lodAccuracy= pMesh->getLodAccuracy(i);
00486 m_pOutStream->writeStartElement("PolygonalLOD");
00487 m_pOutStream->writeAttribute("accuracy", QString::number(lodAccuracy));
00488 m_pOutStream->writeStartElement("Faces");
00489 for (int matIndex= 0; matIndex < materialCount; ++matIndex)
00490 {
00491 const GLC_uint materialId= materialList.at(matIndex);
00492 if (pMesh->lodContainsMaterial(i, materialId))
00493 {
00494 writeGeometryFace(pMesh, i, materialId);
00495 }
00496 }
00497 m_pOutStream->writeEndElement();
00498 m_pOutStream->writeEndElement();
00499 }
00500 }
00501
00502
00503 m_pOutStream->writeStartElement("Faces");
00504 for (int matIndex= 0; matIndex < materialCount; ++matIndex)
00505 {
00506 const GLC_uint materialId= materialList.at(matIndex);
00507 if (pMesh->lodContainsMaterial(0, materialId))
00508 {
00509 writeGeometryFace(pMesh, 0, materialId);
00510 }
00511 }
00512 m_pOutStream->writeEndElement();
00513 if (!pMesh->wireDataIsEmpty())
00514 {
00515 writeEdges(pMesh);
00516 }
00517
00518
00519 m_pOutStream->writeStartElement("VertexBuffer");
00520 {
00521
00522 GLfloatVector positionVector= pMesh->positionVector();
00523 QString positions;
00524 const int size= positionVector.size();
00525 for (int i= 0; i < size; i+=3)
00526 {
00527 positions.append(QString::number(positionVector.at(i)));
00528 positions.append(' ');
00529 positions.append(QString::number(positionVector.at(i + 1)));
00530 positions.append(' ');
00531 positions.append(QString::number(positionVector.at(i + 2)));
00532 positions.append(", ");
00533 }
00534 positions.remove(positions.size() - 2, 2);
00535 m_pOutStream->writeTextElement("Positions", positions);
00536 }
00537 {
00538
00539 GLfloatVector normalVector= pMesh->normalVector();
00540 QString normals;
00541 const int size= normalVector.size();
00542 for (int i= 0; i < size; i+=3)
00543 {
00544 normals.append(QString::number(normalVector.at(i)));
00545 normals.append(' ');
00546 normals.append(QString::number(normalVector.at(i + 1)));
00547 normals.append(' ');
00548 normals.append(QString::number(normalVector.at(i + 2)));
00549 normals.append(", ");
00550 }
00551 normals.remove(normals.size() - 2, 2);
00552 m_pOutStream->writeTextElement("Normals", normals);
00553 }
00554 {
00555
00556 GLfloatVector texelVector= pMesh->texelVector();
00557 if (!texelVector.isEmpty())
00558 {
00559 QString texels;
00560 const int size= texelVector.size();
00561 for (int i= 0; i < size; i+=2)
00562 {
00563 texels.append(QString::number(texelVector.at(i)));
00564 texels.append(' ');
00565 texels.append(QString::number(texelVector.at(i + 1)));
00566 texels.append(", ");
00567 }
00568 texels.remove(texels.size() - 2, 2);
00569
00570 m_pOutStream->writeStartElement("TextureCoordinates");
00571 m_pOutStream->writeAttribute("dimension", "2D");
00572 m_pOutStream->writeAttribute("channel", "0");
00573 m_pOutStream->writeCharacters(texels);
00574 m_pOutStream->writeEndElement();
00575 }
00576 }
00577
00578
00579 m_pOutStream->writeEndElement();
00580 m_pOutStream->writeEndElement();
00581
00582 }
00583 void GLC_WorldTo3dxml::writeGeometryFace(const GLC_Mesh* pMesh, int lod, GLC_uint materialId)
00584 {
00585 m_pOutStream->writeStartElement("Face");
00586 if (pMesh->containsTriangles(lod, materialId))
00587 {
00588 QVector<GLuint> triangleIndex= pMesh->getTrianglesIndex(lod, materialId);
00589 QString indexString;
00590 const int indexSize= triangleIndex.size();
00591 for (int index= 0; index < indexSize; ++index)
00592 {
00593 indexString.append(QString::number(triangleIndex.at(index)));
00594 indexString.append(' ');
00595 }
00596 indexString.remove(indexString.size() - 1, 1);
00597 m_pOutStream->writeAttribute("triangles", indexString);
00598 }
00599 if (pMesh->containsStrips(lod, materialId))
00600 {
00601 QList<QVector<GLuint> > stripsIndex= pMesh->getStripsIndex(lod, materialId);
00602 QString indexStrips;
00603 const int stripCount= stripsIndex.size();
00604 for (int stripIndex= 0; stripIndex < stripCount; ++stripIndex)
00605 {
00606 QVector<GLuint> currentStripIndex= stripsIndex.at(stripIndex);
00607 QString currentIndex;
00608 const int indexSize= currentStripIndex.size();
00609 for (int index= 0; index < indexSize; ++index)
00610 {
00611 currentIndex.append(QString::number(currentStripIndex.at(index)));
00612 currentIndex.append(' ');
00613 }
00614 currentIndex.remove(currentIndex.size() - 1, 1);
00615 indexStrips.append(currentIndex);
00616 indexStrips.append(',');
00617 }
00618 indexStrips.remove(indexStrips.size() - 1, 1);
00619 m_pOutStream->writeAttribute("strips", indexStrips);
00620 }
00621 if (pMesh->containsFans(lod, materialId))
00622 {
00623 QList<QVector<GLuint> > fansIndex= pMesh->getFansIndex(lod, materialId);
00624 QString indexFans;
00625 const int fanCount= fansIndex.size();
00626 for (int fanIndex= 0; fanIndex < fanCount; ++fanIndex)
00627 {
00628 QVector<GLuint> currentFanIndex= fansIndex.at(fanIndex);
00629 QString currentIndex;
00630 const int indexSize= currentFanIndex.size();
00631 for (int index= 0; index < indexSize; ++index)
00632 {
00633 currentIndex.append(QString::number(currentFanIndex.at(index)));
00634 currentIndex.append(' ');
00635 }
00636 currentIndex.remove(currentIndex.size() - 1, 1);
00637 indexFans.append(currentIndex);
00638 indexFans.append(',');
00639 }
00640 indexFans.remove(indexFans.size() - 1, 1);
00641 m_pOutStream->writeAttribute("fans", indexFans);
00642 }
00643
00644 writeSurfaceAttributes(pMesh->material(materialId));
00645
00646 m_pOutStream->writeEndElement();
00647
00648 }
00649
00650 void GLC_WorldTo3dxml::writeSurfaceAttributes(const GLC_Material* pMaterial)
00651 {
00652 QColor diffuseColor= pMaterial->diffuseColor();
00653 m_pOutStream->writeStartElement("SurfaceAttributes");
00654 if (m_ExportMaterial)
00655 {
00656 const QString material3dxmlId=(QString::number(m_MaterialIdToMaterialId.value(pMaterial->id())));
00657 m_pOutStream->writeStartElement("MaterialApplication");
00658 m_pOutStream->writeAttribute("xsi:type", "MaterialApplicationType");
00659 m_pOutStream->writeAttribute("mappingChannel", "0");
00660 m_pOutStream->writeStartElement("MaterialId");
00661 m_pOutStream->writeAttribute("id", "urn:3DXML:CATMaterialRef.3dxml#" + material3dxmlId);
00662 m_pOutStream->writeEndElement();
00663 m_pOutStream->writeEndElement();
00664 }
00665 else
00666 {
00667 m_pOutStream->writeStartElement("Color");
00668 m_pOutStream->writeAttribute("xsi:type", "RGBAColorType");
00669 m_pOutStream->writeAttribute("red", QString::number(diffuseColor.redF()));
00670 m_pOutStream->writeAttribute("green", QString::number(diffuseColor.greenF()));
00671 m_pOutStream->writeAttribute("blue", QString::number(diffuseColor.blueF()));
00672 m_pOutStream->writeAttribute("alpha", QString::number(diffuseColor.alphaF()));
00673 m_pOutStream->writeEndElement();
00674 }
00675 m_pOutStream->writeEndElement();
00676 }
00677
00678 void GLC_WorldTo3dxml::writeEdges(const GLC_Mesh* pMesh)
00679 {
00680 m_pOutStream->writeStartElement("Edges");
00681 writeLineAttributes(pMesh->wireColor());
00682
00683 GLfloatVector positionVector= pMesh->wirePositionVector();
00684 const int polylineCount= pMesh->wirePolylineCount();
00685 for (int i= 0; i < polylineCount; ++i)
00686 {
00687 m_pOutStream->writeStartElement("Polyline");
00688 QString polylinePosition;
00689 const GLuint offset= pMesh->wirePolylineOffset(i);
00690 const GLsizei size= pMesh->wirePolylineSize(i);
00691 for (GLsizei index= 0; index < size; ++index)
00692 {
00693 const int startIndex= 3 * (offset + index);
00694 polylinePosition.append(QString::number(positionVector.at(startIndex)));
00695 polylinePosition.append(' ');
00696 polylinePosition.append(QString::number(positionVector.at(startIndex + 1)));
00697 polylinePosition.append(' ');
00698 polylinePosition.append(QString::number(positionVector.at(startIndex + 2)));
00699 polylinePosition.append(',');
00700 }
00701 polylinePosition.remove(polylinePosition.size() - 1, 1);
00702 m_pOutStream->writeAttribute("vertices", polylinePosition);
00703 m_pOutStream->writeEndElement();
00704 }
00705 m_pOutStream->writeEndElement();
00706 }
00707
00708 void GLC_WorldTo3dxml::writeLineAttributes(const QColor& color)
00709 {
00710 m_pOutStream->writeStartElement("LineAttributes");
00711 m_pOutStream->writeAttribute("lineType", "SOLID");
00712 m_pOutStream->writeAttribute("thickness", "1");
00713 m_pOutStream->writeStartElement("Color");
00714 m_pOutStream->writeAttribute("xsi:type", "RGBAColorType");
00715 m_pOutStream->writeAttribute("red", QString::number(color.redF()));
00716 m_pOutStream->writeAttribute("green", QString::number(color.greenF()));
00717 m_pOutStream->writeAttribute("blue", QString::number(color.blueF()));
00718 m_pOutStream->writeAttribute("alpha", QString::number(color.alphaF()));
00719 m_pOutStream->writeEndElement();
00720 m_pOutStream->writeEndElement();
00721 }
00722
00723 void GLC_WorldTo3dxml::writeMaterial(const GLC_Material* pMaterial)
00724 {
00725 const GLC_uint materialId= pMaterial->id();
00726 QString materialName;
00727 if (pMaterial->name().isEmpty())
00728 {
00729 materialName= "Material_0" + QString::number(materialId);
00730 }
00731 else
00732 {
00733 materialName= pMaterial->name();
00734 }
00735
00736
00737 m_MaterialIdToMaterialName.insert(materialId, materialName);
00738
00739 const QString fileName= xmlFileName(materialName + "_Rendering.3DRep");
00740 setStreamWriterToFile(fileName);
00741
00742
00743 m_pOutStream->writeStartDocument();
00744 m_pOutStream->writeStartElement("Osm");
00745 m_pOutStream->writeAttribute("xmlns", "http://www.3ds.com/xsd/osm.xsd");
00746 m_pOutStream->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
00747 m_pOutStream->writeAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
00748 m_pOutStream->writeAttribute("xsi:schemaLocation", "http://www.3ds.com/xsd/3DXML ./osm.xsd");
00749 m_pOutStream->writeStartElement("Feature");
00750 m_pOutStream->writeAttribute("Alias", "RenderingRootFeature");
00751 m_pOutStream->writeAttribute("Id", "1");
00752 m_pOutStream->writeAttribute("StartUp", "RenderingRootFeature");
00753 m_pOutStream->writeEndElement();
00754 m_pOutStream->writeStartElement("Feature");
00755 m_pOutStream->writeAttribute("Alias", "RenderingFeature");
00756 m_pOutStream->writeAttribute("Id", "2");
00757 m_pOutStream->writeAttribute("StartUp", "RenderingFeature");
00758 m_pOutStream->writeAttribute("Aggregating", "1");
00759
00760 writeMaterialAttributtes("Filtering", "int", "1");
00761 writeMaterialAttributtes("Rotation", "double", "0");
00762 writeMaterialAttributtes("PreviewType", "int", "1");
00763 writeMaterialAttributtes("AmbientCoef", "double", "1");
00764 writeMaterialAttributtes("DiffuseCoef", "double", "1");
00765 writeMaterialAttributtes("SpecularCoef", "double", "1");
00766 writeMaterialAttributtes("EmissiveCoef", "double", "0");
00767 writeMaterialAttributtes("AlphaTest", "boolean", "false");
00768 writeMaterialAttributtes("TextureFunction", "int", "0");
00769 writeMaterialAttributtes("MappingType", "int", "2");
00770 writeMaterialAttributtes("Refraction", "double", "1");
00771 writeMaterialAttributtes("TextureDimension", "int", "2");
00772 writeMaterialAttributtes("TranslationU", "double", "0");
00773 writeMaterialAttributtes("TranslationV", "double", "0");
00774 writeMaterialAttributtes("FlipU", "boolean", "false");
00775 writeMaterialAttributtes("FlipV", "boolean", "false");
00776 writeMaterialAttributtes("WrappingModeU", "int", "1");
00777 writeMaterialAttributtes("WrappingModeV", "int", "1");
00778 writeMaterialAttributtes("ScaleU", "double", "1");
00779 writeMaterialAttributtes("ScaleV", "double", "1");
00780 writeMaterialAttributtes("Reflectivity", "double", "0.1");
00781 writeMaterialAttributtes("BlendColor", "double", "[1,1,1]");
00782
00783 writeMaterialAttributtes("Transparency", "double", QString::number(1.0 - pMaterial->opacity()));
00784 double specularExponent= pMaterial->shininess() / 128.0;
00785 writeMaterialAttributtes("SpecularExponent", "double", QString::number(specularExponent));
00786 writeMaterialAttributtes("DiffuseColor", "double", colorToString(pMaterial->diffuseColor()));
00787 writeMaterialAttributtes("SpecularColor", "double", colorToString(pMaterial->specularColor()));
00788 writeMaterialAttributtes("AmbientColor", "double", colorToString(pMaterial->ambientColor()));
00789 writeMaterialAttributtes("EmissiveColor", "double", colorToString(pMaterial->emissiveColor()));
00790 if (pMaterial->hasTexture())
00791 {
00792 Q_ASSERT(m_MaterialIdTo3dxmlImageId.contains(pMaterial->id()));
00793 const QString imageId(QString::number(m_MaterialIdTo3dxmlImageId.value(pMaterial->id())));
00794
00795 writeMaterialAttributtes("TextureImage", "external", "urn:3DXML:CATRepImage.3dxml#" + imageId);
00796 }
00797 m_pOutStream->writeEndElement();
00798 m_pOutStream->writeEndElement();
00799 m_pOutStream->writeEndDocument();
00800 }
00801
00802 void GLC_WorldTo3dxml::writeMaterialAttributtes(const QString& name, const QString& type, const QString& value)
00803 {
00804 m_pOutStream->writeStartElement("Attr");
00805 m_pOutStream->writeAttribute("Name", name);
00806 m_pOutStream->writeAttribute("Type", type);
00807 m_pOutStream->writeAttribute("Value", value);
00808 m_pOutStream->writeEndElement();
00809 }
00810
00811 QString GLC_WorldTo3dxml::colorToString(const QColor& color)
00812 {
00813 return QString('[' + QString::number(color.redF()) + ',' + QString::number(color.greenF()) + ',' + QString::number(color.blueF()) + ']');
00814 }
00815
00816 void GLC_WorldTo3dxml::writeCatRepImageFile(const QList<GLC_Material*>& materialList)
00817 {
00818 unsigned int currentId= 0;
00819 const QString fileName("CATRepImage.3dxml");
00820 setStreamWriterToFile(fileName);
00821
00822
00823 m_pOutStream->writeStartDocument();
00824 m_pOutStream->writeStartElement("Model_3dxml");
00825 m_pOutStream->writeAttribute("xmlns", "http://www.3ds.com/xsd/3DXML");
00826 m_pOutStream->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
00827 m_pOutStream->writeAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
00828 m_pOutStream->writeAttribute("xsi:schemaLocation", "http://www.3ds.com/xsd/3DXML ./3DXML.xsd");
00829 writeHeader();
00830 m_pOutStream->writeStartElement("CATRepImage");
00831 m_pOutStream->writeAttribute("root", QString::number(currentId));
00832 const int size= materialList.size();
00833 for (int i= 0; i < size; ++i)
00834 {
00835 writeCATRepresentationImage(materialList.at(i), ++currentId);
00836 }
00837 m_pOutStream->writeEndElement();
00838 m_pOutStream->writeEndElement();
00839 m_pOutStream->writeEndDocument();
00840 }
00841
00842 void GLC_WorldTo3dxml::writeCATRepresentationImage(const GLC_Material* pMat, unsigned int id)
00843 {
00844 Q_ASSERT(pMat->hasTexture());
00845 m_MaterialIdTo3dxmlImageId.insert(pMat->id(), id);
00846
00847 const QString imageName= pMat->name();
00848 QString imageFileName;
00849 QString imageFormat;
00850 const QString textureFileName= pMat->textureHandle()->fileName();
00851 if (textureFileName.isEmpty())
00852 {
00853 imageFormat= "jpg";
00854 if (imageName.isEmpty())
00855 {
00856 imageFileName= xmlFileName("textureImage." + imageFormat);
00857 }
00858 else
00859 {
00860 imageFileName= xmlFileName(imageName + '.' + imageFormat);
00861 }
00862 }
00863 else
00864 {
00865 imageFormat= QFileInfo(textureFileName).suffix();
00866 imageFileName= xmlFileName(QFileInfo(textureFileName).fileName());
00867 }
00868 m_MaterialIdToTexture3dxmlName.insert(pMat->id(), imageFileName);
00869
00870 m_pOutStream->writeStartElement("CATRepresentationImage");
00871 m_pOutStream->writeAttribute("xsi:type", "CATRepresentationImageType");
00872 m_pOutStream->writeAttribute("id", QString::number(id));
00873 m_pOutStream->writeAttribute("name", imageName);
00874 m_pOutStream->writeAttribute("format", imageFormat);
00875 m_pOutStream->writeAttribute("associatedFile", QString("urn:3DXML:" + imageFileName));
00876
00877 m_pOutStream->writeTextElement("PLM_ExternalID", imageName);
00878 m_pOutStream->writeTextElement("V_PrimaryMimeType", imageFormat);
00879 m_pOutStream->writeTextElement("V_PrimaryFileName", imageFileName);
00880 m_pOutStream->writeEndElement();
00881 }
00882
00883 void GLC_WorldTo3dxml::writeAllMaterialRelatedFilesIn3dxml()
00884 {
00885 m_MaterialIdToMaterialName.clear();
00886 m_MaterialIdToMaterialId.clear();
00887 m_MaterialIdToTexture3dxmlName.clear();
00888 m_MaterialIdTo3dxmlImageId.clear();
00889
00890
00891 QList<GLC_Material*> materialList= m_World.listOfMaterials();
00892
00893
00894 QList<GLC_Material*> texturedMaterial;
00895 const int size= materialList.size();
00896 for (int i= 0; i < size; ++i)
00897 {
00898 if (materialList.at(i)->hasTexture())
00899 {
00900 texturedMaterial.append(materialList.at(i));
00901 }
00902 }
00903
00904 if (!texturedMaterial.isEmpty())
00905 {
00906 writeCatRepImageFile(texturedMaterial);
00907 writeImageFileIn3dxml(texturedMaterial);
00908 }
00909
00910
00911
00912 for (int i= 0; i < size; ++i)
00913 {
00914 writeMaterial(materialList.at(i));
00915 }
00916
00917 writeCatMaterialRef(materialList);
00918
00919
00920
00921 }
00922 void GLC_WorldTo3dxml::writeImageFileIn3dxml(const QList<GLC_Material*>& materialList)
00923 {
00924 const int size= materialList.size();
00925 Q_ASSERT(size == m_MaterialIdToTexture3dxmlName.size());
00926 for (int i= 0; i < size; ++i)
00927 {
00928 const GLC_Material* pCurrentMaterial= materialList.at(i);
00929 const GLC_Texture* pTexture= pCurrentMaterial->textureHandle();
00930 const QString imageName(m_MaterialIdToTexture3dxmlName.value(pCurrentMaterial->id()));
00931
00932 if (!pTexture->fileName().isEmpty())
00933 {
00934
00935 QImage textureImage(pTexture->fileName());
00936 if (! textureImage.isNull())
00937 {
00938 addImageTextureTo3dxml(textureImage, imageName);
00939 }
00940 else
00941 {
00942 addImageTextureTo3dxml(pTexture->imageOfTexture(), imageName);
00943 }
00944 }
00945 else
00946 {
00947 addImageTextureTo3dxml(pTexture->imageOfTexture(), imageName);
00948 }
00949 }
00950
00951 }
00952
00953 void GLC_WorldTo3dxml::writeCatMaterialRef(const QList<GLC_Material*>& materialList)
00954 {
00955 const QString fileName("CATMaterialRef.3dxml");
00956
00957 setStreamWriterToFile(fileName);
00958
00959 unsigned int currentId= 0;
00960
00961
00962 m_pOutStream->writeStartDocument();
00963 m_pOutStream->writeStartElement("Model_3dxml");
00964 m_pOutStream->writeAttribute("xmlns", "http://www.3ds.com/xsd/3DXML");
00965 m_pOutStream->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
00966 m_pOutStream->writeAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
00967 m_pOutStream->writeAttribute("xsi:schemaLocation", "http://www.3ds.com/xsd/3DXML ./3DXML.xsd");
00968 writeHeader();
00969 m_pOutStream->writeStartElement("CATMaterialRef");
00970 m_pOutStream->writeAttribute("root", QString::number(currentId));
00971 const int size= materialList.size();
00972 for (int i= 0; i < size; ++i)
00973 {
00974 writeMaterialToCatMaterialRef(materialList.at(i), &(++currentId));
00975 }
00976 m_pOutStream->writeEndElement();
00977 m_pOutStream->writeEndElement();
00978 m_pOutStream->writeEndDocument();
00979 }
00980
00981 void GLC_WorldTo3dxml::writeMaterialToCatMaterialRef(const GLC_Material* pMat, unsigned int* id)
00982 {
00983 const QString materialName= m_MaterialIdToMaterialName.value(pMat->id());
00984 m_MaterialIdToMaterialId.insert(pMat->id(), *id);
00985
00986 m_pOutStream->writeStartElement("CATMatReference");
00987 m_pOutStream->writeAttribute("xsi:type", "CATMatReferenceType");
00988 m_pOutStream->writeAttribute("id", QString::number(*id));
00989 m_pOutStream->writeAttribute("name", materialName);
00990 m_pOutStream->writeTextElement("PLM_ExternalID", materialName);
00991 m_pOutStream->writeEndElement();
00992
00993 const QString domainName= materialName + "_Rendering";
00994 m_pOutStream->writeStartElement("MaterialDomain");
00995 m_pOutStream->writeAttribute("xsi:type", "MaterialDomainType");
00996 m_pOutStream->writeAttribute("id", QString::number(++(*id)));
00997 m_pOutStream->writeAttribute("name", domainName);
00998 m_pOutStream->writeAttribute("format", "TECHREP");
00999 const QString associatedFileName("urn:3DXML:" + domainName + ".3DRep");
01000 m_pOutStream->writeAttribute("associatedFile", associatedFileName);
01001 m_pOutStream->writeAttribute("version", "1.0");
01002 m_pOutStream->writeTextElement("PLM_ExternalID", domainName);
01003 if (pMat->hasTexture())
01004 {
01005 m_pOutStream->writeStartElement("PLMRelation");
01006 m_pOutStream->writeTextElement("C_Semantics", "Reference");
01007 m_pOutStream->writeTextElement("C_Role", "CATMaterialReferenceToTextureLink");
01008 m_pOutStream->writeStartElement("Ids");
01009 const QString imageId(QString::number(m_MaterialIdTo3dxmlImageId.value(pMat->id())));
01010 m_pOutStream->writeTextElement("id", "urn:3DXML:CATRepImage.3dxml#" + imageId);
01011 m_pOutStream->writeEndElement();
01012 m_pOutStream->writeEndElement();
01013 }
01014 m_pOutStream->writeTextElement("V_MatDomain", "Rendering");
01015 m_pOutStream->writeEndElement();
01016
01017 m_pOutStream->writeStartElement("MaterialDomainInstance");
01018 m_pOutStream->writeAttribute("xsi:type", "MaterialDomainInstanceType");
01019 m_pOutStream->writeAttribute("id", QString::number(++(*id)));
01020 m_pOutStream->writeAttribute("name", materialName + ".1");
01021 m_pOutStream->writeTextElement("PLM_ExternalID", materialName + ".1");
01022 m_pOutStream->writeTextElement("IsAggregatedBy", QString::number((*id) - 2));
01023 m_pOutStream->writeTextElement("IsInstanceOf", QString::number((*id) - 1));
01024 m_pOutStream->writeEndElement();
01025 }
01026
01027 void GLC_WorldTo3dxml::addImageTextureTo3dxml(const QImage& image, const QString& fileName)
01028 {
01029 delete m_pOutStream;
01030 m_pOutStream= NULL;
01031
01032 bool success= false;
01033 if (NULL != m_p3dxmlArchive)
01034 {
01035 if (NULL != m_pCurrentZipFile)
01036 {
01037 m_pCurrentZipFile->close();
01038 delete m_pOutStream;
01039 delete m_pCurrentZipFile;
01040 }
01041 QuaZipNewInfo quazipNewInfo(fileName);
01042 m_pCurrentZipFile= new QuaZipFile(m_p3dxmlArchive);
01043 success= m_pCurrentZipFile->open(QIODevice::WriteOnly, quazipNewInfo);
01044 if (success)
01045 {
01046 image.save(m_pCurrentZipFile, QFileInfo(fileName).suffix().toAscii().constData());
01047 m_pCurrentZipFile->close();
01048 delete m_pCurrentZipFile;
01049 m_pCurrentZipFile= NULL;
01050 }
01051 }
01052 else
01053 {
01054 delete m_pCurrentFile;
01055 m_pCurrentFile= new QFile(m_AbsolutePath + fileName);
01056 success= m_pCurrentFile->open(QIODevice::WriteOnly);
01057 if (success)
01058 {
01059 image.save(m_pCurrentFile, QFileInfo(fileName).suffix().toAscii().constData());
01060 delete m_pCurrentFile;
01061 m_pCurrentFile= NULL;
01062 }
01063 }
01064 }
01065
01066 QString GLC_WorldTo3dxml::xmlFileName(const QString& fileName)
01067 {
01068 QString newName;
01069 if (!m_3dxmlFileSet.contains(fileName))
01070 {
01071 m_3dxmlFileSet << fileName;
01072 newName= fileName;
01073 }
01074 else
01075 {
01076 newName= QFileInfo(fileName).completeBaseName() + QString::number(++m_FileNameIncrement) + '.' + QFileInfo(fileName).suffix();
01077 }
01078 return newName;
01079 }
01080
01081 void GLC_WorldTo3dxml::writeExtensionAttributes(GLC_Attributes* pAttributes)
01082 {
01083 QList<QString> attributesNames= pAttributes->names();
01084 const int size= attributesNames.size();
01085 for (int i= 0; i < size; ++i)
01086 {
01087 const QString name= attributesNames.at(i);
01088 const QString value= pAttributes->value(name);
01089 m_pOutStream->writeStartElement("Attribute");
01090 m_pOutStream->writeAttribute("name", name);
01091 m_pOutStream->writeAttribute("value", value);
01092 m_pOutStream->writeEndElement();
01093 }
01094 }
01095
01096 void GLC_WorldTo3dxml::writeOccurenceDefaultViewProperty(const GLC_StructOccurence* pOccurence)
01097 {
01098 GLC_3DViewInstance* pInstance= m_World.collection()->instanceHandle(pOccurence->id());
01099 Q_ASSERT(NULL != pInstance);
01100 const bool isVisible= pOccurence->isVisible();
01101 const unsigned int occurrenceId= pOccurence->occurenceNumber();
01102 m_pOutStream->writeStartElement("DefaultViewProperty");
01103 m_pOutStream->writeTextElement("OccurenceId", QString::number(occurrenceId));
01104 m_pOutStream->writeStartElement("GraphicProperties");
01105 m_pOutStream->writeAttribute("xsi:type", "GraphicPropertiesType");
01106 if (! isVisible)
01107 {
01108 m_pOutStream->writeStartElement("GeneralAttributes");
01109 m_pOutStream->writeAttribute("xsi:type", "GeneralAttributesType");
01110 m_pOutStream->writeAttribute("visible", "false");
01111 m_pOutStream->writeAttribute("selectable", "true");
01112 m_pOutStream->writeEndElement();
01113 }
01114 if (!pInstance->renderPropertiesHandle()->isDefault())
01115 {
01116 const GLC_RenderProperties* pProperties= pInstance->renderPropertiesHandle();
01117 if (pProperties->overwriteTransparency() != -1.0f)
01118 {
01119 m_pOutStream->writeStartElement("SurfaceAttributes");
01120 m_pOutStream->writeAttribute("xsi:type", "SurfaceAttributesType");
01121 m_pOutStream->writeStartElement("Color");
01122 m_pOutStream->writeAttribute("xsi:type", "RGBAColorType");
01123 m_pOutStream->writeAttribute("red", "-1");
01124 m_pOutStream->writeAttribute("green", "-1");
01125 m_pOutStream->writeAttribute("blue", "-1");
01126 m_pOutStream->writeAttribute("alpha", QString::number(pProperties->overwriteTransparency()));
01127 m_pOutStream->writeEndElement();
01128 m_pOutStream->writeEndElement();
01129 }
01130 }
01131 m_pOutStream->writeEndElement();
01132 m_pOutStream->writeEndElement();
01133 }
01134
01135 bool GLC_WorldTo3dxml::continu()
01136 {
01137 bool continuValue= true;
01138 if (NULL != m_pReadWriteLock)
01139 {
01140 Q_ASSERT(NULL != m_pIsInterupted);
01141 m_pReadWriteLock->lockForRead();
01142 continuValue= !(*m_pIsInterupted);
01143 m_pReadWriteLock->unlock();
01144 }
01145 return continuValue;
01146 }