Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

dsodb.h

Go to the documentation of this file.
00001 //
00002 // C++ Interface: dsodb
00003 //
00004 // Description:
00005 //
00006 //
00007 // Author: Toti <root@totibox>, (C) 2005
00008 //
00009 // Copyright: See COPYING file that comes with this distribution
00010 //
00011 //
00012 
00013 #ifndef _DSODB_H_
00014 #define _DSODB_H_
00015 
00016 #include <iostream>
00017 #include <vector>
00018 #include <celengine/dsoname.h>
00019 #include <celengine/deepskyobj.h>
00020 #include <celengine/dsooctree.h>
00021 #include <celengine/parser.h>
00022 
00023 
00024 static const unsigned int MAX_DSO_NAMES = 10;
00025 
00026 //NOTE: this one and starDatabase should be derived from a common base class since they share lots of code and functionality.
00027 class DSODatabase
00028 {
00029  public:
00030     DSODatabase();
00031     ~DSODatabase();
00032 
00033 
00034     inline DeepSkyObject* getDSO(const uint32) const;
00035     inline uint32         size() const;
00036 
00037     DeepSkyObject* find(const uint32 catalogNumber) const;
00038     DeepSkyObject* find(const std::string&) const;
00039 
00040     std::vector<std::string> getCompletion(const std::string&) const;
00041 
00042     void findVisibleDSOs(DSOHandler&    dsoHandler,
00043                          const Point3d& obsPosition,
00044                          const Quatf&   obsOrientation,
00045                          float fovY,
00046                          float aspectRatio,
00047                          float limitingMag) const;
00048 
00049     void findCloseDSOs(DSOHandler&    dsoHandler,
00050                        const Point3d& obsPosition,
00051                        float radius) const;
00052 
00053     std::string getDSOName    (const DeepSkyObject* const &) const;
00054     std::string getDSONameList(const DeepSkyObject* const &, const unsigned int maxNames = MAX_DSO_NAMES) const;
00055 
00056     DSONameDatabase* getNameDatabase() const;
00057     void setNameDatabase(DSONameDatabase*);
00058 
00059     bool load(std::istream&, const std::string& resourcePath);
00060     bool loadBinary(std::istream&);
00061     void finish();
00062 
00063     static DSODatabase* read(std::istream&);
00064 
00065     static const char* FILE_HEADER;
00066 
00067     double getAverageAbsoluteMagnitude() const;
00068 
00069 private:
00070     void buildIndexes();
00071     void buildOctree();
00072     void calcAvgAbsMag();
00073 
00074     int              nDSOs;
00075     int              capacity;
00076     DeepSkyObject**  DSOs;
00077     DSONameDatabase* namesDB;
00078     DeepSkyObject**  catalogNumberIndex;
00079     DSOOctree*       octreeRoot;
00080     uint32           nextAutoCatalogNumber;
00081     
00082     double           avgAbsMag;
00083 };
00084 
00085 
00086 DeepSkyObject* DSODatabase::getDSO(const uint32 n) const
00087 {
00088     return *(DSOs + n);
00089 }
00090 
00091 
00092 uint32 DSODatabase::size() const
00093 {
00094     return nDSOs;
00095 }
00096 
00097 #endif // _DSODB_H_

Generated on Sat Jan 14 22:30:27 2006 for Celestia by  doxygen 1.4.1