Skip to content
Snippets Groups Projects
Select Git revision
  • ea07ead94feb66fb5544f0530f7f775793e62868
  • master default protected
  • developement_1 protected
  • Version_1.2.4
  • Version_1.2.3
  • Version_1.2.2
  • Version_1.2.1
  • Version_1.2.0
  • Version_1.0.1
  • Version_1.0.0
  • Version_0.1.0
  • Version_0.0.6
  • Version_0.0.5
  • Version_0.0.4
  • Version_0.0.3
  • Version_0.0.2
  • Version_0.0.1
17 results

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