Skip to content
Snippets Groups Projects
Commit 401f9b45 authored by t.knopff's avatar t.knopff
Browse files

Added handling of negative values of signed integers to get rid of warning

parent 56cac527
No related branches found
No related tags found
1 merge request!42Added handling of negative values of signed integers to get rid of warning
Pipeline #35313 passed
......@@ -21,8 +21,8 @@ OutputData<double>* OutputDataReadWriteNicos::readOutputData(std::istream& input
std::string line;
m_currentLineNr = 0;
int width = 0;
int height = 0;
unsigned int width = 0;
unsigned int height = 0;
// -- read dimensions
bool inFileSection = false;
......@@ -45,9 +45,9 @@ OutputData<double>* OutputDataReadWriteNicos::readOutputData(std::istream& input
}
if (StringUtils::startsWith(line, "DataSizeX"))
width = readAssignedIntValue(line);
width = std::max(readAssignedIntValue(line), 0);
else if (StringUtils::startsWith(line, "DataSizeY"))
height = readAssignedIntValue(line);
height = std::max(readAssignedIntValue(line), 0);
if (width != 0 && height != 0)
break;
......@@ -56,9 +56,11 @@ OutputData<double>* OutputDataReadWriteNicos::readOutputData(std::istream& input
if (!fileSectionFound)
throw std::runtime_error("Could not find 'File' section.");
if (width == 0)
throw std::runtime_error("Could not find 'DataSizeX' value.");
throw std::runtime_error
("Could not find 'DataSizeX' value or value is nonpositive.");
if (height == 0)
throw std::runtime_error("Could not find 'DataSizeY' value.");
throw std::runtime_error
("Could not find 'DataSizeY' value or value is nonpositive.");
result->addAxis("x", width, 0.0, width);
result->addAxis("y", height, 0.0, height);
......@@ -66,7 +68,7 @@ OutputData<double>* OutputDataReadWriteNicos::readOutputData(std::istream& input
// -- read data
bool inCountSection = false;
bool countSectionFound = false;
int dataRow = 0;
unsigned int dataRow = 0;
while (std::getline(input_stream, line)) {
m_currentLineNr++;
......@@ -98,7 +100,7 @@ OutputData<double>* OutputDataReadWriteNicos::readOutputData(std::istream& input
for (unsigned col = 0; col < width; ++col) {
const size_t global_index =
result->toGlobalIndex({col, static_cast<unsigned>(height) - 1
result->toGlobalIndex({col, height - 1
- dataRow}); // y-axis "0" is at bottom => invert y
// to show first line at top of image
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment