[80a6a52] | 1 | #ifndef __GEOWORLD_CONFIGURATION_INTERFACES_H__
|
---|
| 2 | #define __GEOWORLD_CONFIGURATION_INTERFACES_H__
|
---|
| 3 |
|
---|
| 4 | #include <mars_util.h>
|
---|
| 5 | #include <string>
|
---|
| 6 |
|
---|
| 7 | #include "linalgadapt.h"
|
---|
| 8 | #include "gwtypes.h"
|
---|
| 9 | #include "mindbtypes.h"
|
---|
| 10 |
|
---|
| 11 | namespace geoworld
|
---|
| 12 | {
|
---|
| 13 | struct SynthesisSessionConfig
|
---|
| 14 | {
|
---|
| 15 | struct
|
---|
| 16 | {
|
---|
| 17 | unsigned short count;
|
---|
| 18 | mars::RangeX< unsigned short > morphcount;
|
---|
| 19 | } passes;
|
---|
| 20 | struct
|
---|
| 21 | {
|
---|
| 22 | unsigned short layercount;
|
---|
| 23 | mars::RangeX< unsigned short > classcount;
|
---|
| 24 | } geohost;
|
---|
| 25 | struct
|
---|
| 26 | {
|
---|
| 27 | unsigned short morphcount;
|
---|
| 28 | unsigned short lod;
|
---|
| 29 | float coarseness;
|
---|
| 30 | } macro;
|
---|
| 31 | unsigned short tiledim;
|
---|
| 32 | };
|
---|
| 33 |
|
---|
| 34 | class ISynthesisSessionConfigReader
|
---|
| 35 | {
|
---|
| 36 | public:
|
---|
| 37 | virtual bool load (SynthesisSessionConfig & cfg) = 0;
|
---|
| 38 | };
|
---|
| 39 |
|
---|
| 40 | struct DepositSynthesizerSettings
|
---|
| 41 | {
|
---|
| 42 | struct
|
---|
| 43 | {
|
---|
| 44 | size_t count; // Number of layers in the strata
|
---|
| 45 | mars::RangeX< size_t > classes; // Range of how many different mineral classes to synthesize in the world
|
---|
| 46 | mars::Range< unsigned char > silica; // Range of how much silica mineral classifications should have
|
---|
| 47 | float coarseness; // Midpoint displacement noise level for generating strata
|
---|
| 48 | struct
|
---|
| 49 | {
|
---|
| 50 | GeoHeightMap::Precision base; // The base thickness of each layer of strata (in plaxels)
|
---|
| 51 | float curve; // Value between (0, 1] that determines how quickly strata thickness grows from layer to layer deep
|
---|
| 52 | float scale; // A scaling factor for layer thickness over and above the base
|
---|
| 53 | } thickness;
|
---|
| 54 | } layers;
|
---|
| 55 | struct
|
---|
| 56 | {
|
---|
| 57 | float frequency; // Approximate number of minerals per 1000 pixels cubed per pass, actual synthesis may be more due to nested/hosted minerals
|
---|
| 58 | mars::RangeX< unsigned long > neighborhood; // Minimum/maximum radius that a neighborhood of rock is sampled for determining appropriate minerals to synthesize at that location.
|
---|
| 59 | struct
|
---|
| 60 | {
|
---|
| 61 | float curve; // Value between (0, 1] that determines how quickly mineral abundance increases
|
---|
| 62 | } abundance;
|
---|
| 63 | struct
|
---|
| 64 | {
|
---|
| 65 | float curve, // Value between (0, 1] that determines how quickly deposit size grows from the minimum
|
---|
| 66 | base; // The minimum deposit size
|
---|
| 67 |
|
---|
| 68 | struct
|
---|
| 69 | {
|
---|
| 70 | mars::RangeX< float > deviation; // Amount of sphere-pack deviation along the vein
|
---|
| 71 | mars::RangeX< unsigned short > detail; // Min/max of sphere-pack sub-division iterations, larger means very crooked veins
|
---|
| 72 | float erratic; // Degree of erratic angular placement of spheres
|
---|
| 73 | } vein;
|
---|
| 74 | struct
|
---|
| 75 | {
|
---|
| 76 | mars::RangeX< float > orthogonality; // RangeX between 0.0 and 1.0 determining the degree of alignment with the vertical axis
|
---|
| 77 | mars::RangeX< float > deviation; // Amount of sphere-pack deviation along the dike
|
---|
| 78 | } dike;
|
---|
| 79 | struct
|
---|
| 80 | {
|
---|
| 81 | mars::RangeX< float > tail; // Minimum/maximum size of the laccolith's tail (like the tail of an upside down teardrop) relative to deposit size
|
---|
| 82 | } laccolith;
|
---|
| 83 |
|
---|
| 84 | mars::RangeX< size_t > nesting; // Minimum/maximum number of nested hosted minerals to allow
|
---|
| 85 | } deposit;
|
---|
| 86 |
|
---|
| 87 | struct
|
---|
| 88 | {
|
---|
| 89 | WorldUnit
|
---|
| 90 | limit,
|
---|
| 91 | minimum,
|
---|
| 92 | maxtier;
|
---|
| 93 | mars::RangeX< float >
|
---|
| 94 | sizeflux;
|
---|
| 95 | mars::RangeX< unsigned short >
|
---|
| 96 | kidflux;
|
---|
| 97 | } spherepack;
|
---|
| 98 | } minerals;
|
---|
| 99 | };
|
---|
| 100 |
|
---|
| 101 | class IDepositSynthConfigReader
|
---|
| 102 | {
|
---|
| 103 | public:
|
---|
| 104 | virtual bool load (DepositSynthesizerSettings & settings) = 0;
|
---|
| 105 | };
|
---|
| 106 |
|
---|
| 107 | // TODO: Support more detail
|
---|
| 108 | class GMRegistryException : public std::exception
|
---|
| 109 | {
|
---|
| 110 | private:
|
---|
| 111 | std::string _msg;
|
---|
| 112 |
|
---|
| 113 | public:
|
---|
| 114 | GMRegistryException(const std::string & sMsg)
|
---|
| 115 | : _msg(sMsg) {}
|
---|
| 116 |
|
---|
| 117 | virtual const char * what() const noexcept { return _msg.c_str(); }
|
---|
| 118 | };
|
---|
| 119 | class GMMalformedConfigEx : public GMRegistryException
|
---|
| 120 | {
|
---|
| 121 | public:
|
---|
| 122 | GMMalformedConfigEx(const std::string & sMsg)
|
---|
| 123 | : GMRegistryException(sMsg) {}
|
---|
| 124 | };
|
---|
| 125 | class GMInvalidFactoryConfigEx : public GMRegistryException
|
---|
| 126 | {
|
---|
| 127 | public:
|
---|
| 128 | GMInvalidFactoryConfigEx (const std::string & sMsg = "Invalid factory configuration")
|
---|
| 129 | : GMRegistryException(sMsg) {}
|
---|
| 130 | };
|
---|
| 131 | class GMInvalidPropertyEx : public GMInvalidFactoryConfigEx
|
---|
| 132 | {
|
---|
| 133 | public:
|
---|
| 134 | std::string key;
|
---|
| 135 |
|
---|
| 136 | GMInvalidPropertyEx (const std::string & sKeyProp, const std::string & sMsg = "Invalid property")
|
---|
| 137 | : key(sKeyProp), GMInvalidFactoryConfigEx(sKeyProp + ": " + sMsg) {}
|
---|
| 138 | };
|
---|
| 139 | class GMIndexOutOfBoundsEx : public GMInvalidFactoryConfigEx
|
---|
| 140 | {
|
---|
| 141 | public:
|
---|
| 142 | size_t index;
|
---|
| 143 |
|
---|
| 144 | GMIndexOutOfBoundsEx (const size_t & nIdx, const std::string & sMsg = "Index out of bounds")
|
---|
| 145 | : index(nIdx), GMInvalidFactoryConfigEx(sMsg) {}
|
---|
| 146 | };
|
---|
| 147 |
|
---|
| 148 | class IConfigSection;
|
---|
| 149 | class IConfigSequence;
|
---|
| 150 |
|
---|
| 151 | class IConfigValue
|
---|
| 152 | {
|
---|
| 153 | protected:
|
---|
| 154 | template< typename T, typename M >
|
---|
| 155 | inline mars::RangeX< T > convertRange (const mars::RangeX< M > & rngFrom) const
|
---|
| 156 | {
|
---|
| 157 | return mars::RangeX< T > (
|
---|
| 158 | static_cast< T > (rngFrom.minimum),
|
---|
| 159 | static_cast< T > (rngFrom.maximum),
|
---|
| 160 | static_cast< T > (rngFrom.step)
|
---|
| 161 | );
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | virtual mars::RangeX< double > toDoubleRange () const {
|
---|
| 165 | auto dummy = mars::RangeX< double >();
|
---|
| 166 | return toRange(dummy);
|
---|
| 167 | }
|
---|
| 168 | virtual mars::RangeX< long > toLongRange () const {
|
---|
| 169 | auto dummy = mars::RangeX< long >();
|
---|
| 170 | return toRange(dummy);
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | virtual mars::RangeX< double > & toRange (mars::RangeX< double > & out) const = 0;
|
---|
| 174 | virtual mars::RangeX< long > & toRange (mars::RangeX< long > & out) const = 0;
|
---|
| 175 |
|
---|
| 176 | public:
|
---|
| 177 | virtual IConfigSection * operator >> (IConfigSection * & pSection) const = 0;
|
---|
| 178 | virtual IConfigSequence * operator >> (IConfigSequence * & pSequence) const = 0;
|
---|
| 179 | virtual std::string & operator >> (std::string & out) const = 0;
|
---|
| 180 | virtual float & operator >> (float & out) const = 0;
|
---|
| 181 | virtual bool & operator >> (bool & out) const = 0;
|
---|
| 182 | virtual unsigned int & operator >> (unsigned int & out) const = 0;
|
---|
| 183 | virtual unsigned short & operator >> (unsigned short & out) const = 0;
|
---|
| 184 |
|
---|
| 185 | virtual VectorTag< GeoHeightMap::Precision >::V2 & operator >> (VectorTag< GeoHeightMap::Precision >::V2 & out) const = 0;
|
---|
| 186 | virtual VectorTag< GeoHeightMap::Precision >::V3 & operator >> (VectorTag< GeoHeightMap::Precision >::V3 & out) const = 0;
|
---|
| 187 |
|
---|
| 188 | mars::RangeX< long > & operator >> (mars::RangeX< long > & out) const
|
---|
| 189 | { return out = toRange(out); }
|
---|
| 190 | mars::RangeX< double > & operator >> (mars::RangeX< double > & out) const
|
---|
| 191 | { return out = toRange(out); }
|
---|
| 192 | mars::RangeX< float > & operator >> (mars::RangeX< float > & out) const
|
---|
| 193 | { return out = convertRange< float > (toDoubleRange()); }
|
---|
| 194 |
|
---|
| 195 | mars::RangeX< int > & operator >> (mars::RangeX< int > & out) const
|
---|
| 196 | { return out = convertRange< int > (toLongRange()); }
|
---|
| 197 | mars::RangeX< short > & operator >> (mars::RangeX< short > & out) const
|
---|
| 198 | { return out = convertRange< short > (toLongRange()); }
|
---|
| 199 | mars::RangeX< unsigned int > & operator >> (mars::RangeX< unsigned int > & out) const
|
---|
| 200 | { return out = convertRange< unsigned int > (toLongRange()); }
|
---|
| 201 | mars::RangeX< unsigned short > & operator >> (mars::RangeX< unsigned short > & out) const
|
---|
| 202 | { return out = convertRange< unsigned short > (toLongRange()); }
|
---|
| 203 | };
|
---|
| 204 |
|
---|
| 205 | template< typename K >
|
---|
| 206 | class TemplConfigAggregate
|
---|
| 207 | {
|
---|
| 208 | private:
|
---|
| 209 | template< typename T, typename M >
|
---|
| 210 | mars::RangeX< T > getrng(const K & key, const T, const M)
|
---|
| 211 | {
|
---|
| 212 | mars::RangeX< M > rng;
|
---|
| 213 |
|
---|
| 214 | *operator [] (key) >> rng;
|
---|
| 215 | return mars::RangeX< T > (static_cast< T > (rng.minimum), static_cast< T > (rng.maximum));
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | public:
|
---|
| 219 | virtual const IConfigValue * operator [] (const K & key) const = 0;
|
---|
| 220 |
|
---|
| 221 | template< typename T >
|
---|
| 222 | T get(const K & key, T * = NULL)
|
---|
| 223 | {
|
---|
| 224 | T val;
|
---|
| 225 |
|
---|
| 226 | return *operator [] (key) >> val;
|
---|
| 227 | }
|
---|
| 228 | std::string getstr(const K & key)
|
---|
| 229 | {
|
---|
| 230 | std::string str;
|
---|
| 231 | return *operator [] (key) >> str;
|
---|
| 232 | }
|
---|
| 233 | IConfigSection * getmap(const K & key)
|
---|
| 234 | {
|
---|
| 235 | IConfigSection * pSection;
|
---|
| 236 | return *operator [] (key) >> pSection;
|
---|
| 237 | }
|
---|
| 238 | IConfigSequence * getseq(const K & key)
|
---|
| 239 | {
|
---|
| 240 | IConfigSequence * pSequence;
|
---|
| 241 | return *operator [] (key) >> pSequence;
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | inline mars::RangeX< float > getrngf(const K & key)
|
---|
| 245 | { return getrng(key, 0.0f, 0.0); }
|
---|
| 246 | inline mars::RangeX< double > getrngd(const K & key)
|
---|
| 247 | { return getrng(key, 0.0, 0.0); }
|
---|
| 248 | inline mars::RangeX< short > getrngs(const K & key)
|
---|
| 249 | { return getrng(key, static_cast <short> (0), 0L); }
|
---|
| 250 | inline mars::RangeX< int > getrngi(const K & key)
|
---|
| 251 | { return getrng(key, 0, 0L); }
|
---|
| 252 | inline mars::RangeX< long > getrngl(const K & key)
|
---|
| 253 | { return getrng(key, 0L, 0L); }
|
---|
| 254 | };
|
---|
| 255 |
|
---|
| 256 | class IConfigSection : public TemplConfigAggregate< std::string > {};
|
---|
| 257 | class IConfigSequence : public TemplConfigAggregate< size_t > {};
|
---|
| 258 |
|
---|
| 259 | class IConfigFactoryBase
|
---|
| 260 | {
|
---|
| 261 | public:
|
---|
| 262 | const std::string factory, nom;
|
---|
| 263 |
|
---|
| 264 | IConfigFactoryBase(const std::string & factory)
|
---|
| 265 | : factory(factory), nom(factory) {}
|
---|
| 266 | IConfigFactoryBase(const std::string & factory, const std::string & name)
|
---|
| 267 | : factory(factory), nom(name) {}
|
---|
| 268 |
|
---|
| 269 | virtual IConfigSection * getSection() = 0;
|
---|
| 270 | virtual ~IConfigFactoryBase() = 0;
|
---|
| 271 | };
|
---|
| 272 |
|
---|
| 273 | enum GeoTemplatePhase
|
---|
| 274 | { GTP_Pre = 0, GTP_Post = 1, CountGTP = 2 };
|
---|
| 275 |
|
---|
| 276 | class IConfigGMFactory : public IConfigFactoryBase
|
---|
| 277 | {
|
---|
| 278 | public:
|
---|
| 279 | const struct Settings
|
---|
| 280 | {
|
---|
| 281 | float frequency;
|
---|
| 282 | } settings;
|
---|
| 283 |
|
---|
| 284 | IConfigGMFactory(const std::string & factory, const Settings & settings)
|
---|
| 285 | : IConfigFactoryBase(factory), settings(settings) {}
|
---|
| 286 | IConfigGMFactory(const std::string & factory, const std::string & name, const Settings & settings)
|
---|
| 287 | : IConfigFactoryBase(factory, name), settings(settings) {}
|
---|
| 288 | };
|
---|
| 289 |
|
---|
| 290 | class IConfigGTFactory : public IConfigFactoryBase
|
---|
| 291 | {
|
---|
| 292 | public:
|
---|
| 293 | const struct Settings
|
---|
| 294 | {
|
---|
| 295 | GeoTemplatePhase phase;
|
---|
| 296 | } settings;
|
---|
| 297 |
|
---|
| 298 | IConfigGTFactory(const std::string & factory, const Settings & settings)
|
---|
| 299 | : IConfigFactoryBase(factory), settings(settings) {}
|
---|
| 300 | IConfigGTFactory(const std::string & factory, const std::string & name, const Settings & settings)
|
---|
| 301 | : IConfigFactoryBase(factory, name), settings(settings) {}
|
---|
| 302 | };
|
---|
| 303 |
|
---|
| 304 | class IFactoryConfigReader
|
---|
| 305 | {
|
---|
| 306 | public:
|
---|
| 307 | virtual IConfigFactoryBase * readNext () = 0;
|
---|
| 308 | };
|
---|
| 309 |
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 | #endif
|
---|