-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputLayer.cpp
More file actions
77 lines (59 loc) · 1.51 KB
/
InputLayer.cpp
File metadata and controls
77 lines (59 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// Created by Kejsty, Katarina Kejstova on 26.11.16.
//
#include <sstream>
#include "InputLayer.h"
//INPUT LAYER
InputLayer::InputLayer( const std::string &path ) : currentValues(3) , input(path){
if (!input.good())
throw InvalidInputFileException("Unable to open input file " + path);
double x,y,e;
std::string line;
while (input.good()) {
getline(input, line);
std::stringstream buffer(line);
buffer >> x >> y >> e;
_x.push(x);
_y.push(y);
_e.push(e);
if(e == 1.0)
break;
}
}
void InputLayer::loadData( const std::string &path ) {
input.close();
input.open(path);
if (!input.good())
throw InvalidInputFileException("Unable to open input file " + path);
loadData();
}
void InputLayer::loadData( ) {
double x,y,e;
std::string line;
while (input.good()) {
getline(input, line);
std::stringstream buffer(line);
buffer >> x >> y >> e;
_x.push(x);
_y.push(y);
_e.push(e);
if(e == 1.0)
break;
}
}
bool InputLayer::eval( ) {
currentValues[0] = _x.front( );
_x.pop();
currentValues[1] = _y.front( );
_y.pop();
currentValues[2] = _e.front( );
_e.pop();
if (currentValues[2] == 1) {
#if PRINT
std::cout << "End of stroke point : " << currentValues[0] << ", " << currentValues[1] << ", " << currentValues[2] << std::endl;
#endif
loadData();
return true;
}
return false;
}