-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse.h
More file actions
157 lines (135 loc) · 3.45 KB
/
Copy pathresponse.h
File metadata and controls
157 lines (135 loc) · 3.45 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* Class structure to parse output pallet configuration for a mixed pallet.
* KUKA output file definition for orders is used here.
*
* Author: Pushkar Kolhe
*/
#ifndef RESPONSE_H_
#define RESPONSE_H_
#include "packlist.h"
#include <vector>
class Point {
public:
int x;
int y;
int z;
Point() {}
~Point() {}
int parse(std::string data);
std::string xml(const char* name);
void set(int _x, int _y, int _z) {
x = _x; y = _y; z = _z;
}
Point add(Point d) {
Point a;
a.x = x+d.x; a.y = y+d.y; a.z = z+d.z;
return a;
}
Point subtract(Point d) {
Point a;
a.x = x-d.x; a.y = y-d.y; a.z = z-d.z;
return a;
}
Point mult(float n) {
Point a;
a.x = x*n; a.y = y*n; a.z = z*n;
return a;
}
};
class Package {
public:
unsigned int pack_sequence;
unsigned int incoming_sequence;
unsigned int orderlineno;
unsigned int parent_layer;
Article article;
Barcode barcode;
Point place_position;
unsigned int orientation;
Point approach_point_1;
Point approach_point_2;
Point approach_point_3;
unsigned int stack_height_before;
double normal_force;
double min_x, max_x, min_y, max_y, z;
std::vector<Package> connect;
Package() {};
~Package() {};
int parse(std::string data);
std::string xml();
void find_boundaries() {
double l, w;
if(orientation == 1) {
l = (double) article.length;
w = (double) article.width;
}
else {
l = (double) article.width;
w = (double) article.length;
}
min_x = place_position.x - l/2.0f;
max_x = place_position.x + l/2.0f;
min_y = place_position.y - w/2.0f;
max_y = place_position.y + w/2.0f;
z = place_position.z - article.height/2.0f;
}
};
class Dimensions {
public:
unsigned int length;
unsigned int width;
unsigned int max_load_weight;
unsigned int max_load_height;
Dimensions() {}
~Dimensions() {}
int parse(std::string data);
std::string xml();
};
class PackPallet {
public:
unsigned int pallet_number;
unsigned int brutto_weight;
unsigned int number_of_packages;
std::string description;
Dimensions dimension;
std::vector<Package> package;
PackPallet() {};
~PackPallet() {};
unsigned int n_package() { return package.size(); }
int parse(std::string data);
std::string xml();
// Call once
// Might be deprecated! Haven't used this for a while (Remove from viewer.cpp)
void find_normals() {
for(int i = n_package()-1; i >= 0; i--) {
package[i].normal_force = 0.0f;
package[i].normal_force += package[i].article.weight;
for(unsigned int j = i+1; j < n_package(); j++) {
// All packages above this one
if(package[j].z > package[i].z) {
double s = 0.1f, len = 0.0f, wid = 0.0f;
for(double l = 0; l < dimension.length; l+=s)
if( (package[i].min_x <= l && l <= package[i].max_x) && (package[j].min_x <= l && l <= package[j].max_x)) len += s;
for(double w = 0; w < dimension.width ; w+=s)
if( (package[i].min_y <= w && w <= package[i].max_y) && (package[j].min_y <= w && w <= package[j].max_y) ) wid += s;
double area = len*wid;
if(area > 0) package[j].connect.push_back(package[i]);
package[i].normal_force += package[j].normal_force*area;
}
}
}
}
};
class PackList {
public:
unsigned int order_id;
std::vector<PackPallet> packpallet;
PackList() {};
~PackList() {};
unsigned int n_packpallet() { return packpallet.size(); }
int parse(std::string data);
std::string xml();
};
PackList read_response(const char* filename, int debug);
void write_response(PackList list, const char* filename);
#endif /* RESPONSE_H_ */