File indexing completed on 2024-04-06 12:30:06
0001 #include <algorithm>
0002 #include <cmath>
0003 #include <iomanip>
0004 #include <iostream>
0005 #include <fstream>
0006 #include <string>
0007 #include <vector>
0008
0009 class HexGeometry {
0010
0011 public :
0012 HexGeometry(bool fine);
0013 virtual ~HexGeometry() {}
0014
0015 void initCellGeom(bool fine);
0016 void initWaferGeom();
0017
0018 std::pair<double,double> position_cell(const int cell);
0019 std::pair<double,double> position_wafer(const int wafer);
0020 std::pair<double,double> cellGC(const int cell, const int wafer);
0021
0022
0023 private :
0024 std::vector<std::pair<double,double> > xypos_cell;
0025 std::vector<std::pair<double,double> > xypos_wafer;
0026
0027 };
0028
0029 HexGeometry::HexGeometry(bool fine) {
0030
0031 initCellGeom(fine);
0032 initWaferGeom();
0033
0034 }
0035
0036
0037
0038 void HexGeometry::initCellGeom(bool fine){
0039 const int nC(15), nF(20);
0040
0041 int nCoarse(11), nyCoarse(21), nFine(15), nyFine(28);
0042 int cellCoarse[nC] = {2,5,8,11,12,11,12,11,12,11,12,11,8,5,2};
0043 int cellFine[nF] = {3,6,9,12,15,16,15,16,15,16,15,16,15,16,15,14,11,8,5,2};
0044 double wafer(123.7);
0045
0046 int rows = (fine) ? nF : nC;
0047 double cell = (fine) ? wafer/nFine : wafer/nCoarse;
0048 double dx = 0.5*cell;
0049
0050 double dy = 0.5*cell*tan(30.0*M_PI/180.0);
0051 int ny = (fine) ? nyFine : nyCoarse;
0052
0053
0054 for (int ir = 0; ir < rows; ++ir) {
0055 int column = (fine) ? cellFine[ir] : cellCoarse[ir];
0056 int nx = 1 - column;
0057 double ypos = dy*ny;
0058 for (int ic = 0; ic<column; ++ic) {
0059 double xpos = dx*nx;
0060 nx += 2;
0061
0062 xypos_cell.push_back(std::pair<double,double>(ypos,xpos));
0063 }
0064
0065 ny -= 3;
0066 }
0067
0068 std::cout << "Initialize HexGeometry for " << xypos_cell.size() << " cells"
0069 << std::endl;
0070
0071
0072
0073
0074
0075 }
0076
0077
0078
0079 void HexGeometry::initWaferGeom(){
0080 const int nwafer = 7;
0081 const int wafer[nwafer] = {0, 110101, 100101, 10002, 2, 10101, 101};
0082 const double wafersize = 124.7;
0083
0084
0085
0086 double dy = 0.5*wafersize;
0087 double dx = 1.5*wafersize*tan(30.0*M_PI/180.0);
0088 for (int i = 0; i < nwafer; ++i) {
0089 int ix = (wafer[i]/100) % 100;
0090 if (((wafer[i]/100000)%10) == 0) ix = -ix;
0091 int iy = wafer[i] % 100;
0092 if (((wafer[i]/10000)%10) == 1) iy = -iy;
0093 double xx = ix * dx;
0094 double yy = iy * dy;
0095
0096
0097 xypos_wafer.push_back(std::pair<double,double>(xx,yy));
0098 }
0099 std::cout << "Initialize HexGeometry for " << xypos_wafer.size() << " wafers"
0100 << std::endl;
0101
0102
0103
0104
0105
0106
0107
0108 }
0109
0110
0111 std::pair<double,double> HexGeometry::position_cell(const int cell) {
0112 std::pair<double,double> xy;
0113 if (cell >= 0 && cell < (int)(xypos_cell.size())) {
0114 xy = xypos_cell[cell];
0115 } else {
0116 xy = std::pair<double,double>(0,0);
0117 }
0118 return xy;
0119 }
0120
0121
0122 std::pair<double,double> HexGeometry::position_wafer(const int wafer) {
0123 std::pair<double,double> xy;
0124 if (wafer >= 0 && wafer < (int)(xypos_wafer.size())) {
0125 xy = xypos_wafer[wafer];
0126 } else {
0127 xy = std::pair<double,double>(0,0);
0128 }
0129
0130
0131 return xy;
0132 }
0133
0134
0135 std::pair<double,double> HexGeometry::cellGC(const int cell, const int wafer) {
0136 std::pair<double,double> xy;
0137 if (wafer >= 0 && wafer < (int)(xypos_wafer.size())) {
0138
0139 double x = position_cell(cell).first + position_wafer(wafer).first;
0140 double y = position_cell(cell).second + position_wafer(wafer).second;
0141
0142 xy = std::pair<double,double>(x,y);
0143 } else {
0144 xy = std::pair<double,double>(0,0);
0145 }
0146 std::cout << "X : Y : " << xy.first << " " << xy.second << std::endl;
0147 return xy;
0148 }
0149
0150
0151
0152
0153
0154 void testGeometry() {
0155
0156 HexGeometry geomc(false);
0157 for (int k = 0; k < 133; ++k) {
0158 std::pair<double,double> xy = geomc.position_cell(k);
0159 std::cout << "Coarse Cell[" << k << "] " << xy.first << ":" << xy.second
0160 << std::endl;
0161 }
0162
0163
0164 for (int k = 0; k < 7; ++k) {
0165 std::pair<double,double> xy_w = geomc.position_wafer(k);
0166 std::cout << "Wafer[" << k << "] " << xy_w.first << ":" << xy_w.second
0167 << std::endl;
0168 }
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179 }