-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataLoader.cpp
More file actions
124 lines (106 loc) · 2.59 KB
/
Copy pathDataLoader.cpp
File metadata and controls
124 lines (106 loc) · 2.59 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
#include<iostream>
#include<fstream>
#include<cstdint>
#include<sstream>
#include<vector>
#include "DataLoader.h"
template<typename Ta,typename Tb>
static void range_to_value(std::string str,Ta &a,Tb &b)
{
str = str.substr(1);
str.pop_back();
for(char &c:str)
if(c==',')c=' ';
std::stringstream ss(str);
ss>>a>>b;
}
std::istream& operator>>(std::istream& in,DataSet::point &p)
{
std::string buf;
in>>buf;
range_to_value(buf,p.x,p.y);
return in;
}
std::ostream& operator<<(std::ostream& out,DataSet::point &p)
{
out<<'('<<p.x<<','<<p.y<<')';
return out;
}
static int rm_first_char(std::string s)
{
return std::stoi(s.substr(1));
}
void DataSet::load(std::istream &fin)
{
std::string buf;
std::stringstream ss;
auto getline_to_ss = [&](){
std::getline(fin,buf);
ss.clear();
ss.str(buf);
};
getline_to_ss(); //ViaCost
ss>>buf>>buf>>viacost;
getline_to_ss(); //Spacing
ss>>buf>>buf>>spacing;
getline_to_ss(); //Boundary
ss>>buf>>buf>>boundary.first>>boundary.second;
getline_to_ss(); //MetalLayers
ss>>buf>>buf>>metal_layers;
for(s32 i=1;i<=metal_layers;++i)
{
Obstacles[i].clear();
RoutedShape[i].clear();
RoutedVia[i].clear();
}
getline_to_ss();
ss>>buf>>buf>>routed_shapes;
getline_to_ss(); //RoutedVias
ss>>buf>>buf>>routed_vias;
getline_to_ss(); //Obstacles
ss>>buf>>buf>>obstacles;
DataSet::point tmp_point;
int lay;
for(s32 i=0;i<routed_shapes;++i)
{
getline_to_ss();
ss>>buf>>buf;
lay = rm_first_char(buf);
RoutedShape[lay].emplace_back(tmp_point,tmp_point);
ss>>RoutedShape[lay].back().first>>RoutedShape[lay].back().second;
}
for(s32 i=0;i<routed_vias;++i)
{
getline_to_ss();
ss>>buf>>buf;
lay = rm_first_char(buf);
RoutedVia[lay].emplace_back(tmp_point);
ss>>RoutedVia[lay].back();
}
for(s32 i=0;i<obstacles;++i)
{
getline_to_ss();
ss>>buf>>buf;
lay = rm_first_char(buf);
Obstacles[lay].emplace_back(tmp_point,tmp_point);
ss>>Obstacles[lay].back().first>>Obstacles[lay].back().second;
}
}
void DataSet::set_spacing_on_Obstacles()
{
boundary.first.x+=spacing;
boundary.first.y+=spacing;
boundary.second.x-=spacing;
boundary.second.y-=spacing;
for(s32 lay=1;lay<=metal_layers;++lay)
{
for(auto &obs:Obstacles[lay])
{
obs.first.x-=spacing;
obs.first.y-=spacing;
obs.second.x+=spacing;
obs.second.y+=spacing;
}
}
spacing=0;
}