Select Git revision
Object.cpp
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Object.cpp 17.45 KiB
#include "Object.h"
#include <iostream>
#define PI (4.0*atan(1.0))
/////////////////////////////////////////////////////////////////////////
// public constructor/destructor
Object::Object(const char* path)
{
// open file
fsMesh.open(path, std::ios::in | std::ios::binary);
if (!fsMesh.is_open())
throw std::invalid_argument(std::string("file not found: ") += path);
// jump to file size information
fsMesh.seekg(4);
std::uint32_t tempFileSize;
std::list<ChunkHeader*> tempMainChunks;
// get all chunks under HEDR
fsMesh.read(reinterpret_cast<char*>(&tempFileSize), sizeof(tempFileSize));
loadChunks(tempMainChunks, fsMesh.tellg(), tempFileSize);
// evaluate HEDR subchunks (= find MSH2)
for (std::list<ChunkHeader*>::iterator it = tempMainChunks.begin(); it != tempMainChunks.end(); it++)
{
if (!strcmp("MSH2", (*it)->name))
{
// get all subchunks
std::list<ChunkHeader*> tempMsh2Chunks;
loadChunks(tempMsh2Chunks, (*it)->position, (*it)->size);
// evaluate MSH2 subchunks
analyseMsh2Chunks(tempMsh2Chunks);
// clean up
while (!tempMsh2Chunks.empty())
{
ChunkHeader* tempCursor = tempMsh2Chunks.front();
tempMsh2Chunks.pop_front();
delete tempCursor;
}
continue;
}
}
// clean up
while (!tempMainChunks.empty())
{
ChunkHeader* tempCursor = tempMainChunks.front();
tempMainChunks.pop_front();
delete tempCursor;
}
// close file
fsMesh.close();
}
Object::~Object()
{
//delete Chunk list;
}
/////////////////////////////////////////////////////////////////////////
// private functions