lc = 0.05;
r1 = 0.6;
r2 = 0.7;
r3 = 1.0;
r4 = 1.5;
x1 = 0.15;
x2 = 0.3;
pas = 2;
teta = 45;

teta = teta*Pi/180;
teta1 = Asin(x1/r2);

dz1 = (pas/(2*Pi))*(teta-teta1);
dz2 = (pas/(2*Pi))*2*teta1;
dz3 = (pas/(2*Pi))*(2*Pi/3-teta1-teta);
dz4 = (pas/(2*Pi))*(2*Pi/3-2*teta1);

Point(1) = {0, 0, 0, lc};
Point(2) = {0, r1, 0, lc};
Point(3) = {0, r2, 0, lc};
Point(4) = {x1, Sqrt(r2*r2-x1*x1), 0, lc};
Point(5) = {x1, r3, 0, lc};
Point(6) = {x2, r3, 0, lc};
Point(7) = {x2, Sqrt(r4*r4-x2*x2), 0, lc};

Rotate {{0, 0, 1}, {0, 0, 0}, -teta} {Point{2, 3};}
Rotate {{0, 0, 1}, {0, 0, 0}, teta-teta1} {Duplicata { Point{2}; }}

Line(1) = {2, 3};
Line(2) = {4, 5};
Line(3) = {5, 6};
Line(4) = {6, 7};
Circle(5) = {3, 1, 4};
Circle(6) = {2, 1, 8};

Symmetry {1, 0, 0, 0} {Duplicata { Line{4, 3, 2, 5, 1, 6}; }}

Circle(13) = {7, 1, 10};
Circle(14) = {4, 1, 17};
Circle(15) = {8, 1, 32};

Line Loop(16) = {14, 9, 8, 7, -13, -4, -3, -2};
Plane Surface(17) = {16};

Rotate {{0, 0, 1}, {0, 0, 0}, 2*Pi/3} {Duplicata { Surface{17}; }}
Rotate {{0, 0, 1}, {0, 0, 0}, 2*Pi/3} {Duplicata { Surface{18}; }}

Circle(36) = {10, 1, 52};
Circle(37) = {47, 1, 80};
Circle(38) = {75, 1, 7};


Extrude {{0, 0, dz1},{0, 0, 1}, {0, 0, 0}, teta-teta1} {Point{3,2};}
Extrude {{0, 0, dz2},{0, 0, 1}, {0, 0, 0}, 2*teta1} {Point{93,98};}
Extrude {{0, 0, dz1},{0, 0, 1}, {0, 0, 0}, teta-teta1} {Point{103,108};}
Extrude {{0, 0, dz3},{0, 0, 1}, {0, 0, 0}, 2*Pi/3-teta-teta1} {Point{113,118};}
Extrude {{0, 0, dz2},{0, 0, 1}, {0, 0, 0}, 2*teta1} {Point{123,128};}
Extrude {{0, 0, dz4*0.5},{0, 0, 1}, {0, 0, 0}, (2*Pi/3-2*teta1)*0.5} {Point{133,138};}
Extrude {{0, 0, dz4*0.5},{0, 0, 1}, {0, 0, 0}, (2*Pi/3-2*teta1)*0.5} {Point{143,148};}
Extrude {{0, 0, dz2},{0, 0, 1}, {0, 0, 0}, 2*teta1} {Point{153,158};}
Extrude {{0, 0, dz3},{0, 0, 1}, {0, 0, 0}, 2*Pi/3-teta-teta1} {Point{163,168};}





Extrude {{0, 0, dz3},{0, 0, 1}, {0, 0, 0}, 2*Pi/3-teta-teta1} {Point{21,26};}
Extrude {{0, 0, dz2},{0, 0, 1}, {0, 0, 0}, 2*teta1} {Point{183,188};}
Extrude {{0, 0, dz4*0.5},{0, 0, 1}, {0, 0, 0}, (2*Pi/3-2*teta1)*0.5} {Point{193,198};}
Extrude {{0, 0, dz4*0.5},{0, 0, 1}, {0, 0, 0}, (2*Pi/3-2*teta1)*0.5} {Point{203,208};}
Extrude {{0, 0, dz2},{0, 0, 1}, {0, 0, 0}, 2*teta1} {Point{213,218};}
Extrude {{0, 0, dz3},{0, 0, 1}, {0, 0, 0}, 2*Pi/3-teta-teta1} {Point{223,228};}
Extrude {{0, 0, dz1},{0, 0, 1}, {0, 0, 0}, teta-teta1} {Point{233,238};}
Extrude {{0, 0, dz2},{0, 0, 1}, {0, 0, 0}, 2*teta1} {Point{243,248};}
Extrude {{0, 0, dz1},{0, 0, 1}, {0, 0, 0}, teta-teta1} {Point{253,258};}



Line(75) = {268, 263};
Line(76) = {178, 173};
Line(77) = {98, 8};
Line(78) = {93, 4};
Line(79) = {26, 118};
Line(80) = {113, 21};
Line(81) = {113, 118};
Line(82) = {98, 93};
Line(83) = {183, 123};
Line(84) = {123, 128};
Line(85) = {183, 188};
Line(86) = {188, 128};
Line(87) = {193, 133};
Line(88) = {133, 138};
Line(89) = {138, 198};
Line(90) = {198, 193};
Line(91) = {143, 203};
Line(92) = {203, 208};
Line(93) = {208, 148};
Line(94) = {148, 143};
Line(95) = {153, 213};
Line(96) = {213, 218};
Line(97) = {218, 158};
Line(98) = {158, 153};
Line(99) = {223, 228};
Line(100) = {228, 168};
Line(101) = {168, 163};
Line(102) = {163, 223};
Extrude {0, 0, pas} {
  Line{38, 31, 30, 34, 33, 37, 22, 21, 25, 24, 36, 7, 4, 32, 13, 23};
}


Translate {0, 0, pas} {
  Duplicata { Line{9, 2, 5, 14, 10, 12, 15, 6, 29, 28, 35, 26, 19, 20, 3, 8}; }
}
Line(183) = {17, 103};
Line(184) = {103, 253};
Line(185) = {253, 286};
Line(186) = {93, 243};
Line(187) = {243, 290};
Line(188) = {61, 213};
Line(189) = {63, 223};
Line(190) = {163, 324};
Line(191) = {153, 328};
Line(192) = {193, 35};
Line(193) = {183, 33};
Line(194) = {123, 338};
Line(195) = {133, 343};
Line Loop(196) = {178, 179, 180, 131, 127, 163, 139, 135};
Plane Surface(197) = {196};
Line Loop(198) = {159, -147, -182, -167, -170, 168, 181, 151};
Plane Surface(199) = {198};
Line Loop(200) = {107, 155, 119, 115, 177, 176, 175, 111};
Plane Surface(201) = {200};
Line Loop(202) = {38, -4, -3, -2, -5, -1, 6, 15, -12, 11, 10, 9, 8, 7, 36, 24, 25, 26, 19, 20, 21, 22, 37, 33, 34, 35, 28, 29, 30, 31};
Plane Surface(203) = {202};
Line Loop(204) = {76, 169, 168, 181, 151, -103, -107, -111, -175, -176, -177, -115, -119, -123, -127, -131, -180, -179, -178, -135, -139, -143, -147, -182, -167, -171, -75, 172, -173, -174};
Plane Surface(205) = {204};
Line(206) = {5, 291};
Line(207) = {287, 13};
Line Loop(208) = {8, 148, -182, 207};
Plane Surface(209) = {208};
Line Loop(210) = {3, 152, -181, -206};
Plane Surface(211) = {210};
Line Loop(212) = {2, 206, -168, -187, -186, 78};
Plane Surface(213) = {212};
Line Loop(214) = {9, -207, -167, -185, -184, -183};
Plane Surface(215) = {214};
Line Loop(216) = {180, -132, -20, -192, 87, 195};
Plane Surface(217) = {216};
Line Loop(218) = {178, -194, -83, 193, -26, 137};
Plane Surface(219) = {218};
Line Loop(220) = {177, -191, 95, -188, -35, 117};
Plane Surface(221) = {220};
Line Loop(222) = {190, 175, -112, -29, 189, -102};
Plane Surface(223) = {222};
Line Loop(224) = {179, -195, -47, 194};
Ruled Surface(225) = {224};
Line Loop(226) = {47, -87, -59, 83};
Ruled Surface(227) = {226};
Line Loop(228) = {59, 192, -19, -193};
Ruled Surface(229) = {228};
Line Loop(230) = {189, -65, -188, 28};
Ruled Surface(231) = {230};
Line Loop(232) = {95, 65, -102, -53};
Ruled Surface(233) = {232};
Line Loop(234) = {190, -176, -191, 53};
Ruled Surface(235) = {234};
Line Loop(236) = {14, 183, -41, 78};
Ruled Surface(237) = {236};
Line Loop(238) = {41, 184, -71, -186};
Ruled Surface(239) = {238};
Line Loop(240) = {71, 185, -170, -187};
Ruled Surface(241) = {240};
Line Loop(242) = {5, -78, -39};
Ruled Surface(243) = {242};
Line Loop(244) = {10, 183, 43, 80};
Ruled Surface(245) = {244};
Line Loop(246) = {57, 83, -45, 80};
Ruled Surface(247) = {246};
Line Loop(248) = {87, 49, 91, -61};
Ruled Surface(249) = {248};
Line Loop(250) = {91, 63, -95, -51};
Ruled Surface(251) = {250};
Line(252) = {173, 233};
Line(253) = {233, 238};
Line(254) = {238, 178};
Line(255) = {253, 258};
Line(256) = {258, 311};
Line(257) = {311, 286};
Line Loop(258) = {55, 252, -67, -102};
Ruled Surface(259) = {258};
Line Loop(260) = {69, 187, -169, 252};
Ruled Surface(261) = {260};
Line Loop(262) = {185, -171, -73};
Ruled Surface(263) = {262};
Line Loop(264) = {73, -75, -74, -255};
Ruled Surface(265) = {264};
Line Loop(266) = {74, 172, -256};
Ruled Surface(267) = {266};
Line Loop(268) = {39, -82, -40, 1};
Ruled Surface(269) = {268};
Line Loop(270) = {40, 77, -6};
Ruled Surface(271) = {270};
Line(272) = {32, 108};
Line(273) = {108, 103};
Line Loop(274) = {15, 272, -42, 77};
Ruled Surface(275) = {274};
Line Loop(276) = {82, 41, -273, -42};
Ruled Surface(277) = {276};
Line Loop(278) = {272, 44, -79, 12};
Ruled Surface(279) = {278};
Line Loop(280) = {273, 43, 81, -44};
Ruled Surface(281) = {280};
Line Loop(282) = {79, 46, -86, -58};
Ruled Surface(283) = {282};
Line Loop(284) = {46, -84, -45, 81};
Ruled Surface(285) = {284};
Line Loop(286) = {58, -85, -57, -11};
Ruled Surface(287) = {286};
Line Loop(288) = {59, -90, -60, -85};
Ruled Surface(289) = {288};
Line Loop(290) = {86, 48, 89, -60};
Ruled Surface(291) = {290};
Line Loop(292) = {48, -88, -47, 84};
Ruled Surface(293) = {292};
Line Loop(294) = {90, 61, 92, -62};
Ruled Surface(295) = {294};
Line Loop(296) = {62, 93, -50, 89};
Ruled Surface(297) = {296};
Line Loop(298) = {64, 97, -52, -93};
Ruled Surface(299) = {298};
Line Loop(300) = {50, 94, -49, 88};
Ruled Surface(301) = {300};
Line Loop(302) = {64, -96, -63, 92};
Ruled Surface(303) = {302};
Line Loop(304) = {52, 98, -51, -94};
Ruled Surface(305) = {304};
Line Loop(306) = {66, 100, -54, -97};
Ruled Surface(307) = {306};
Line Loop(308) = {54, 101, -53, -98};
Ruled Surface(309) = {308};
Line Loop(310) = {96, 66, -99, -65};
Ruled Surface(311) = {310};
Line Loop(312) = {99, 68, -253, -67};
Ruled Surface(313) = {312};
Line Loop(314) = {101, 55, -76, -56};
Ruled Surface(315) = {314};
Line Loop(316) = {100, 56, -254, -68};
Ruled Surface(317) = {316};
Line(318) = {243, 248};
Line(319) = {248, 314};
Line Loop(320) = {69, 318, -70, -253};
Ruled Surface(321) = {320};
Line Loop(322) = {254, 174, -319, -70};
Ruled Surface(323) = {322};
Line Loop(324) = {319, 173, -256, -72};
Ruled Surface(325) = {324};
Line Loop(326) = {318, 72, -255, -71};
Ruled Surface(327) = {326};
Surface Loop(328) = {162, 17, 237, 199, 241, 154, 211, 213, 239, 215, 209, 150};
Volume(329) = {328};
Surface Loop(330) = {166, 18, 197, 219, 225, 217, 134, 130, 229, 138, 142, 227};
Volume(331) = {330};
Surface Loop(332) = {158, 27, 201, 221, 235, 223, 114, 110, 231, 118, 122, 233};
Volume(333) = {332};
Surface Loop(334) = {205, 315, 309, 307, 311, 303, 299, 305, 251, 249, 301, 297, 295, 289, 291, 283, 279, 275, 203, 106, 243, 269, 277, 281, 245, 247, 287, 285, 293, 271, 146, 126, 313, 317, 323, 325, 267, 265, 263, 327, 321, 261, 259, 154, 211, 213, 239, 215, 209, 150, 130, 134, 217, 229, 219, 225, 138, 142, 122, 118, 221, 235, 223, 114, 110, 231};
Volume(335) = {334};

Periodic Surface (197) {163,139,135,178,179,180,131,127} = (18) { 23,24,25,26,19,20,21,22};
Periodic Surface (199) {159,151,181,168,170,167,182,147} = (17) { 13,4,3,2,14,9,8,7};
Periodic Surface (201) {155,119,115,177,176,175,111,107} = (27) { 32,33,34,35,28,29,30,31};
Periodic Surface (205) {143,139,135,178,179,180,131,127,123,119,115,177,176,175,111,107,103,-151,-181,-168,-169,-76,174,173,-172,75,171,167,182,147} = (203) {36,24,25,26,19,20,21,22,37,33,34,35,28,29,30,31,38,-4,-3,-2,-5,-1,6,15,-12,11,10,9,8,7};
