// Gmsh project created on Thu Oct 19 12:19:17 2017

SetFactory("OpenCASCADE");

Cylinder(1) = {-0.08, 0.20, 0, 0.08, 0, 0, 0.04, 2*Pi};

Box(2) = {-0.58, -0.25, -0.25, 0.5, 0.5, 0.5};

Delete {
  Volume{1}; Volume{2}; 
}

Delete {
  Surface{5}; Surface{3}; 
}
Delete {
  Surface{2}; 
}

Line Loop(10) = {9, -10, -11, 8};
Line Loop(11) = {3};
Plane Surface(10) = {10, 11};

Box(1) = {-0.5, 0.4, -0.26, 1.5, 0.5, 0.01};
Delete {
  Volume{1}; 
}

////////////////////////////////////////////////////////////////

p1 = newp;
lref = 1.0;
 
Point(p1+ 1)={  0.000,  0.2000,  0.0000, lref};
Point(p1+ 2)={  0.000,  0.2000,  0.0210, lref};
Point(p1+ 3)={  0.000,  0.2000,  0.0310, lref};
Point(p1+ 4)={  0.000,  0.2000, -0.0210, lref};
Point(p1+ 5)={  0.000,  0.2000, -0.0310, lref};
Point(p1+ 6)={  0.000,  0.2210,  0.0000, lref};
Point(p1+ 7)={  0.000,  0.2310,  0.0000, lref};
Point(p1+ 8)={  0.000, 0.2-0.0210,  0.0000, lref};
Point(p1+ 9)={  0.000, 0.2-0.0310,  0.0000, lref};

Circle(28) = {22, 20, 26};
Circle(29) = {26, 20, 24};
Circle(30) = {24, 20, 28};
Circle(31) = {28, 20, 22};
Circle(32) = {21, 20, 25};
Circle(33) = {25, 20, 23};
Circle(34) = {23, 20, 27};
Circle(35) = {27, 20, 21};
Line(36) = {22, 21};
Line(37) = {26, 25};
Line(38) = {24, 23};
Line(39) = {28, 27};

Line Loop(19) = {32, 33, 34, 35};
Plane Surface(17) = {19};

Line Loop(20) = {31, 36, -35, -39};
Plane Surface(18) = {20};

Line Loop(21) = {39, -34, -38, 30};
Plane Surface(19) = {21};

Line Loop(22) = {33, -38, -29, 37};
Plane Surface(20) = {22};

Line Loop(23) = {37, -32, -36, 28};
Plane Surface(21) = {23};

Line Loop(24) = {1};
Line Loop(25) = {31, 28, 29, 30};
Plane Surface(22) = {24, 25};

Box(1) = {-1, -0.4, -0.8, 3, 2.0, 2};
Delete {
  Volume{1}; 
}

////////////////////////////////////////////////////////////////

Physical Surface(100) = {7, 9, 6, 8, 4, 10, 1, 22, 17};
Physical Surface(101) = {21, 18, 19, 20};
Physical Surface(102) = {16};
Physical Surface(103) = {15, 11, 14, 13, 12};
Physical Surface(104) = {28, 23, 27, 24, 25, 26};

////////////////////////////////////////////////////////////////

Transfinite Line {9, 8, 11, 10, 15, 13, 12, 14} = 10 Using Progression 1;
Transfinite Line {5, 6, 7, 4} = 8 Using Progression 1;
Transfinite Line {3} = 10 Using Progression 1;
Transfinite Line {32, 35, 34, 33} = 8 Using Progression 1;
Transfinite Line {28, 31, 30, 29} = 10 Using Progression 1;
Transfinite Line {1} = 24 Using Progression 1;
Transfinite Line {27, 25, 24, 27, 26} = 40 Using Progression 1;
Transfinite Line {21, 23, 17, 19} = 13 Using Progression 1;
Transfinite Line {51, 49, 50, 48} = 30 Using Progression 1;
Transfinite Line {45, 44, 47, 46} = 25 Using Progression 1;
Transfinite Line {42, 41, 40, 43} = 20 Using Progression 1;
Transfinite Line {37, 36, 39, 38} = 3 Using Progression 1;
Transfinite Line {2} = 7 Using Progression 0.9;
Transfinite Surface {16};

////////////////////////////////////////////////////////////////

Surface Loop(5) = {28, 23, 25, 27, 26, 24};
Surface Loop(6) = {9, 4, 6, 8, 7, 10, 1, 22, 18, 21, 20, 17, 19};
Surface Loop(7) = {15, 11, 13, 12, 16, 14};
Volume(1) = {5, 6, 7};
Physical Volume(999) = {1};

//////////////////////////////////////////////////////////////////

tmp[] = Physical Surface {102,103};

Rotate {{1, 0, 0}, {-0.5, 0.65, -0.25}, Pi/6} {
  Surface { tmp[] }; 
}
