🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
SolarSystem.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "AstCore/CelestialBody.hpp"
25#include "AstCore/Object.hpp"
26#include "AstUtil/ObjectNamed.hpp"
27#include <unordered_map>
28#include <vector>
29
30AST_NAMESPACE_BEGIN
31
32
45class CelestialBody;
46class SolarSystem;
47
48
49
53class AST_CORE_API SolarSystem: public ObjectNamed
54{
55public:
56 AST_OBJECT(SolarSystem)
57
58 SolarSystem() = default;
60 : ObjectNamed(name) {}
61 ~SolarSystem() = default;
62
64 void initPredefined();
65
70 errc_t load(StringView dirpath);
71
76 errc_t loadPCK(StringView filepath);
77
79 errc_t loadDefault();
80
82 static std::string defaultSolarSystemDir();
83
85 const std::string& getDirpath() const { return dirpath_; }
86
88 CelestialBody* getSolarSystemBarycenter() const { return solarSystemBarycenter_.get(); }
89
91 CelestialBody* getEarthMoonBarycenter() const { return earthMoonBarycenter_.get(); }
92
94 CelestialBody* getMercury() const { return mercury_.get(); }
95
97 CelestialBody* getVenus() const { return venus_.get(); }
98
100 CelestialBody* getEarth() const { return earth_.get(); }
101
103 CelestialBody* getMars() const { return mars_.get(); }
104
106 CelestialBody* getJupiter() const { return jupiter_.get(); }
107
109 CelestialBody* getSaturn() const { return saturn_.get(); }
110
112 CelestialBody* getUranus() const { return uranus_.get(); }
113
115 CelestialBody* getNeptune() const { return neptune_.get(); }
116
118 CelestialBody* getPluto() const { return pluto_.get(); }
119
121 CelestialBody* getMoon() const { return moon_.get(); }
122
124 CelestialBody* getSun() const { return sun_.get(); }
125
129 CelestialBody* getBody(StringView name) const;
130
131
135 CelestialBody* getBodyByJplIndex(int index) const;
136
140 CelestialBody* getBodyBySpiceId(int id) const;
141
145 CelestialBody* addBody(StringView name);
146
150 CelestialBody* addBody(HCelestialBody body);
151
155 CelestialBody* getOrAddBody(StringView name);
156
157protected:
158 using BodyNameMap = std::unordered_map<std::string, CelestialBody*>;
159 using BodyIndexMap = std::unordered_map<int, CelestialBody*>;
160 using BodyVector = std::vector<SharedPtr<CelestialBody>>;
161
162
163 SharedPtr<CelestialBody> solarSystemBarycenter_{};
164 SharedPtr<CelestialBody> earthMoonBarycenter_{};
165
177
178 BodyVector bodies_{};
179 mutable BodyNameMap nameMap_{};
180 mutable BodyIndexMap jplIndexMap_{};
181 mutable BodyIndexMap spiceIdMap_{};
182 bool isInit_{false};
183 std::string dirpath_{};
184};
185
186
187
190AST_NAMESPACE_END
191
192AST_DECL_TYPE_ALIAS(SolarSystem)
天体
定义 CelestialBody.hpp:72
命名对象
定义 ObjectNamed.hpp:36
ObjectNamed()=default
默认构造函数
太阳系
定义 SolarSystem.hpp:54
CelestialBody * getEarthMoonBarycenter() const
获取地月质心
定义 SolarSystem.hpp:91
CelestialBody * getMars() const
获取火星
定义 SolarSystem.hpp:103
CelestialBody * getJupiter() const
获取木星
定义 SolarSystem.hpp:106
CelestialBody * getSaturn() const
获取土星
定义 SolarSystem.hpp:109
CelestialBody * getNeptune() const
获取海王星
定义 SolarSystem.hpp:115
CelestialBody * getMoon() const
获取月球
定义 SolarSystem.hpp:121
CelestialBody * getSolarSystemBarycenter() const
获取太阳系质心
定义 SolarSystem.hpp:88
CelestialBody * getVenus() const
获取金星
定义 SolarSystem.hpp:97
CelestialBody * getPluto() const
获取冥王星
定义 SolarSystem.hpp:118
CelestialBody * getMercury() const
获取水星
定义 SolarSystem.hpp:94
const std::string & getDirpath() const
获取太阳系数据目录路径
定义 SolarSystem.hpp:85
CelestialBody * getEarth() const
获取地球
定义 SolarSystem.hpp:100
CelestialBody * getUranus() const
获取天王星
定义 SolarSystem.hpp:112
CelestialBody * getSun() const
获取火星
定义 SolarSystem.hpp:124