-
Notifications
You must be signed in to change notification settings - Fork 9
/
numberandcoordinate.cpp
116 lines (98 loc) · 2.25 KB
/
numberandcoordinate.cpp
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
#include <stdio.h>
#include <vector>
#include <algorithm>
#include "numberandcoordinate.h"
#include "convertcoordinate.h"
void numberandcoordinate::sortEntries()
{
std::sort(inputList.begin(), inputList.end(), numberandcoordinate::compareWidthCooord);
}
void numberandcoordinate::addEntry(pinpair& numberAndCoords)
{
int itype = numberAndCoords[TYPE];
//increase the number of Astates by one or zero
nrAStates += (1 - itype);
nrYStates += itype;
//compute min/max inj coordinate
if (numberAndCoords[ROWCOORD] < minInjRow)
{
minInjRow = numberAndCoords[ROWCOORD];
}
if (numberAndCoords[ROWCOORD] > maxInjRow)
{
maxInjRow = numberAndCoords[ROWCOORD];
}
inputList.push_back(numberAndCoords);
}
int numberandcoordinate::size()
{
return inputList.size();
}
int numberandcoordinate::getIOType(int idx)
{
return inputList[idx][TYPE];
}
pinpair::pinpair()
{
id = FAKEID;
type = ATYPE;
hasSourceAndDestinationReversed = false;
allowConnectionThroughChannel = false;
};
pinpair::pinpair(const pinpair& other)
{
pins[0]= other.pins[0];
pins[1]= other.pins[1];
id = other.id;
type = other.type;
hasSourceAndDestinationReversed = other.hasSourceAndDestinationReversed;
allowConnectionThroughChannel = other.allowConnectionThroughChannel;
};
pinpair& pinpair::operator=(const pinpair& other)
{
pins[0] = other.pins[0];
pins[1] = other.pins[1];
id = other.id;
type = other.type;
hasSourceAndDestinationReversed = other.hasSourceAndDestinationReversed;
allowConnectionThroughChannel = other.allowConnectionThroughChannel;
return *this;
};
long& pinpair::operator[](int i)
{
if(i == TYPE)
{
return type;
}
else if(i == INJNR)
{
return id;
}
int coordnr = (i - OFFSETNONCOORD) / 3;
int coordidx = (i - OFFSETNONCOORD) % 3;
return pins[coordnr].coord[coordidx];
};
void pinpair::setPinDetail(int idx, pindetails& c)
{
pins[idx] = c;
};
pindetails& pinpair::getPinDetail(int idx)
{
return pins[idx];
}
long pinpair::minDistBetweenPins()
{
return pins[0].coord.manhattanDistance(pins[1].coord);
}
bool pinpair::isColinear()
{
return pins[0].coord.isColinear(pins[1].coord);
}
int pinpair::getType()
{
return type;
}
//void pindetails::addPinBlock(int offset, int direction, int distance)
//{
// addPinBlock(offset, direction, distance, false);
//}