| 1401 | #endif |
| 1402 | |
| 1403 | void System::SaveAtlas(int type){ |
| 1404 | if(!mStrSaveAtlasToFile.empty()) |
| 1405 | { |
| 1406 | //clock_t start = clock(); |
| 1407 | |
| 1408 | // Save the current session |
| 1409 | mpAtlas->PreSave(); |
| 1410 | |
| 1411 | string pathSaveFileName = "./"; |
| 1412 | pathSaveFileName = pathSaveFileName.append(mStrSaveAtlasToFile); |
| 1413 | pathSaveFileName = pathSaveFileName.append(".osa"); |
| 1414 | |
| 1415 | string strVocabularyChecksum = CalculateCheckSum(mStrVocabularyFilePath,TEXT_FILE); |
| 1416 | std::size_t found = mStrVocabularyFilePath.find_last_of("/\\"); |
| 1417 | string strVocabularyName = mStrVocabularyFilePath.substr(found+1); |
| 1418 | |
| 1419 | if(type == TEXT_FILE) // File text |
| 1420 | { |
| 1421 | cout << "Starting to write the save text file " << endl; |
| 1422 | std::remove(pathSaveFileName.c_str()); |
| 1423 | std::ofstream ofs(pathSaveFileName, std::ios::binary); |
| 1424 | boost::archive::text_oarchive oa(ofs); |
| 1425 | |
| 1426 | oa << strVocabularyName; |
| 1427 | oa << strVocabularyChecksum; |
| 1428 | oa << mpAtlas; |
| 1429 | cout << "End to write the save text file" << endl; |
| 1430 | } |
| 1431 | else if(type == BINARY_FILE) // File binary |
| 1432 | { |
| 1433 | cout << "Starting to write the save binary file" << endl; |
| 1434 | std::remove(pathSaveFileName.c_str()); |
| 1435 | std::ofstream ofs(pathSaveFileName, std::ios::binary); |
| 1436 | boost::archive::binary_oarchive oa(ofs); |
| 1437 | oa << strVocabularyName; |
| 1438 | oa << strVocabularyChecksum; |
| 1439 | oa << mpAtlas; |
| 1440 | cout << "End to write save binary file" << endl; |
| 1441 | } |
| 1442 | } |
| 1443 | } |
| 1444 | |
| 1445 | bool System::LoadAtlas(int type) |
| 1446 | { |