mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 12:59:07 -06:00
Make the iswa module compile again
This commit is contained in:
Submodule ext/ghoul updated: 80cf208aed...8f17cc57d9
@@ -115,9 +115,17 @@ bool DataCygnet::updateTexture() {
|
||||
}
|
||||
|
||||
bool texturesReady = false;
|
||||
const std::vector<int>& selectedOptions = _dataOptions.value();
|
||||
const std::set<std::string>& selectedOptions = _dataOptions;
|
||||
const std::vector<std::string>& options = _dataOptions.options();
|
||||
std::vector<int> selectedOptionsIndices;
|
||||
for (const std::string& option : selectedOptions) {
|
||||
auto it = std::find(options.begin(), options.end(), option);
|
||||
ghoul_assert(it != options.end(), "Selected option must be in all options");
|
||||
int idx = static_cast<int>(std::distance(options.begin(), it));
|
||||
selectedOptionsIndices.push_back(idx);
|
||||
}
|
||||
|
||||
for (int option : selectedOptions) {
|
||||
for (int option : selectedOptionsIndices) {
|
||||
float* values = data[option];
|
||||
if (!values) {
|
||||
continue;
|
||||
@@ -191,7 +199,16 @@ bool DataCygnet::readyToRender() const {
|
||||
* ghoul::TextureUnit needs to be passed as an argument to both.
|
||||
*/
|
||||
void DataCygnet::setTextureUniforms() {
|
||||
const std::vector<int>& selectedOptions = _dataOptions.value();
|
||||
const std::set<std::string>& selectedOptions = _dataOptions;
|
||||
const std::vector<std::string>& options = _dataOptions.options();
|
||||
std::vector<int> selectedOptionsIndices;
|
||||
for (const std::string& option : selectedOptions) {
|
||||
auto it = std::find(options.begin(), options.end(), option);
|
||||
ghoul_assert(it != options.end(), "Selected option must be in all options");
|
||||
int idx = static_cast<int>(std::distance(options.begin(), it));
|
||||
selectedOptionsIndices.push_back(idx);
|
||||
}
|
||||
|
||||
int activeTextures = std::min(static_cast<int>(selectedOptions.size()), MaxTextures);
|
||||
int activeTransferfunctions = std::min(
|
||||
static_cast<int>(_transferFunctions.size()),
|
||||
@@ -201,7 +218,7 @@ void DataCygnet::setTextureUniforms() {
|
||||
// Set Textures
|
||||
ghoul::opengl::TextureUnit txUnits[MaxTextures];
|
||||
int j = 0;
|
||||
for (int option : selectedOptions) {
|
||||
for (int option : selectedOptionsIndices) {
|
||||
if (_textures[option]) {
|
||||
txUnits[j].activate();
|
||||
_textures[option]->bind();
|
||||
@@ -215,7 +232,7 @@ void DataCygnet::setTextureUniforms() {
|
||||
}
|
||||
|
||||
if (activeTextures > 0 &&
|
||||
selectedOptions.back() >= static_cast<int>(_transferFunctions.size()))
|
||||
selectedOptionsIndices.back() >= static_cast<int>(_transferFunctions.size()))
|
||||
{
|
||||
activeTransferfunctions = 1;
|
||||
}
|
||||
@@ -230,7 +247,7 @@ void DataCygnet::setTextureUniforms() {
|
||||
_shader->setUniform("transferFunctions[0]", tfUnits[0]);
|
||||
}
|
||||
else {
|
||||
for (int option : selectedOptions) {
|
||||
for (int option : selectedOptionsIndices) {
|
||||
if (static_cast<int>(_transferFunctions.size()) >= option) {
|
||||
tfUnits[j].activate();
|
||||
_transferFunctions[option].bind();
|
||||
@@ -277,7 +294,7 @@ void DataCygnet::fillOptions(const std::string& source) {
|
||||
);
|
||||
|
||||
for (int i = 0; i < static_cast<int>(options.size()); i++) {
|
||||
_dataOptions.addOption({ i, options[i] });
|
||||
_dataOptions.addOption(options[i]);
|
||||
_textures.push_back(nullptr);
|
||||
}
|
||||
|
||||
@@ -288,7 +305,7 @@ void DataCygnet::fillOptions(const std::string& source) {
|
||||
_dataOptions.setValue(g->dataOptionsValue());
|
||||
}
|
||||
else {
|
||||
_dataOptions.setValue(std::vector<int>(1, 0));
|
||||
_dataOptions.setValue({ options.front() });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +349,13 @@ void DataCygnet::subscribeToGroup() {
|
||||
[&](const ghoul::Dictionary& dict) {
|
||||
LDEBUG(identifier() + " Event dataOptionsChanged");
|
||||
if (dict.hasValue<std::vector<int>>("dataOptions")) {
|
||||
_dataOptions = dict.value<std::vector<int>>("dataOptions");
|
||||
std::vector<int> idx = dict.value<std::vector<int>>("dataOptions");
|
||||
std::vector<std::string> opts = _dataOptions.options();
|
||||
std::set<std::string> selected;
|
||||
for (int i : idx) {
|
||||
selected.insert(opts[i]);
|
||||
}
|
||||
_dataOptions = selected;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -166,23 +166,23 @@ void IswaDataGroup::registerProperties() {
|
||||
_dataOptions.onChange([this]() {
|
||||
LDEBUG("Group " + identifier() + " published dataOptionsChanged");
|
||||
ghoul::Dictionary dict;
|
||||
dict.setValue("dataOptions", _dataOptions.value());
|
||||
std::set<std::string> set = _dataOptions;
|
||||
std::vector<std::string> vec(set.begin(), set.end());
|
||||
dict.setValue("dataOptions", vec);
|
||||
_groupEvent.publish("dataOptionsChanged", dict);
|
||||
});
|
||||
}
|
||||
|
||||
void IswaDataGroup::registerOptions(
|
||||
const std::vector<properties::SelectionProperty::Option>& options)
|
||||
{
|
||||
void IswaDataGroup::registerOptions(const std::vector<std::string>& options) {
|
||||
if (!_registered) {
|
||||
registerProperties();
|
||||
}
|
||||
|
||||
if (_dataOptions.options().empty()) {
|
||||
for (properties::SelectionProperty::Option option : options) {
|
||||
_dataOptions.addOption({ option.value, option.description });
|
||||
for (const std::string& option : options) {
|
||||
_dataOptions.addOption(option);
|
||||
}
|
||||
_dataOptions.setValue(std::vector<int>(1, 0));
|
||||
_dataOptions.setValue({ options.front() });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ void IswaDataGroup::createDataProcessor() {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> IswaDataGroup::dataOptionsValue() const {
|
||||
std::set<std::string> IswaDataGroup::dataOptionsValue() const {
|
||||
return _dataOptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,8 @@ public:
|
||||
IswaDataGroup(std::string name, std::string type);
|
||||
~IswaDataGroup();
|
||||
|
||||
void registerOptions(
|
||||
const std::vector<properties::SelectionProperty::Option>& options);
|
||||
std::vector<int> dataOptionsValue() const;
|
||||
void registerOptions(const std::vector<std::string>& options);
|
||||
std::set<std::string> dataOptionsValue() const;
|
||||
|
||||
protected:
|
||||
void registerProperties();
|
||||
|
||||
@@ -67,7 +67,7 @@ void IswaKameleonGroup::clearGroup() {
|
||||
clearFieldlines();
|
||||
}
|
||||
|
||||
std::vector<int> IswaKameleonGroup::fieldlineValue() const {
|
||||
std::set<std::string> IswaKameleonGroup::fieldlineValue() const {
|
||||
return _fieldlines;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ void IswaKameleonGroup::readFieldlinePaths(const std::string& indexFile) {
|
||||
int i = 0;
|
||||
|
||||
for (json::iterator it = fieldlines.begin(); it != fieldlines.end(); ++it) {
|
||||
_fieldlines.addOption({ i, it.key() });
|
||||
_fieldlines.addOption(it.key());
|
||||
_fieldlineState[i] = std::make_tuple<std::string, std::string, bool>(
|
||||
identifier() + "/" + it.key(),
|
||||
it.value(),
|
||||
@@ -137,14 +137,16 @@ void IswaKameleonGroup::readFieldlinePaths(const std::string& indexFile) {
|
||||
}
|
||||
|
||||
void IswaKameleonGroup::updateFieldlineSeeds() {
|
||||
const std::vector<int>& options = _fieldlines.value();
|
||||
const std::set<std::string>& options = _fieldlines;
|
||||
std::vector<std::string> opts = _fieldlines.options();
|
||||
|
||||
// SeedPath == map<int selectionValue, tuple<string name, string path, bool active>>
|
||||
using K = int;
|
||||
using V = std::tuple<std::string, std::string, bool>;
|
||||
for (std::pair<const K, V>& seedPath : _fieldlineState) {
|
||||
// if this option was turned off
|
||||
const auto it = std::find(options.begin(), options.end(), seedPath.first);
|
||||
std::string o = opts[seedPath.first];
|
||||
const auto it = std::find(options.begin(), options.end(), o);
|
||||
if (it == options.end() && std::get<2>(seedPath.second)) {
|
||||
LDEBUG("Removed fieldlines: " + std::get<0>(seedPath.second));
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
|
||||
virtual void clearGroup() override;
|
||||
|
||||
std::vector<int> fieldlineValue() const;
|
||||
std::set<std::string> fieldlineValue() const;
|
||||
void setFieldlineInfo(std::string fieldlineIndexFile, std::string kameleonPath);
|
||||
void changeCdf(std::string path);
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ KameleonPlane::~KameleonPlane() {}
|
||||
|
||||
void KameleonPlane::deinitializeGL() {
|
||||
IswaCygnet::deinitialize();
|
||||
_fieldlines = std::vector<int>();
|
||||
_fieldlines = std::set<std::string>();
|
||||
}
|
||||
|
||||
void KameleonPlane::initializeGL() {
|
||||
@@ -268,16 +268,16 @@ void KameleonPlane::setUniforms() {
|
||||
}
|
||||
|
||||
void KameleonPlane::updateFieldlineSeeds() {
|
||||
std::vector<int> selectedOptions = _fieldlines.value();
|
||||
std::set<std::string> selectedOptions = _fieldlines;
|
||||
std::vector<std::string> opts = _fieldlines.options();
|
||||
|
||||
// seedPath == map<int selectionValue, tuple<string name, string path, bool active>>
|
||||
for (auto& seedPath : _fieldlineState) {
|
||||
using K = int;
|
||||
using V = std::tuple<std::string, std::string, bool>;
|
||||
for (std::pair<const K, V>& seedPath : _fieldlineState) {
|
||||
// if this option was turned off
|
||||
const auto it = std::find(
|
||||
selectedOptions.begin(),
|
||||
selectedOptions.end(),
|
||||
seedPath.first
|
||||
);
|
||||
std::string o = opts[seedPath.first];
|
||||
const auto it = std::find(selectedOptions.begin(), selectedOptions.end(), o);
|
||||
if (it == selectedOptions.end() && std::get<2>(seedPath.second)) {
|
||||
SceneGraphNode* n = global::renderEngine->scene()->sceneGraphNode(
|
||||
std::get<0>(seedPath.second)
|
||||
@@ -336,7 +336,7 @@ void KameleonPlane::readFieldlinePaths(const std::string& indexFile) {
|
||||
const std::string& fullName = identifier();
|
||||
std::string partName = fullName.substr(0,fullName.find_last_of("-"));
|
||||
for (json::iterator it = fieldlines.begin(); it != fieldlines.end(); ++it) {
|
||||
_fieldlines.addOption({i, it.key()});
|
||||
_fieldlines.addOption(it.key());
|
||||
_fieldlineState[i] = std::make_tuple<std::string, std::string, bool>(
|
||||
partName + "/" + it.key(),
|
||||
it.value(),
|
||||
|
||||
@@ -73,11 +73,10 @@ void DataProcessorJson::addDataValues(const std::string& data,
|
||||
|
||||
std::vector<float> sum(numOptions, 0.f);
|
||||
std::vector<std::vector<float>> optionValues(numOptions, std::vector<float>());
|
||||
const std::vector<properties::SelectionProperty::Option>& options =
|
||||
dataOptions.options();
|
||||
const std::vector<std::string>& options = dataOptions.options();
|
||||
|
||||
for (int i = 0; i < numOptions; ++i) {
|
||||
const json& row = variables[options[i].description];
|
||||
const json& row = variables[options[i]];
|
||||
// int rowsize = row.size();
|
||||
|
||||
for (size_t y = 0; y < row.size(); ++y) {
|
||||
@@ -108,18 +107,23 @@ std::vector<float*> DataProcessorJson::processData(const std::string& data,
|
||||
const json& j = json::parse(data);
|
||||
json variables = j["variables"];
|
||||
|
||||
const std::vector<int>& selectedOptions = optionProp;
|
||||
|
||||
const std::vector<properties::SelectionProperty::Option>& options =
|
||||
optionProp.options();
|
||||
const std::set<std::string>& selectedOptions = optionProp;
|
||||
const std::vector<std::string>& options = optionProp.options();
|
||||
std::vector<int> selectedOptionsIndices;
|
||||
for (const std::string& option : selectedOptions) {
|
||||
auto it = std::find(options.begin(), options.end(), option);
|
||||
ghoul_assert(it != options.end(), "Selected option must be in all options");
|
||||
int idx = static_cast<int>(std::distance(options.begin(), it));
|
||||
selectedOptionsIndices.push_back(idx);
|
||||
}
|
||||
|
||||
std::vector<float*> dataOptions(options.size(), nullptr);
|
||||
for (int option : selectedOptions) {
|
||||
for (int option : selectedOptionsIndices) {
|
||||
// @CLEANUP: This memory is very easy to lose and should be replaced by some
|
||||
// other mechanism (std::vector<float> most likely)
|
||||
dataOptions[option] = new float[dimensions.x * dimensions.y] { 0.f };
|
||||
|
||||
json row = variables[options[option].description];
|
||||
json row = variables[options[option]];
|
||||
const int rowsize = static_cast<int>(row.size());
|
||||
|
||||
for (int y = 0; y < rowsize; ++y) {
|
||||
@@ -135,7 +139,7 @@ std::vector<float*> DataProcessorJson::processData(const std::string& data,
|
||||
}
|
||||
}
|
||||
|
||||
calculateFilterValues(selectedOptions);
|
||||
calculateFilterValues(selectedOptionsIndices);
|
||||
return dataOptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,15 +80,14 @@ void DataProcessorKameleon::addDataValues(const std::string& path,
|
||||
|
||||
std::vector<float> sum(numOptions, 0.f);
|
||||
std::vector<std::vector<float>> optionValues(numOptions, std::vector<float>());
|
||||
const std::vector<properties::SelectionProperty::Option>& options =
|
||||
dataOptions.options();
|
||||
const std::vector<std::string>& options = dataOptions.options();
|
||||
|
||||
const int numValues = static_cast<int>(_dimensions.x * _dimensions.y * _dimensions.z);
|
||||
|
||||
for (int i = 0; i < numOptions; ++i) {
|
||||
//0.5 to gather interesting values for the normalization/histograms.
|
||||
float* values = _kw->uniformSliceValues(
|
||||
options[i].description,
|
||||
options[i],
|
||||
_dimensions,
|
||||
0.5f
|
||||
);
|
||||
@@ -120,17 +119,22 @@ std::vector<float*> DataProcessorKameleon::processData(const std::string& path,
|
||||
initializeKameleonWrapper(path);
|
||||
}
|
||||
|
||||
const std::vector<int>& selectedOptions = optionProp;
|
||||
|
||||
const std::vector<properties::SelectionProperty::Option>& options =
|
||||
optionProp.options();
|
||||
const std::set<std::string>& selectedOptions = optionProp;
|
||||
const std::vector<std::string>& options = optionProp.options();
|
||||
std::vector<int> selectedOptionsIndices;
|
||||
for (const std::string& option : selectedOptions) {
|
||||
auto it = std::find(options.begin(), options.end(), option);
|
||||
ghoul_assert(it != options.end(), "Selected option must be in all options");
|
||||
int idx = static_cast<int>(std::distance(options.begin(), it));
|
||||
selectedOptionsIndices.push_back(idx);
|
||||
}
|
||||
|
||||
const int numValues = static_cast<int>(glm::compMul(dimensions));
|
||||
|
||||
std::vector<float*> dataOptions(numOptions, nullptr);
|
||||
for (int option : selectedOptions) {
|
||||
for (int option : selectedOptionsIndices) {
|
||||
dataOptions[option] = _kw->uniformSliceValues(
|
||||
options[option].description,
|
||||
options[option],
|
||||
dimensions,
|
||||
_slice
|
||||
);
|
||||
@@ -141,7 +145,7 @@ std::vector<float*> DataProcessorKameleon::processData(const std::string& path,
|
||||
}
|
||||
}
|
||||
|
||||
calculateFilterValues(selectedOptions);
|
||||
calculateFilterValues(selectedOptionsIndices);
|
||||
return dataOptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,10 @@ std::vector<float*> DataProcessorText::processData(const std::string& data,
|
||||
properties::SelectionProperty& options,
|
||||
glm::size3_t& dimensions)
|
||||
{
|
||||
// The update of the selection properties broke this and we don't have the data to
|
||||
// actually test whether this update works. So if you are getting a crash around here
|
||||
// this is why
|
||||
|
||||
if (data.empty()) {
|
||||
return std::vector<float*>();
|
||||
}
|
||||
@@ -149,11 +153,20 @@ std::vector<float*> DataProcessorText::processData(const std::string& data,
|
||||
std::string line;
|
||||
std::stringstream memorystream(data);
|
||||
|
||||
const std::vector<int>& selectedOptions = options.value();
|
||||
const std::set<std::string>& selectedOptions = options.value();
|
||||
const std::vector<std::string>& allOptions = options.options();
|
||||
std::vector<int> selectedOptionsIndices;
|
||||
|
||||
std::vector<float*> dataOptions(options.options().size(), nullptr);
|
||||
for (int o : selectedOptions) {
|
||||
dataOptions[o] = new float[dimensions.x * dimensions.y] { 0.f };
|
||||
for (const std::string& o : selectedOptions) {
|
||||
auto it = std::find(allOptions.begin(), allOptions.end(), o);
|
||||
ghoul_assert(
|
||||
it != allOptions.end(),
|
||||
"Selected option must be in list of all options"
|
||||
);
|
||||
int idx = static_cast<int>(std::distance(allOptions.begin(), it));
|
||||
selectedOptionsIndices.push_back(idx);
|
||||
dataOptions[idx] = new float[dimensions.x * dimensions.y] { 0.f };
|
||||
}
|
||||
|
||||
int numValues = 0;
|
||||
@@ -172,11 +185,11 @@ std::vector<float*> DataProcessorText::processData(const std::string& data,
|
||||
last = (last > 0)? last : lineSize;
|
||||
|
||||
const auto it = std::find(
|
||||
selectedOptions.begin(),
|
||||
selectedOptions.end(),
|
||||
selectedOptionsIndices.begin(),
|
||||
selectedOptionsIndices.end(),
|
||||
option
|
||||
);
|
||||
if (option >= 0 && it != selectedOptions.end()) {
|
||||
if (option >= 0 && it != selectedOptionsIndices.end()) {
|
||||
const float value = std::stof(line.substr(first, last));
|
||||
dataOptions[option][numValues] = processDataPoint(value, option);
|
||||
}
|
||||
@@ -187,9 +200,10 @@ std::vector<float*> DataProcessorText::processData(const std::string& data,
|
||||
numValues++;
|
||||
}
|
||||
|
||||
calculateFilterValues(selectedOptions);
|
||||
calculateFilterValues(selectedOptionsIndices);
|
||||
|
||||
return dataOptions;
|
||||
//#endif
|
||||
}
|
||||
|
||||
} //namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user