示例#1
0
文件: bsrep.cpp 项目: binhpt/vltest
// Return true if the binary rep is up to date
bool BSRep::isUsable(const QDateTime& timeStamp)
{
    bool isUpToDate= false;
    if (open(QIODevice::ReadOnly))
    {
        if (headerIsOk())
        {
            isUpToDate= timeStampOk(timeStamp);
            isUpToDate= isUpToDate && close();
        }
    }
    else
    {
        std::string message(std::string("BSRep::loadRep Enable to open the file ") + m_FileInfo.fileName());
        FileFormatException fileFormatException(message, m_FileInfo.fileName(), FileFormatException::FileNotFound);
        close();
        throw(fileFormatException);
    }

    if (!isUpToDate && TraceLog::isEnable())
    {
        std::stringList stringList("BSRep::isUsable");
        stringList.append("File " + m_FileInfo.filePath() + " not Usable");
        TraceLog::addTrace(stringList);
    }
    return isUpToDate;
}
//////////////////////////////////////////////////////////////////////
// name Get Functions
//////////////////////////////////////////////////////////////////////
// Load the binary rep
GLC_3DRep GLC_BSRep::loadRep()
{
	GLC_3DRep loadedRep;

	if (open(QIODevice::ReadOnly))
	{
		if (headerIsOk())
		{
			timeStampOk(QDateTime());
			GLC_BoundingBox boundingBox;
			m_DataStream >> boundingBox;
			bool useCompression;
			m_DataStream >> useCompression;
			if (useCompression)
			{
				QByteArray CompresseBuffer;
				m_DataStream >> CompresseBuffer;
				QByteArray uncompressedBuffer= qUncompress(CompresseBuffer);
				uncompressedBuffer.squeeze();
				CompresseBuffer.clear();
				CompresseBuffer.squeeze();
				QDataStream bufferStream(uncompressedBuffer);
				bufferStream >> loadedRep;
			}
			else
			{
				m_DataStream >> loadedRep;
			}
			loadedRep.setFileName(m_FileInfo.filePath());

			if (!close())
			{
				QString message(QString("GLC_BSRep::loadRep An error occur when loading file ") + m_FileInfo.fileName());
				GLC_FileFormatException fileFormatException(message, m_FileInfo.fileName(), GLC_FileFormatException::WrongFileFormat);
				throw(fileFormatException);
			}
		}
		else
		{