mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-24 04:59:24 -06:00
Spatial scale for DataSphere
This commit is contained in:
@@ -7,7 +7,7 @@ function preInitialization()
|
||||
]]--
|
||||
|
||||
--openspace.time.setTime(openspace.time.currentWallTime())
|
||||
openspace.time.setTime('2015-03-15T11:00:00.00')
|
||||
openspace.time.setTime('2015-03-15T00:00:00.00')
|
||||
--openspace.time.setTime('2000-01-01T00:00:00.00')
|
||||
openspace.time.setDeltaTime(0)
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys_iswa.lua'))
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
Copyright (C) 2004-2008 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
|
||||
*/
|
||||
|
||||
#include "base64.h"
|
||||
#include <iostream>
|
||||
|
||||
static const std::string base64_chars =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
|
||||
static inline bool is_base64(unsigned char c) {
|
||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||
}
|
||||
|
||||
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
|
||||
std::string ret;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
unsigned char char_array_3[3];
|
||||
unsigned char char_array_4[4];
|
||||
|
||||
while (in_len--) {
|
||||
char_array_3[i++] = *(bytes_to_encode++);
|
||||
if (i == 3) {
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for(i = 0; (i <4) ; i++)
|
||||
ret += base64_chars[char_array_4[i]];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i)
|
||||
{
|
||||
for(j = i; j < 3; j++)
|
||||
char_array_3[j] = '\0';
|
||||
|
||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
||||
|
||||
for (j = 0; (j < i + 1); j++)
|
||||
ret += base64_chars[char_array_4[j]];
|
||||
|
||||
while((i++ < 3))
|
||||
ret += '=';
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
std::string base64_decode(std::string const& encoded_string) {
|
||||
int in_len = encoded_string.size();
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int in_ = 0;
|
||||
unsigned char char_array_4[4], char_array_3[3];
|
||||
std::string ret;
|
||||
|
||||
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
|
||||
char_array_4[i++] = encoded_string[in_]; in_++;
|
||||
if (i ==4) {
|
||||
for (i = 0; i <4; i++)
|
||||
char_array_4[i] = base64_chars.find(char_array_4[i]);
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (i = 0; (i < 3); i++)
|
||||
ret += char_array_3[i];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i) {
|
||||
for (j = i; j <4; j++)
|
||||
char_array_4[j] = 0;
|
||||
|
||||
for (j = 0; j <4; j++)
|
||||
char_array_4[j] = base64_chars.find(char_array_4[j]);
|
||||
|
||||
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
|
||||
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||
|
||||
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
#include <string>
|
||||
|
||||
std::string base64_encode(unsigned char const* , unsigned int len);
|
||||
std::string base64_decode(std::string const& s);
|
||||
@@ -41,18 +41,13 @@ DataCygnet::DataCygnet(const ghoul::Dictionary& dictionary)
|
||||
:IswaCygnet(dictionary)
|
||||
,_dataProcessor(nullptr)
|
||||
,_dataOptions("dataOptions", "Data Options")
|
||||
// ,_useLog("useLog","Use Logarithm", false)
|
||||
,_useHistogram("useHistogram", "Auto Contrast", false)
|
||||
,_autoFilter("autoFilter", "Auto Filter", true)
|
||||
,_normValues("normValues", "Normalize Values", glm::vec2(1.0,1.0), glm::vec2(0), glm::vec2(5.0))
|
||||
,_backgroundValues("backgroundValues", "Background Values", glm::vec2(0.0), glm::vec2(0), glm::vec2(1.0))
|
||||
,_transferFunctionsFile("transferfunctions", "Transfer Functions", "${OPENSPACE_DATA}/iswa/transferfunctions/tfs/default.tf")
|
||||
//FOR TESTING
|
||||
// ,_numOfBenchmarks(0)
|
||||
// ,_avgBenchmarkTime(0.0f)
|
||||
{
|
||||
addProperty(_dataOptions);
|
||||
// addProperty(_useLog);
|
||||
addProperty(_useHistogram);
|
||||
addProperty(_autoFilter);
|
||||
addProperty(_normValues);
|
||||
@@ -82,6 +77,7 @@ bool DataCygnet::updateTexture(){
|
||||
if(!values) continue;
|
||||
|
||||
if(!_textures[option]){
|
||||
//create new texture
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture = std::make_unique<ghoul::opengl::Texture>(
|
||||
values,
|
||||
_textureDimensions,
|
||||
@@ -98,6 +94,7 @@ bool DataCygnet::updateTexture(){
|
||||
_textures[option] = std::move(texture);
|
||||
}
|
||||
}else{
|
||||
//update existing texture
|
||||
_textures[option]->setPixelData(values);
|
||||
_textures[option]->uploadTexture();
|
||||
}
|
||||
@@ -166,6 +163,7 @@ void DataCygnet::setTextureUniforms(){
|
||||
if(activeTextures > 0 && selectedOptions.back()>=(int)_transferFunctions.size())
|
||||
activeTransferfunctions = 1;
|
||||
|
||||
//Set Transferfunctions
|
||||
ghoul::opengl::TextureUnit tfUnits[MAX_TEXTURES];
|
||||
j = 0;
|
||||
|
||||
@@ -243,11 +241,6 @@ void DataCygnet::setPropertyCallbacks(){
|
||||
updateTexture();
|
||||
});
|
||||
|
||||
// _useLog.onChange([this](){
|
||||
// _dataProcessor->useLog(_useLog.value());
|
||||
// updateTexture();
|
||||
// });
|
||||
|
||||
_useHistogram.onChange([this](){
|
||||
_dataProcessor->useHistogram(_useHistogram.value());
|
||||
updateTexture();
|
||||
@@ -309,11 +302,6 @@ void DataCygnet::subscribeToGroup(){
|
||||
_transferFunctionsFile.setValue(dict.value<std::string>("transferFunctions"));
|
||||
});
|
||||
|
||||
// groupEvent->subscribe(name(), "useLogChanged", [&](const ghoul::Dictionary& dict){
|
||||
// LDEBUG(name() + " Event useLogChanged");
|
||||
// _useLog.setValue(dict.value<bool>("useLog"));
|
||||
// });
|
||||
|
||||
groupEvent->subscribe(name(), "useHistogramChanged", [&](ghoul::Dictionary dict){
|
||||
LDEBUG(name() + " Event useHistogramChanged");
|
||||
_useHistogram.setValue(dict.value<bool>("useHistogram"));
|
||||
@@ -337,6 +325,7 @@ void DataCygnet::getGroupPropertyValues(){
|
||||
_backgroundValues.onChange([this]{
|
||||
glm::vec2 bv = _backgroundValues.value();
|
||||
|
||||
//let the values "push" each other
|
||||
if(bv.x > bv.y){
|
||||
float y = bv.y;
|
||||
bv.y = bv.x;
|
||||
|
||||
@@ -103,7 +103,6 @@ protected:
|
||||
properties::StringProperty _transferFunctionsFile;
|
||||
properties::Vec2Property _backgroundValues;
|
||||
properties::Vec2Property _normValues;
|
||||
// properties::BoolProperty _useLog;
|
||||
properties::BoolProperty _useHistogram;
|
||||
properties::BoolProperty _autoFilter;
|
||||
|
||||
@@ -111,10 +110,6 @@ protected:
|
||||
std::string _dataBuffer;
|
||||
glm::size3_t _textureDimensions;
|
||||
|
||||
//FOR TESTING
|
||||
// int _numOfBenchmarks;
|
||||
// double _avgBenchmarkTime;
|
||||
|
||||
private:
|
||||
bool readyToRender() const override;
|
||||
bool downloadTextureResource(double timestamp = Time::ref().currentTime()) override;
|
||||
|
||||
@@ -50,7 +50,6 @@ bool DataPlane::initialize(){
|
||||
_dataProcessor = _group->dataProcessor();
|
||||
subscribeToGroup();
|
||||
}else{
|
||||
// OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
OsEng.gui()._iswa.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iswa.registerProperty(&_autoFilter);
|
||||
OsEng.gui()._iswa.registerProperty(&_normValues);
|
||||
@@ -97,7 +96,8 @@ bool DataPlane::createGeometry() {
|
||||
const GLfloat z = s*_data->scale.z/2.0;
|
||||
const GLfloat w = _data->spatialScale.w;
|
||||
|
||||
const GLfloat vertex_data[] = { // square of two triangles (sigh)
|
||||
//construct a 2D plane independent of axis alignment
|
||||
const GLfloat vertex_data[] = {
|
||||
// x y z w s t
|
||||
-x, -y, -z, w, 0, 1,
|
||||
x, y, z, w, 1, 0,
|
||||
@@ -156,25 +156,6 @@ std::vector<float*> DataPlane::textureData(){
|
||||
return std::vector<float*>();
|
||||
}
|
||||
}
|
||||
// _textureDimensions = _dataProcessor->dimensions();
|
||||
|
||||
// // FOR TESTING
|
||||
// // ===========
|
||||
// std::chrono::time_point<std::chrono::system_clock> start, end;
|
||||
// start = std::chrono::system_clock::now();
|
||||
// // ===========
|
||||
// std::vector<float*> d = _dataProcessor->processData(_dataBuffer, _dataOptions, _textureDimensions);
|
||||
|
||||
// // FOR TESTING
|
||||
// // ===========
|
||||
// end = std::chrono::system_clock::now();
|
||||
// _numOfBenchmarks++;
|
||||
// std::chrono::duration<double> elapsed_seconds = end-start;
|
||||
// _avgBenchmarkTime = ( (_avgBenchmarkTime * (_numOfBenchmarks-1)) + elapsed_seconds.count() ) / _numOfBenchmarks;
|
||||
// std::cout << " processData() " << name() << std::endl;
|
||||
// std::cout << "avg elapsed time: " << _avgBenchmarkTime << "s\n";
|
||||
// std::cout << "num Benchmarks: " << _numOfBenchmarks << "\n";
|
||||
// ===========
|
||||
|
||||
return _dataProcessor->processData(_dataBuffer, _dataOptions, _textureDimensions);
|
||||
}
|
||||
|
||||
@@ -52,8 +52,6 @@ DataSphere::DataSphere(const ghoul::Dictionary& dictionary)
|
||||
_programName = "DataSphereProgram";
|
||||
_vsPath = "${MODULE_ISWA}/shaders/datasphere_vs.glsl";
|
||||
_fsPath = "${MODULE_ISWA}/shaders/datasphere_fs.glsl";
|
||||
|
||||
|
||||
}
|
||||
|
||||
DataSphere::~DataSphere(){}
|
||||
@@ -67,9 +65,7 @@ bool DataSphere::initialize(){
|
||||
if(_group){
|
||||
_dataProcessor = _group->dataProcessor();
|
||||
subscribeToGroup();
|
||||
//getGroupPropertyValues();
|
||||
}else{
|
||||
// OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
OsEng.gui()._iswa.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iswa.registerProperty(&_autoFilter);
|
||||
OsEng.gui()._iswa.registerProperty(&_normValues);
|
||||
@@ -99,7 +95,8 @@ bool DataSphere::initialize(){
|
||||
}
|
||||
|
||||
bool DataSphere::createGeometry(){
|
||||
PowerScaledScalar radius = PowerScaledScalar(6.371f*_radius, 6.0);
|
||||
// std::cout << _data->spatialScale.x << " " << _data->spatialScale.w << std::endl;
|
||||
PowerScaledScalar radius = PowerScaledScalar(_data->spatialScale.x*_radius, _data->spatialScale.w);
|
||||
int segments = 100;
|
||||
_sphere = std::make_shared<PowerScaledSphere>(radius, segments);
|
||||
_sphere->initialize();
|
||||
|
||||
@@ -145,7 +145,7 @@ std::string LuaCygnetConverter::kameleonToLuaTable(CdfInfo info, std::string cut
|
||||
coordinateType = "Cartesian";
|
||||
}else{
|
||||
spatialScale = glm::vec4(1.0);
|
||||
spatialScale.w = 1; //-log10(1.0f/max.x);
|
||||
spatialScale.w = -log10(1.0f/max.x);
|
||||
coordinateType = "Polar";
|
||||
}
|
||||
|
||||
@@ -212,6 +212,7 @@ std::string LuaCygnetConverter::sphereToLuaTable(std::shared_ptr<MetadataFuture>
|
||||
"Frame = '" + frame + "' , "
|
||||
"GridMin = " + std::to_string(min) + ", "
|
||||
"GridMax = " + std::to_string(max) + ", "
|
||||
"SpatialScale = " + std::to_string(spatialScale) + ", "
|
||||
"UpdateTime = " + std::to_string(updateTime) + ", "
|
||||
"Radius = " + std::to_string(radius) + ", "
|
||||
"CoordinateType = '" + coordinateType + "', "
|
||||
|
||||
@@ -21,7 +21,7 @@ openspace.bindKey("h", "openspace.iswa.setBaseUrl('http://iswa-demo-server.herok
|
||||
openspace.bindKey("g", "openspace.iswa.setBaseUrl('http://128.183.168.116:3000/')");
|
||||
openspace.bindKey("l", "openspace.iswa.setBaseUrl('http://localhost:3000/')");
|
||||
|
||||
openspace.bindKey("v", "openspace.time.setTime('2015-03-15T11:00:00.00')");
|
||||
openspace.bindKey("v", "openspace.time.setTime('2015-03-15T00:00:00.00')");
|
||||
|
||||
openspace.bindKey("s", "openspace.saveCameraPosition('${OPENSPACE_DATA}/iswa/magnetosphere.pos');");
|
||||
openspace.bindKey("a", "openspace.restoreCameraPosition('${OPENSPACE_DATA}/iswa/magnetosphere.pos');");
|
||||
Reference in New Issue
Block a user