mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Faster processing in DataProcessorText
This commit is contained in:
@@ -33,12 +33,12 @@ function postInitialization()
|
||||
|
||||
--openspace.iswa.addCygnet(7);
|
||||
|
||||
openspace.iswa.addCygnet(-4,"Data","Gm");
|
||||
openspace.iswa.addCygnet(-5,"Data","Gm");
|
||||
openspace.iswa.addCygnet(-6,"Data","Gm");
|
||||
openspace.iswa.addCygnet(-7,"Data","Gm");
|
||||
openspace.iswa.addCygnet(-8,"Data","Gm");
|
||||
openspace.iswa.addCygnet(-9,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-4,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-5,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-6,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-7,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-8,"Data","Gm");
|
||||
--openspace.iswa.addCygnet(-9,"Data","Gm");
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -184,6 +184,7 @@ void DataProcessor::add(std::vector<std::vector<float>>& optionValues, std::vect
|
||||
_numValues[i] += numValues;
|
||||
|
||||
_histograms[i]->generateEqualizer();
|
||||
// _histograms[i]->print();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,13 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <boost/iostreams/device/mapped_file.hpp>
|
||||
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix_core.hpp>
|
||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
||||
#include <boost/spirit/include/phoenix_stl.hpp>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "DataProcessorText";
|
||||
}
|
||||
@@ -115,12 +122,14 @@ void DataProcessorText::addDataValues(std::string data, properties::SelectionPro
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add(optionValues, sum);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<float*> DataProcessorText::processData(std::string data, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions){
|
||||
if(!data.empty()){
|
||||
|
||||
std::string line;
|
||||
std::stringstream memorystream(data);
|
||||
|
||||
@@ -136,26 +145,50 @@ std::vector<float*> DataProcessorText::processData(std::string data, properties:
|
||||
dataOptions[option] = new float[dimensions.x*dimensions.y]{0.0f};
|
||||
}
|
||||
|
||||
// FOR TESTING
|
||||
// ===========
|
||||
// std::chrono::time_point<std::chrono::system_clock> start, end;
|
||||
// start = std::chrono::system_clock::now();
|
||||
// ===========
|
||||
|
||||
int numValues = 0;
|
||||
while(getline(memorystream, line)){
|
||||
if(line.find("#") == 0) continue;
|
||||
|
||||
values = std::vector<float>();
|
||||
std::stringstream ss(line);
|
||||
copy(
|
||||
std::istream_iterator<float> (ss),
|
||||
std::istream_iterator<float> (),
|
||||
back_inserter(values)
|
||||
);
|
||||
|
||||
for(int option : selectedOptions){
|
||||
value = values[option+3]; //+3 because options x, y and z in the file
|
||||
dataOptions[option][numValues] = processDataPoint(value, option);
|
||||
int first = 0;
|
||||
int last = 0;
|
||||
int option = -3;
|
||||
int lineSize = line.size();
|
||||
|
||||
while(last < lineSize){
|
||||
|
||||
first = line.find_first_not_of(" \t", last);
|
||||
last = line.find_first_of(" \t", first);
|
||||
last = (last > 0)? last : lineSize;
|
||||
// boost::spirit::qi::parse(&line[first], &line[last], boost::spirit::qi::double_, value);
|
||||
value = std::stof(line.substr(first, last));
|
||||
|
||||
if(option >= 0 && std::find(selectedOptions.begin(), selectedOptions.end(), option) != selectedOptions.end())
|
||||
dataOptions[option][numValues] = processDataPoint(value, option);
|
||||
|
||||
option++;
|
||||
}
|
||||
|
||||
numValues++;
|
||||
}
|
||||
|
||||
calculateFilterValues(selectedOptions);
|
||||
|
||||
// FOR TESTING
|
||||
// ===========
|
||||
// end = std::chrono::system_clock::now();
|
||||
// std::chrono::duration<double> elapsed_seconds = end-start;
|
||||
// std::cout << "time: " << elapsed_seconds.count() << "\n";
|
||||
// ===========
|
||||
|
||||
|
||||
return dataOptions;
|
||||
}
|
||||
return std::vector<float*>();
|
||||
|
||||
@@ -88,9 +88,9 @@ void GuiIswaComponent::render() {
|
||||
|
||||
if(_gmdata != gmdatavalue){
|
||||
if(_gmdata){
|
||||
std::string x = "openspace.iswa.addCygnet(-1,'Data','GMData');";
|
||||
std::string y = "openspace.iswa.addCygnet(-2,'Data','GMData');";
|
||||
std::string z = "openspace.iswa.addCygnet(-3,'Data','GMData');";
|
||||
std::string x = "openspace.iswa.addCygnet(-4,'Data','GMData');";
|
||||
std::string y = "openspace.iswa.addCygnet(-5,'Data','GMData');";
|
||||
std::string z = "openspace.iswa.addCygnet(-6,'Data','GMData');";
|
||||
OsEng.scriptEngine().queueScript(x+y+z);
|
||||
}else{
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup('GMData');");
|
||||
@@ -99,9 +99,9 @@ void GuiIswaComponent::render() {
|
||||
|
||||
if(_gmimage != gmimagevalue){
|
||||
if(_gmimage){
|
||||
std::string x = "openspace.iswa.addCygnet(-1,'Texture','GMImage');";
|
||||
std::string y = "openspace.iswa.addCygnet(-2,'Texture','GMImage');";
|
||||
std::string z = "openspace.iswa.addCygnet(-3,'Texture','GMImage');";
|
||||
std::string x = "openspace.iswa.addCygnet(-4,'Texture','GMImage');";
|
||||
std::string y = "openspace.iswa.addCygnet(-5,'Texture','GMImage');";
|
||||
std::string z = "openspace.iswa.addCygnet(-6,'Texture','GMImage');";
|
||||
OsEng.scriptEngine().queueScript(x+y+z);
|
||||
}else{
|
||||
OsEng.scriptEngine().queueScript("openspace.iswa.removeGroup('GMImage');");
|
||||
|
||||
@@ -304,7 +304,7 @@ void Histogram::print() const {
|
||||
std::cout << i << " [" << low << ", " << high << "]"
|
||||
<< " " << _data[i] << std::endl;
|
||||
}
|
||||
std::cout << std::endl << std::endl << std::endl<< "==============" << std::endl;
|
||||
// std::cout << std::endl << std::endl << std::endl<< "==============" << std::endl;
|
||||
}
|
||||
|
||||
float Histogram::highestBinValue(bool equalized, int overBins){
|
||||
@@ -341,7 +341,6 @@ float Histogram::highestBinValue(bool equalized, int overBins){
|
||||
float high = low + (_maxValue - _minValue) / float(_numBins);
|
||||
|
||||
if(!equalized){
|
||||
std::cout << (high+low)/2.0 << std::endl;
|
||||
return (high+low)/2.0;
|
||||
}else{
|
||||
return equalize((high+low)/2.0);
|
||||
|
||||
Reference in New Issue
Block a user