mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Windows compile fixes
This commit is contained in:
@@ -37,115 +37,115 @@ namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
|
||||
struct TileMetaData {
|
||||
std::vector<float> maxValues;
|
||||
std::vector<float> minValues;
|
||||
std::vector<bool> hasMissingData;
|
||||
struct TileMetaData {
|
||||
std::vector<float> maxValues;
|
||||
std::vector<float> minValues;
|
||||
std::vector<bool> hasMissingData;
|
||||
|
||||
void serialize(std::ostream& s);
|
||||
static TileMetaData deserialize(std::istream& s);
|
||||
};
|
||||
void serialize(std::ostream& s);
|
||||
static TileMetaData deserialize(std::istream& s);
|
||||
};
|
||||
|
||||
struct TextureFormat {
|
||||
ghoul::opengl::Texture::Format ghoulFormat;
|
||||
GLuint glFormat;
|
||||
};
|
||||
struct TextureFormat {
|
||||
ghoul::opengl::Texture::Format ghoulFormat;
|
||||
GLuint glFormat;
|
||||
};
|
||||
|
||||
using namespace ghoul::opengl;
|
||||
using namespace ghoul::opengl;
|
||||
|
||||
struct RawTile {
|
||||
RawTile();
|
||||
struct RawTile {
|
||||
RawTile();
|
||||
|
||||
char* imageData;
|
||||
glm::uvec3 dimensions;
|
||||
std::shared_ptr<TileMetaData> tileMetaData;
|
||||
TileIndex tileIndex;
|
||||
CPLErr error;
|
||||
size_t nBytesImageData;
|
||||
char* imageData;
|
||||
glm::uvec3 dimensions;
|
||||
std::shared_ptr<TileMetaData> tileMetaData;
|
||||
TileIndex tileIndex;
|
||||
CPLErr error;
|
||||
size_t nBytesImageData;
|
||||
|
||||
void serializeMetaData(std::ostream& s);
|
||||
static RawTile deserializeMetaData(std::istream& s);
|
||||
void serializeMetaData(std::ostream& s);
|
||||
static RawTile deserializeMetaData(std::istream& s);
|
||||
|
||||
static RawTile createDefaultRes();
|
||||
static RawTile createDefaultRes();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct TileUvTransform {
|
||||
glm::vec2 uvOffset;
|
||||
glm::vec2 uvScale;
|
||||
};
|
||||
struct TileUvTransform {
|
||||
glm::vec2 uvOffset;
|
||||
glm::vec2 uvScale;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Defines a status and may have a Texture and TileMetaData
|
||||
*/
|
||||
struct Tile {
|
||||
std::shared_ptr<Texture> texture;
|
||||
std::shared_ptr<TileMetaData> metaData;
|
||||
|
||||
/**
|
||||
* Defines a status and may have a Texture and TileMetaData
|
||||
* Describe if this Tile is good for usage (OK) or otherwise
|
||||
* the reason why it is not.
|
||||
*/
|
||||
struct Tile {
|
||||
std::shared_ptr<Texture> texture;
|
||||
std::shared_ptr<TileMetaData> metaData;
|
||||
enum class Status {
|
||||
/**
|
||||
* E.g when texture data is not currently in memory.
|
||||
* texture and tileMetaData are both null
|
||||
*/
|
||||
Unavailable,
|
||||
|
||||
/**
|
||||
* Describe if this Tile is good for usage (OK) or otherwise
|
||||
* the reason why it is not.
|
||||
* Can be set by <code>TileProvider</code>s if the requested
|
||||
* <code>TileIndex</code> is undefined for that particular
|
||||
* provider.
|
||||
* texture and metaData are both null
|
||||
*/
|
||||
enum class Status {
|
||||
/**
|
||||
* E.g when texture data is not currently in memory.
|
||||
* texture and tileMetaData are both null
|
||||
*/
|
||||
Unavailable,
|
||||
OutOfRange,
|
||||
|
||||
/**
|
||||
* Can be set by <code>TileProvider</code>s if the requested
|
||||
* <code>TileIndex</code> is undefined for that particular
|
||||
* provider.
|
||||
* texture and metaData are both null
|
||||
*/
|
||||
OutOfRange,
|
||||
/**
|
||||
* An IO Error happend
|
||||
* texture and metaData are both null
|
||||
*/
|
||||
IOError,
|
||||
|
||||
/**
|
||||
* An IO Error happend
|
||||
* texture and metaData are both null
|
||||
*/
|
||||
IOError,
|
||||
|
||||
/**
|
||||
* The Texture is uploaded to the GPU and good for usage.
|
||||
* texture is defined. metaData may be defined.
|
||||
*/
|
||||
OK
|
||||
} status;
|
||||
/**
|
||||
* The Texture is uploaded to the GPU and good for usage.
|
||||
* texture is defined. metaData may be defined.
|
||||
*/
|
||||
OK
|
||||
} status;
|
||||
|
||||
/**
|
||||
* Instantiates a new tile with a single color.
|
||||
*
|
||||
* \param size The size of texture to be created
|
||||
* \param color defined RGBA values in range 0-255.
|
||||
*
|
||||
* \returns a Tile with status OK and the a texture
|
||||
* with the requested size and color
|
||||
*/
|
||||
static Tile createPlainTile(const glm::uvec2& size, const glm::uvec4& color);
|
||||
|
||||
static glm::vec2 compensateSourceTextureSampling(
|
||||
glm::vec2 startOffset,
|
||||
glm::vec2 sizeDiff,
|
||||
glm::uvec2 resolution,
|
||||
glm::vec2 tileUV);
|
||||
|
||||
static glm::vec2 TileUvToTextureSamplePosition(
|
||||
const TileUvTransform uvTransform,
|
||||
glm::vec2 tileUV,
|
||||
glm::uvec2 resolution);
|
||||
|
||||
/**
|
||||
* A tile with status unavailable that any user can return to
|
||||
* indicate that a tile was unavailable.
|
||||
/**
|
||||
* Instantiates a new tile with a single color.
|
||||
*
|
||||
* \param size The size of texture to be created
|
||||
* \param color defined RGBA values in range 0-255.
|
||||
*
|
||||
* \returns a Tile with status OK and the a texture
|
||||
* with the requested size and color
|
||||
*/
|
||||
static const Tile TileUnavailable;
|
||||
static Tile createPlainTile(const glm::uvec2& size, const glm::uvec4& color);
|
||||
|
||||
};
|
||||
static glm::vec2 compensateSourceTextureSampling(
|
||||
glm::vec2 startOffset,
|
||||
glm::vec2 sizeDiff,
|
||||
glm::uvec2 resolution,
|
||||
glm::vec2 tileUV);
|
||||
|
||||
static glm::vec2 TileUvToTextureSamplePosition(
|
||||
const TileUvTransform uvTransform,
|
||||
glm::vec2 tileUV,
|
||||
glm::uvec2 resolution);
|
||||
|
||||
/**
|
||||
* A tile with status unavailable that any user can return to
|
||||
* indicate that a tile was unavailable.
|
||||
*/
|
||||
static const Tile TileUnavailable;
|
||||
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace ghoul{
|
||||
namespace ghoul {
|
||||
class Dictionary;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef __TEXT_TILE_PROVIDER_H__
|
||||
#define __TEXT_TILE_PROVIDER_H__
|
||||
|
||||
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
@@ -37,109 +39,108 @@
|
||||
#include <ghoul/font/fontmanager.h>
|
||||
|
||||
#include <modules/globebrowsing/tile/asynctilereader.h>
|
||||
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
|
||||
#include <modules/globebrowsing/other/lrucache.h>
|
||||
#include <modules/globebrowsing/geometry/ellipsoid.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TILE PROVIDER //
|
||||
// TILE PROVIDER //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
using namespace ghoul::fontrendering;
|
||||
using namespace ghoul::fontrendering;
|
||||
|
||||
/**
|
||||
* Enables a simple way of providing tiles with any type of rendered text.
|
||||
* Internally it handles setting up a FBO for rendering the text, and defines a new
|
||||
* interface, consisting of only a single method for subclasses to implement:
|
||||
* renderText(const FontRenderer&, const TileIndex&) const;
|
||||
*/
|
||||
class TextTileProvider : public TileProvider {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor with default values for texture and font size
|
||||
*/
|
||||
TextTileProvider(const glm::uvec2& textureSize = {512, 512}, size_t fontSize = 48);
|
||||
virtual ~TextTileProvider();
|
||||
|
||||
// The TileProvider interface below is implemented in this class
|
||||
virtual Tile getTile(const TileIndex& tileIndex);
|
||||
virtual Tile getDefaultTile();
|
||||
virtual Tile::Status getTileStatus(const TileIndex& index);
|
||||
virtual TileDepthTransform depthTransform();
|
||||
virtual void update();
|
||||
virtual void reset();
|
||||
virtual int maxLevel();
|
||||
|
||||
/**
|
||||
* Returns the tile which will be used to draw text onto.
|
||||
* Default implementation returns a tile with a plain transparent texture.
|
||||
*/
|
||||
virtual Tile backgroundTile(const TileIndex& tileIndex) const;
|
||||
|
||||
|
||||
/**
|
||||
* Allow overriding of hash function.
|
||||
* Default is <code>TileIndex::hashKey()</code>
|
||||
*
|
||||
* \param tileIndex tileIndex to hash
|
||||
* \returns hashkey used for in LRU cache for this tile
|
||||
*/
|
||||
virtual TileHashKey toHash(const TileIndex& tileIndex) const;
|
||||
|
||||
/**
|
||||
* Uses the fontRenderer to render some text onto the tile texture provided in
|
||||
* backgroundTile(const TileIndex& tileIndex).
|
||||
*
|
||||
* \param fontRenderer used for rendering text onto texture
|
||||
* \param tileIndex associated with the tile to be rendered onto
|
||||
*/
|
||||
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const = 0;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
glm::uvec2 _textureSize;
|
||||
size_t _fontSize;
|
||||
|
||||
private:
|
||||
Tile createChunkIndexTile(const TileIndex& tileIndex);
|
||||
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
|
||||
|
||||
TileCache _tileCache;
|
||||
GLuint _fbo;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides <code>Tile</code>s with the chunk index rendered as text onto its tiles.
|
||||
*/
|
||||
class TileIndexTileProvider : public TextTileProvider {
|
||||
public:
|
||||
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructed with an ellipsoid and uses that to render the longitudal length of each
|
||||
* of each tile.
|
||||
/**
|
||||
* Enables a simple way of providing tiles with any type of rendered text.
|
||||
* Internally it handles setting up a FBO for rendering the text, and defines a new
|
||||
* interface, consisting of only a single method for subclasses to implement:
|
||||
* renderText(const FontRenderer&, const TileIndex&) const;
|
||||
*/
|
||||
class SizeReferenceTileProvider : public TextTileProvider {
|
||||
public:
|
||||
SizeReferenceTileProvider(const ghoul::Dictionary& dictionary);
|
||||
class TextTileProvider : public TileProvider {
|
||||
public:
|
||||
|
||||
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const;
|
||||
virtual Tile backgroundTile(const TileIndex& tileIndex) const;
|
||||
/**
|
||||
* Default constructor with default values for texture and font size
|
||||
*/
|
||||
TextTileProvider(const glm::uvec2& textureSize = {512, 512}, size_t fontSize = 48);
|
||||
virtual ~TextTileProvider();
|
||||
|
||||
virtual TileHashKey toHash(const TileIndex& tileIndex) const;
|
||||
// The TileProvider interface below is implemented in this class
|
||||
virtual Tile getTile(const TileIndex& tileIndex);
|
||||
virtual Tile getDefaultTile();
|
||||
virtual Tile::Status getTileStatus(const TileIndex& index);
|
||||
virtual TileDepthTransform depthTransform();
|
||||
virtual void update();
|
||||
virtual void reset();
|
||||
virtual int maxLevel();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Returns the tile which will be used to draw text onto.
|
||||
* Default implementation returns a tile with a plain transparent texture.
|
||||
*/
|
||||
virtual Tile backgroundTile(const TileIndex& tileIndex) const;
|
||||
|
||||
int roundedLongitudalLength(const TileIndex& tileIndex) const;
|
||||
|
||||
Ellipsoid _ellipsoid;
|
||||
Tile _backgroundTile;
|
||||
};
|
||||
/**
|
||||
* Allow overriding of hash function.
|
||||
* Default is <code>TileIndex::hashKey()</code>
|
||||
*
|
||||
* \param tileIndex tileIndex to hash
|
||||
* \returns hashkey used for in LRU cache for this tile
|
||||
*/
|
||||
virtual TileHashKey toHash(const TileIndex& tileIndex) const;
|
||||
|
||||
/**
|
||||
* Uses the fontRenderer to render some text onto the tile texture provided in
|
||||
* backgroundTile(const TileIndex& tileIndex).
|
||||
*
|
||||
* \param fontRenderer used for rendering text onto texture
|
||||
* \param tileIndex associated with the tile to be rendered onto
|
||||
*/
|
||||
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const = 0;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ghoul::fontrendering::Font> _font;
|
||||
glm::uvec2 _textureSize;
|
||||
size_t _fontSize;
|
||||
|
||||
private:
|
||||
Tile createChunkIndexTile(const TileIndex& tileIndex);
|
||||
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
|
||||
|
||||
TileCache _tileCache;
|
||||
GLuint _fbo;
|
||||
};
|
||||
|
||||
/**
|
||||
* Provides <code>Tile</code>s with the chunk index rendered as text onto its tiles.
|
||||
*/
|
||||
class TileIndexTileProvider : public TextTileProvider {
|
||||
public:
|
||||
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructed with an ellipsoid and uses that to render the longitudal length of each
|
||||
* of each tile.
|
||||
*/
|
||||
class SizeReferenceTileProvider : public TextTileProvider {
|
||||
public:
|
||||
SizeReferenceTileProvider(const ghoul::Dictionary& dictionary);
|
||||
|
||||
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const;
|
||||
virtual Tile backgroundTile(const TileIndex& tileIndex) const;
|
||||
|
||||
virtual TileHashKey toHash(const TileIndex& tileIndex) const;
|
||||
|
||||
private:
|
||||
|
||||
int roundedLongitudalLength(const TileIndex& tileIndex) const;
|
||||
|
||||
Ellipsoid _ellipsoid;
|
||||
Tile _backgroundTile;
|
||||
};
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
@@ -63,7 +63,7 @@ float TileProvider::noDataValueAsFloat() {
|
||||
return std::numeric_limits<float>::min();
|
||||
}
|
||||
|
||||
ChunkTile TileProvider::getChunkTile(TileIndex tileIndex, int parents, int maxParents){
|
||||
ChunkTile TileProvider::getChunkTile(TileIndex tileIndex, int parents, int maxParents) {
|
||||
TileUvTransform uvTransform;
|
||||
uvTransform.uvOffset = glm::vec2(0, 0);
|
||||
uvTransform.uvScale = glm::vec2(1, 1);
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef __TILE_PROVIDER_H__
|
||||
#define __TILE_PROVIDER_H__
|
||||
|
||||
#include <modules/globebrowsing/tile/tileindex.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h> // absPath
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
@@ -33,6 +35,7 @@
|
||||
#include <modules/globebrowsing/tile/tile.h>
|
||||
|
||||
#include <modules/globebrowsing/other/lrucache.h>
|
||||
#include <modules/globebrowsing/tile/chunktile.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TILE PROVIDER //
|
||||
@@ -41,121 +44,118 @@
|
||||
namespace openspace {
|
||||
namespace globebrowsing {
|
||||
|
||||
class ChunkTile;
|
||||
class ChunkTilePile;
|
||||
|
||||
using namespace ghoul::opengl;
|
||||
using namespace ghoul::opengl;
|
||||
|
||||
/**
|
||||
* Interface for providing <code>Tile</code>s given a
|
||||
* <code>TileIndex</code>.
|
||||
*/
|
||||
class TileProvider {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Interface for providing <code>Tile</code>s given a
|
||||
* <code>TileIndex</code>.
|
||||
* Factory method for instantiating different implementations of
|
||||
* <code>TileProviders</code>. The provided dictionary must
|
||||
* define a key specifying what implementation of TileProvider
|
||||
* to be instantiated.
|
||||
*/
|
||||
class TileProvider {
|
||||
public:
|
||||
static TileProvider* createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
|
||||
/**
|
||||
* Factory method for instantiating different implementations of
|
||||
* <code>TileProviders</code>. The provided dictionary must
|
||||
* define a key specifying what implementation of TileProvider
|
||||
* to be instantiated.
|
||||
*/
|
||||
static TileProvider* createFromDictionary(const ghoul::Dictionary& dictionary);
|
||||
/**
|
||||
* Empty default constructor
|
||||
*/
|
||||
TileProvider() {};
|
||||
|
||||
/**
|
||||
* Empty default constructor
|
||||
*/
|
||||
TileProvider() {};
|
||||
/**
|
||||
* Implementations of the TileProvider interface must implement
|
||||
* a constructor taking a dictionary as input. The provided
|
||||
* dictionary must define a key specifying what implementation
|
||||
* of TileProvider to be instantiated.
|
||||
*/
|
||||
TileProvider(const ghoul::Dictionary& dictionary);
|
||||
|
||||
/**
|
||||
* Implementations of the TileProvider interface must implement
|
||||
* a constructor taking a dictionary as input. The provided
|
||||
* dictionary must define a key specifying what implementation
|
||||
* of TileProvider to be instantiated.
|
||||
*/
|
||||
TileProvider(const ghoul::Dictionary& dictionary);
|
||||
/**
|
||||
* Virtual destructor that subclasses should override to do
|
||||
* clean up.
|
||||
*/
|
||||
virtual ~TileProvider() { }
|
||||
|
||||
/**
|
||||
* Virtual destructor that subclasses should override to do
|
||||
* clean up.
|
||||
*/
|
||||
virtual ~TileProvider() { }
|
||||
|
||||
/**
|
||||
* Method for querying tiles, given a specified <code>TileIndex</code>.
|
||||
*
|
||||
* This method is expected to be invoked multiple times per frame,
|
||||
* and should therefore return quickly, e.g. not perform heavy I/O
|
||||
* operations. However, invoking this method may spawn separate threads
|
||||
* to perform such operations. Therefore, programmers shoud
|
||||
* note that there is no guarantee that the <code>Tile</code>
|
||||
* status and texture will be consistent over different invocations
|
||||
* of this method.
|
||||
*
|
||||
* \param tileIndex specifying a region of a map for which
|
||||
* we want tile data.
|
||||
*
|
||||
* \returns The tile corresponding to the TileIndex by the time
|
||||
* the method was invoked.
|
||||
*/
|
||||
virtual Tile getTile(const TileIndex& tileIndex) = 0;
|
||||
/**
|
||||
* Method for querying tiles, given a specified <code>TileIndex</code>.
|
||||
*
|
||||
* This method is expected to be invoked multiple times per frame,
|
||||
* and should therefore return quickly, e.g. not perform heavy I/O
|
||||
* operations. However, invoking this method may spawn separate threads
|
||||
* to perform such operations. Therefore, programmers shoud
|
||||
* note that there is no guarantee that the <code>Tile</code>
|
||||
* status and texture will be consistent over different invocations
|
||||
* of this method.
|
||||
*
|
||||
* \param tileIndex specifying a region of a map for which
|
||||
* we want tile data.
|
||||
*
|
||||
* \returns The tile corresponding to the TileIndex by the time
|
||||
* the method was invoked.
|
||||
*/
|
||||
virtual Tile getTile(const TileIndex& tileIndex) = 0;
|
||||
|
||||
|
||||
virtual ChunkTile getChunkTile(TileIndex tileIndex, int parents = 0, int maxParents = 1337);
|
||||
virtual ChunkTile getChunkTile(TileIndex tileIndex, int parents = 0, int maxParents = 1337);
|
||||
|
||||
|
||||
virtual ChunkTilePile getChunkTilePile(TileIndex tileIndex, int pileSize);
|
||||
virtual ChunkTilePile getChunkTilePile(TileIndex tileIndex, int pileSize);
|
||||
|
||||
|
||||
/**
|
||||
* TileProviders must be able to provide a defualt
|
||||
* <code>Tile</code> which may be used by clients in cases when
|
||||
* requested tiles were unavailable.
|
||||
*
|
||||
* \returns A default tile
|
||||
*/
|
||||
virtual Tile getDefaultTile() = 0;
|
||||
/**
|
||||
* TileProviders must be able to provide a defualt
|
||||
* <code>Tile</code> which may be used by clients in cases when
|
||||
* requested tiles were unavailable.
|
||||
*
|
||||
* \returns A default tile
|
||||
*/
|
||||
virtual Tile getDefaultTile() = 0;
|
||||
|
||||
/**
|
||||
* Returns the status of a <code>Tile</code>. The <code>Tile::Status</code>
|
||||
* corresponds the <code>Tile</code> that would be returned
|
||||
* if the function <code>getTile</code> would be invoked with the same
|
||||
* <code>TileIndex</code> argument at this point in time.
|
||||
*/
|
||||
virtual Tile::Status getTileStatus(const TileIndex& index) = 0;
|
||||
/**
|
||||
* Returns the status of a <code>Tile</code>. The <code>Tile::Status</code>
|
||||
* corresponds the <code>Tile</code> that would be returned
|
||||
* if the function <code>getTile</code> would be invoked with the same
|
||||
* <code>TileIndex</code> argument at this point in time.
|
||||
*/
|
||||
virtual Tile::Status getTileStatus(const TileIndex& index) = 0;
|
||||
|
||||
/**
|
||||
* Get the associated depth transform for this TileProvider.
|
||||
* This is necessary for TileProviders serving height map
|
||||
* data, in order to correcly map pixel values to meters.
|
||||
*/
|
||||
virtual TileDepthTransform depthTransform() = 0;
|
||||
/**
|
||||
* Get the associated depth transform for this TileProvider.
|
||||
* This is necessary for TileProviders serving height map
|
||||
* data, in order to correcly map pixel values to meters.
|
||||
*/
|
||||
virtual TileDepthTransform depthTransform() = 0;
|
||||
|
||||
/**
|
||||
* This method should be called once per frame. Here, TileProviders
|
||||
* are given the opportunity to update their internal state.
|
||||
*/
|
||||
virtual void update() = 0;
|
||||
/**
|
||||
* This method should be called once per frame. Here, TileProviders
|
||||
* are given the opportunity to update their internal state.
|
||||
*/
|
||||
virtual void update() = 0;
|
||||
|
||||
/**
|
||||
* Provides a uniform way of all TileProviders to reload or
|
||||
* restore all of its internal state. This is mainly useful
|
||||
* for debugging purposes.
|
||||
*/
|
||||
virtual void reset() = 0;
|
||||
/**
|
||||
* Provides a uniform way of all TileProviders to reload or
|
||||
* restore all of its internal state. This is mainly useful
|
||||
* for debugging purposes.
|
||||
*/
|
||||
virtual void reset() = 0;
|
||||
|
||||
/**
|
||||
* \returns The maximum level as defined by <code>TileIndex</code>
|
||||
* that this TileProvider is able provide.
|
||||
*/
|
||||
virtual int maxLevel() = 0;
|
||||
/**
|
||||
* \returns The maximum level as defined by <code>TileIndex</code>
|
||||
* that this TileProvider is able provide.
|
||||
*/
|
||||
virtual int maxLevel() = 0;
|
||||
|
||||
/**
|
||||
* \returns the no data value for the dataset. Default is the minimum float avalue.
|
||||
*/
|
||||
virtual float noDataValueAsFloat();
|
||||
};
|
||||
/**
|
||||
* \returns the no data value for the dataset. Default is the minimum float avalue.
|
||||
*/
|
||||
virtual float noDataValueAsFloat();
|
||||
};
|
||||
|
||||
typedef LRUCache<TileHashKey, Tile> TileCache;
|
||||
typedef LRUCache<TileHashKey, Tile> TileCache;
|
||||
|
||||
} // namespace globebrowsing
|
||||
} // namespace openspace
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace globebrowsing {
|
||||
}
|
||||
|
||||
TileDepthTransform TileProviderByIndex::depthTransform() {
|
||||
_defaultTileProvider->depthTransform();
|
||||
return _defaultTileProvider->depthTransform();
|
||||
}
|
||||
|
||||
void TileProviderByIndex::update() {
|
||||
|
||||
@@ -30,14 +30,10 @@
|
||||
#include <fstream>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
using namespace openspace;
|
||||
|
||||
class AABBTest : public testing::Test {};
|
||||
|
||||
|
||||
|
||||
TEST_F(AABBTest, Contains2) {
|
||||
|
||||
using namespace openspace::globebrowsing;
|
||||
AABB2 a1;
|
||||
AABB2 a2;
|
||||
/*
|
||||
@@ -67,6 +63,7 @@ TEST_F(AABBTest, Contains2) {
|
||||
|
||||
|
||||
TEST_F(AABBTest, Intersects2) {
|
||||
using namespace openspace::globebrowsing;
|
||||
AABB2 a1;
|
||||
AABB2 a2;
|
||||
|
||||
@@ -98,9 +95,8 @@ TEST_F(AABBTest, Intersects2) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_F(AABBTest, Contains3) {
|
||||
using namespace openspace::globebrowsing;
|
||||
AABB3 a1;
|
||||
AABB3 a2;
|
||||
|
||||
@@ -122,6 +118,7 @@ TEST_F(AABBTest, Contains3) {
|
||||
|
||||
|
||||
TEST_F(AABBTest, Intersects3) {
|
||||
using namespace openspace::globebrowsing;
|
||||
AABB3 a1;
|
||||
AABB3 a2;
|
||||
|
||||
|
||||
@@ -30,90 +30,92 @@
|
||||
#include <fstream>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
using namespace openspace;
|
||||
|
||||
class AngleTest : public testing::Test {};
|
||||
|
||||
TEST_F(AngleTest, DoubleConversions) {
|
||||
|
||||
ASSERT_EQ(dAngle::fromRadians(0).asDegrees(), 0) << "from radians to degrees";
|
||||
ASSERT_EQ(dAngle::HALF.asDegrees(), 180) << "from radians to degrees";
|
||||
ASSERT_EQ(dAngle::fromDegrees(180).asRadians(), dAngle::PI) << "from degrees to radians";
|
||||
using namespace openspace::globebrowsing;
|
||||
|
||||
ASSERT_EQ(dAngle::fromRadians(0).asDegrees(), 0) << "from radians to degrees";
|
||||
ASSERT_EQ(dAngle::HALF.asDegrees(), 180) << "from radians to degrees";
|
||||
ASSERT_EQ(dAngle::fromDegrees(180).asRadians(), dAngle::PI) << "from degrees to radians";
|
||||
|
||||
}
|
||||
|
||||
TEST_F(AngleTest, FloatConversions) {
|
||||
using namespace openspace::globebrowsing;
|
||||
|
||||
ASSERT_EQ(fAngle::ZERO.asDegrees(), 0.0) << "from radians to degrees";
|
||||
ASSERT_EQ(fAngle::HALF.asDegrees(), 180.0) << "from radians to degrees";
|
||||
ASSERT_EQ(fAngle::fromDegrees(180).asRadians(), fAngle::PI) << "from degrees to radians";
|
||||
ASSERT_EQ(fAngle::ZERO.asDegrees(), 0.0) << "from radians to degrees";
|
||||
ASSERT_EQ(fAngle::HALF.asDegrees(), 180.0) << "from radians to degrees";
|
||||
ASSERT_EQ(fAngle::fromDegrees(180).asRadians(), fAngle::PI) << "from degrees to radians";
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_F(AngleTest, Normalize) {
|
||||
|
||||
|
||||
ASSERT_NEAR(
|
||||
dAngle::fromDegrees(390).normalize().asDegrees(),
|
||||
30.0,
|
||||
dAngle::EPSILON
|
||||
) << "normalize to [0, 360]";
|
||||
using namespace openspace::globebrowsing;
|
||||
|
||||
ASSERT_NEAR(
|
||||
dAngle::fromDegrees(390).normalize().asDegrees(),
|
||||
30.0,
|
||||
dAngle::EPSILON
|
||||
) << "normalize to [0, 360]";
|
||||
|
||||
|
||||
dAngle a = dAngle::fromDegrees(190);
|
||||
a.normalizeAround(dAngle::ZERO);
|
||||
ASSERT_NEAR(
|
||||
a.asDegrees(),
|
||||
-170,
|
||||
dAngle::EPSILON
|
||||
) << "normalize to [-180,180]";
|
||||
dAngle a = dAngle::fromDegrees(190);
|
||||
a.normalizeAround(dAngle::ZERO);
|
||||
ASSERT_NEAR(
|
||||
a.asDegrees(),
|
||||
-170,
|
||||
dAngle::EPSILON
|
||||
) << "normalize to [-180,180]";
|
||||
|
||||
|
||||
dAngle b = dAngle::fromDegrees(190);
|
||||
b.normalizeAround(dAngle::fromDegrees(90));
|
||||
ASSERT_NEAR(
|
||||
b.asDegrees(),
|
||||
190,
|
||||
dAngle::EPSILON
|
||||
) << "normalize to [-90,270]";
|
||||
dAngle b = dAngle::fromDegrees(190);
|
||||
b.normalizeAround(dAngle::fromDegrees(90));
|
||||
ASSERT_NEAR(
|
||||
b.asDegrees(),
|
||||
190,
|
||||
dAngle::EPSILON
|
||||
) << "normalize to [-90,270]";
|
||||
|
||||
|
||||
dAngle c = dAngle::fromDegrees(360);
|
||||
c.normalizeAround(dAngle::fromDegrees(1083.2));
|
||||
ASSERT_NEAR(
|
||||
c.asDegrees(),
|
||||
1080,
|
||||
dAngle::EPSILON
|
||||
) << "normalize to [903.2, 1263.2]";
|
||||
dAngle c = dAngle::fromDegrees(360);
|
||||
c.normalizeAround(dAngle::fromDegrees(1083.2));
|
||||
ASSERT_NEAR(
|
||||
c.asDegrees(),
|
||||
1080,
|
||||
dAngle::EPSILON
|
||||
) << "normalize to [903.2, 1263.2]";
|
||||
}
|
||||
|
||||
|
||||
TEST_F(AngleTest, Clamp) {
|
||||
using namespace openspace::globebrowsing;
|
||||
|
||||
ASSERT_EQ(
|
||||
dAngle::fromDegrees(390).clamp(dAngle::ZERO, dAngle::HALF).asDegrees(),
|
||||
180
|
||||
) << "clamp [0, 180]";
|
||||
ASSERT_EQ(
|
||||
dAngle::fromDegrees(390).clamp(dAngle::ZERO, dAngle::HALF).asDegrees(),
|
||||
180
|
||||
) << "clamp [0, 180]";
|
||||
|
||||
ASSERT_EQ(
|
||||
dAngle::fromDegrees(390).clamp(dAngle::ZERO, dAngle::FULL).asDegrees(),
|
||||
360
|
||||
) << "clamp [0, 360]";
|
||||
ASSERT_EQ(
|
||||
dAngle::fromDegrees(390).clamp(dAngle::ZERO, dAngle::FULL).asDegrees(),
|
||||
360
|
||||
) << "clamp [0, 360]";
|
||||
}
|
||||
|
||||
|
||||
TEST_F(AngleTest, ConstClamp) {
|
||||
|
||||
const dAngle a = dAngle::fromDegrees(390);
|
||||
ASSERT_EQ(
|
||||
a.getClamped(dAngle::ZERO, dAngle::HALF).asDegrees(),
|
||||
180
|
||||
) << "clamp [0, 180]";
|
||||
using namespace openspace::globebrowsing;
|
||||
|
||||
const dAngle b = dAngle::fromDegrees(390);
|
||||
ASSERT_EQ(
|
||||
b.getClamped(dAngle::ZERO, dAngle::FULL).asDegrees(),
|
||||
360
|
||||
) << "clamp [0, 360]";
|
||||
const dAngle a = dAngle::fromDegrees(390);
|
||||
ASSERT_EQ(
|
||||
a.getClamped(dAngle::ZERO, dAngle::HALF).asDegrees(),
|
||||
180
|
||||
) << "clamp [0, 180]";
|
||||
|
||||
const dAngle b = dAngle::fromDegrees(390);
|
||||
ASSERT_EQ(
|
||||
b.getClamped(dAngle::ZERO, dAngle::FULL).asDegrees(),
|
||||
360
|
||||
) << "clamp [0, 360]";
|
||||
}
|
||||
@@ -31,22 +31,12 @@
|
||||
#include <math.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
class ConcurrentJobManagerTest : public testing::Test {};
|
||||
|
||||
|
||||
using namespace openspace;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
|
||||
struct TestJob : public Job<int> {
|
||||
struct TestJob : public openspace::globebrowsing::Job<int> {
|
||||
TestJob(int jobExecutingTime)
|
||||
: _jobExecutingTime(jobExecutingTime) {
|
||||
|
||||
}
|
||||
: _jobExecutingTime(jobExecutingTime)
|
||||
{}
|
||||
|
||||
virtual void execute() {
|
||||
std::cout << "Executing job ... " << std::endl;
|
||||
@@ -68,6 +58,7 @@ private:
|
||||
|
||||
|
||||
TEST_F(ConcurrentJobManagerTest, Basic) {
|
||||
using namespace openspace::globebrowsing;
|
||||
std::shared_ptr<ThreadPool> pool = std::make_shared<ThreadPool>(1);
|
||||
|
||||
ConcurrentJobManager<int> jobManager(pool);
|
||||
@@ -95,12 +86,6 @@ TEST_F(ConcurrentJobManagerTest, Basic) {
|
||||
EXPECT_EQ(product, 1337) << "Expecting product to be 1337";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct VerboseProduct {
|
||||
VerboseProduct(int v)
|
||||
: val(v){
|
||||
@@ -115,7 +100,7 @@ struct VerboseProduct {
|
||||
};
|
||||
|
||||
|
||||
struct VerboseJob : public Job<VerboseProduct>{
|
||||
struct VerboseJob : public openspace::globebrowsing::Job<VerboseProduct>{
|
||||
VerboseJob(int jobExecutingTime)
|
||||
: _jobExecutingTime(jobExecutingTime) {
|
||||
std::cout << "VerboseTestJob constructor" << std::endl;
|
||||
@@ -141,12 +126,9 @@ struct VerboseJob : public Job<VerboseProduct>{
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TEST_F(ConcurrentJobManagerTest, JobCreation) {
|
||||
using namespace openspace::globebrowsing;
|
||||
|
||||
std::shared_ptr<ThreadPool> pool = std::make_shared<ThreadPool>(1);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
@@ -170,8 +152,6 @@ TEST_F(ConcurrentJobManagerTest, JobCreation) {
|
||||
auto product = finishedJob->product();
|
||||
}
|
||||
|
||||
|
||||
int a;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,17 +30,11 @@
|
||||
#include <math.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
class ConcurrentQueueTest : public testing::Test {};
|
||||
|
||||
|
||||
using namespace openspace;
|
||||
|
||||
|
||||
|
||||
TEST_F(ConcurrentQueueTest, Basic) {
|
||||
using namespace openspace::globebrowsing;
|
||||
|
||||
ConcurrentQueue<int> q1;
|
||||
q1.push(4);
|
||||
int val = q1.pop();
|
||||
|
||||
@@ -30,13 +30,10 @@
|
||||
#include <fstream>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
using namespace openspace;
|
||||
|
||||
class ConvexHull2Test : public testing::Test {};
|
||||
|
||||
|
||||
|
||||
TEST_F(ConvexHull2Test, basic) {
|
||||
using namespace openspace::globebrowsing;
|
||||
|
||||
// points
|
||||
// 2 x
|
||||
@@ -68,6 +65,7 @@ TEST_F(ConvexHull2Test, basic) {
|
||||
}
|
||||
|
||||
TEST_F(ConvexHull2Test, intersection) {
|
||||
using namespace openspace::globebrowsing;
|
||||
std::vector<Point2> points1 = {
|
||||
{ -1.0, 0.0 },
|
||||
{ 1.0, 0.0 },
|
||||
@@ -97,6 +95,7 @@ TEST_F(ConvexHull2Test, intersection) {
|
||||
|
||||
|
||||
TEST_F(ConvexHull2Test, non_intersection) {
|
||||
using namespace openspace::globebrowsing;
|
||||
std::vector<Point2> points1 = {
|
||||
{ -2.0, 0.0 },
|
||||
{ 2.0, 0.0 },
|
||||
|
||||
@@ -32,72 +32,65 @@
|
||||
|
||||
class LRUCacheTest : public testing::Test {};
|
||||
|
||||
using namespace openspace;
|
||||
|
||||
TEST_F(LRUCacheTest, Get) {
|
||||
LRUCache<int, std::string> lru(4);
|
||||
lru.put(1, "hej");
|
||||
lru.put(12, "san");
|
||||
ASSERT_STREQ(lru.get(1).c_str(), "hej") << "testing get";
|
||||
openspace::globebrowsing::LRUCache<int, std::string> lru(4);
|
||||
lru.put(1, "hej");
|
||||
lru.put(12, "san");
|
||||
ASSERT_STREQ(lru.get(1).c_str(), "hej") << "testing get";
|
||||
}
|
||||
|
||||
TEST_F(LRUCacheTest, CleaningCache) {
|
||||
LRUCache<int, double> lru(4);
|
||||
lru.put(1, 1.2);
|
||||
lru.put(12, 2.3);
|
||||
lru.put(123, 33.4);
|
||||
lru.put(1234, 4.5);
|
||||
lru.put(12345, 6.7);
|
||||
ASSERT_FALSE(lru.exist(1)) << "Element should have been cleaned out of cache";
|
||||
ASSERT_TRUE(lru.exist(12)) << "Element should remain in cache";
|
||||
openspace::globebrowsing::LRUCache<int, double> lru(4);
|
||||
lru.put(1, 1.2);
|
||||
lru.put(12, 2.3);
|
||||
lru.put(123, 33.4);
|
||||
lru.put(1234, 4.5);
|
||||
lru.put(12345, 6.7);
|
||||
ASSERT_FALSE(lru.exist(1)) << "Element should have been cleaned out of cache";
|
||||
ASSERT_TRUE(lru.exist(12)) << "Element should remain in cache";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct MyKey {
|
||||
int x, y;
|
||||
int x, y;
|
||||
};
|
||||
|
||||
bool operator==(const MyKey& a, const MyKey& b) {
|
||||
return a.x == b.x && a.y == b.y;
|
||||
return a.x == b.x && a.y == b.y;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& o, const MyKey& key) {
|
||||
return o << key.x << ", " << key.y;
|
||||
return o << key.x << ", " << key.y;
|
||||
}
|
||||
|
||||
// custom specialization of std::hash can be injected in namespace std
|
||||
namespace std {
|
||||
template<> struct hash<MyKey> {
|
||||
std::size_t operator()(MyKey const& s) const {
|
||||
return s.x ^ (s.y << 1);
|
||||
}
|
||||
};
|
||||
template<> struct hash<MyKey> {
|
||||
std::size_t operator()(MyKey const& s) const {
|
||||
return s.x ^ (s.y << 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
TEST_F(LRUCacheTest, StructKey) {
|
||||
openspace::globebrowsing::LRUCache<MyKey, std::string> lru(4);
|
||||
|
||||
LRUCache<MyKey, std::string> lru(4);
|
||||
// These two custom keys should be treated as equal
|
||||
MyKey key1 = { 2, 3 };
|
||||
MyKey key2 = { 2, 3 };
|
||||
|
||||
// These two custom keys should be treated as equal
|
||||
MyKey key1 = { 2, 3 };
|
||||
MyKey key2 = { 2, 3 };
|
||||
|
||||
std::string val1 = "value 1";
|
||||
std::string val2 = "value 2";
|
||||
std::string val1 = "value 1";
|
||||
std::string val2 = "value 2";
|
||||
|
||||
|
||||
lru.put(key1, val1);
|
||||
ASSERT_TRUE(lru.exist(key1));
|
||||
ASSERT_EQ(lru.get(key1), val1);
|
||||
lru.put(key1, val1);
|
||||
ASSERT_TRUE(lru.exist(key1));
|
||||
ASSERT_EQ(lru.get(key1), val1);
|
||||
|
||||
// Putting key2 should replace key1
|
||||
lru.put(key2, val2);
|
||||
ASSERT_EQ(key1, key2) << "key 1 and key2 should be considered equal";
|
||||
ASSERT_TRUE(lru.exist(key2));
|
||||
ASSERT_EQ(lru.get(key1), val2);
|
||||
ASSERT_EQ(lru.get(key2), val2);
|
||||
|
||||
// Putting key2 should replace key1
|
||||
lru.put(key2, val2);
|
||||
ASSERT_EQ(key1, key2) << "key 1 and key2 should be considered equal";
|
||||
ASSERT_TRUE(lru.exist(key2));
|
||||
ASSERT_EQ(lru.get(key1), val2);
|
||||
ASSERT_EQ(lru.get(key2), val2);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user