00001 // trajmanager.cpp 00002 // 00003 // Copyright (C) 2001 Chris Laurel <claurel@shatters.net> 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 00010 #include <iostream> 00011 #include <fstream> 00012 00013 #include "celestia.h" 00014 #include <celutil/debug.h> 00015 #include "samporbit.h" 00016 #include "trajmanager.h" 00017 00018 using namespace std; 00019 00020 00021 static TrajectoryManager* trajectoryManager = NULL; 00022 00023 00024 TrajectoryManager* GetTrajectoryManager() 00025 { 00026 if (trajectoryManager == NULL) 00027 trajectoryManager = new TrajectoryManager("data"); 00028 return trajectoryManager; 00029 } 00030 00031 00032 string TrajectoryInfo::resolve(const string& baseDir) 00033 { 00034 if (!path.empty()) 00035 { 00036 string filename = path + "/data/" + source; 00037 // cout << "Resolve: testing [" << filename << "]\n"; 00038 ifstream in(filename.c_str()); 00039 if (in.good()) 00040 return filename; 00041 } 00042 00043 return baseDir + "/" + source; 00044 } 00045 00046 Orbit* TrajectoryInfo::load(const string& filename) 00047 { 00048 DPRINTF(1, "Loading trajectory: %s\n", filename.c_str()); 00049 // cout << "Loading trajectory: " << filename << '\n'; 00050 00051 return LoadSampledOrbit(filename); 00052 }
1.4.1