// maillage d'un cube et du reseau de fibres interieur
lc1 = 0.1 ;
R = 0.05;
H = 0.25 ;

Point(100) = {0., 0., 0., lc1};
// premier cercle
Point(1) = {  0. ,  0. , -H/2 , lc1  } ;
Point(2) = {  R  ,  0. , -H/2 , lc1  } ;
Point(3) = {  0. ,  R  , -H/2. , lc1  } ;
Point(4) = { -R  ,  0. , -H/2 , lc1  } ;
Point(5) = {  0. , -R  , -H/2 , lc1  } ;

Circle(23) = { 2 , 1 , 3 } ;
Circle(34) = { 3 , 1 , 4 } ;
Circle(45) = { 4 , 1 , 5 } ;
Circle(52) = { 5 , 1 , 2 } ;


// deuxieme cercle
Point(6) = {  0. ,  0. , H/2 , lc1  } ;
Point(7) = {  R  ,  0. , H/2 , lc1  } ;
Point(8) = {  0. ,  R  , H/2. , lc1  } ;
Point(9) = { -R  ,  0. , H/2 , lc1  } ;
Point(10) = {  0. , -R  , H/2 , lc1  } ;

Circle(78) = { 7 , 6 , 8 } ;
Circle(89) = { 8 , 6 , 9 } ;
Circle(910) = { 9 , 6 , 10 } ;
Circle(107) = { 10 , 6 , 7 } ;



// troisieme cercle
Point(11) = {  -H/2 ,  0. , 0. , lc1  } ;
Point(12) = {  -H/2  ,  0. , R , lc1  } ;
Point(13) = {  -H/2 ,  -R  , 0 , lc1  } ;
Point(14) = {  -H/2  ,  0. , -R , lc1  } ;
Point(15) = { -H/2 , R  , 0 , lc1  } ;

Circle(1213) = { 12 , 11 , 13 } ;
Circle(1314) = { 13 , 11 , 14 } ;
Circle(1415) = { 14 , 11 , 15 } ;
Circle(1512) = { 15 , 11 , 12 } ;



// quatrieme cercle
Point(16) = {  H/2 ,  0. , 0. , lc1  } ;
Point(17) = {  H/2  ,  0. , R , lc1  } ;
Point(18) = {  H/2 ,  -R  , 0 , lc1  } ;
Point(19) = {  H/2  ,  0. , -R , lc1  } ;
Point(20) = { H/2 , R  , 0 , lc1  } ;

Circle(1718) = { 17 , 16 , 18 } ;
Circle(1819) = { 18 , 16 , 19 } ;
Circle(1920) = { 19 , 16 , 20 } ;
Circle(2017) = { 20 , 16 , 17 } ;



// cinquieme cercle
Point(21) = {  0. ,  -H/2 , 0. , lc1  } ;
Point(22) = {  0  ,  -H/2 , R , lc1  } ;
Point(23) = {  -R ,  -H/2  , 0 , lc1  } ;
Point(24) = {  0  ,  -H/2 , -R , lc1  } ;
Point(25) = { R , -H/2  , 0 , lc1  } ;


Circle(2223) = { 22 , 21 , 23 } ;
Circle(2324) = { 23 , 21 , 24 } ;
Circle(2425) = { 24 , 21 , 25 } ;
Circle(2522) = { 25 , 21 , 22 } ;



// sixieme cercle
Point(26) = {  0. ,  H/2 , 0. , lc1  } ;
Point(27) = {  0  ,  H/2 , R , lc1  } ;
Point(28) = {  -R ,  H/2  , 0 , lc1  } ;
Point(29) = {  0  ,  H/2 , -R , lc1  } ;
Point(30) = { R , H/2  , 0 , lc1  } ;

Circle(2728) = { 27 , 26 , 28 } ;
Circle(2829) = { 28 , 26 , 29 } ;
Circle(2930) = { 29 , 26 , 30 } ;
Circle(3027) = { 30 , 26 , 27 } ;

// les cercles de la boule , plan x = 0
Circle(192) = {19, 100, 2};
Circle(414) = {4, 100, 14};
Circle(129) = {12, 100, 9};
Circle(717) = {7, 100, 17};

// plan z = 0
Circle(2030) = {20, 100, 30};
Circle(2815) = {28, 100, 15};
Circle(1323) = {13, 100, 23};
Circle(2518) = {25, 100, 18};

// plan y = 0
Circle(329) = {3, 100, 29};
Circle(278) = {27, 100, 8};
Circle(1022) = {10, 100, 22};
Circle(245) = {24, 100, 5};

M = 2*H + H/2;

// les points de la boiboite
Point(101) = {M, M, -M, lc1};
Point(102) = {-M, M, -M, lc1};
Point(103) = {-M, -M, -M, lc1};
Point(104) = {M, -M, -M, lc1};

Point(105) = {M, M, M, lc1};
Point(106) = {-M, M, M, lc1};
Point(107) = {-M, -M, M, lc1};
Point(108) = {M, -M, M, lc1};

// carre du bas

Line(101102) = {101, 102};
Line(102103) = {102, 103};
Line(103104) = {103, 104};
Line(104101) = {104, 101};

// carre du haut

Line(105106) = {105, 106};
Line(106107) = {106, 107};
Line(107108) = {107, 108};
Line(108105) = {108, 105};

// les aretes

Line(101105) = {101, 105};
Line(102106) = {102, 106};
Line(103107) = {103, 107};
Line(104108) = {104, 108};




// extrusions
out23[] = Extrude {0,0,-2*H} { Line{23}; };
out34[] = Extrude {0,0,-2*H} { Line{34}; };
out45[] = Extrude {0,0,-2*H} { Line{45}; };
out52[] = Extrude {0,0,-2*H} { Line{52}; };
ll1 = newll ; Line Loop (ll1) = {out23[0], out34[0], out45[0], out52[0] };

out78[] = Extrude {0,0,2*H} { Line{78}; };
out89[] = Extrude {0,0,2*H} { Line{89}; };
out910[] = Extrude {0,0,2*H} { Line{910}; };
out107[] = Extrude {0,0,2*H} { Line{107}; };
ll2 = newll ; Line Loop (ll2) = {out78[0], out89[0], out910[0], out107[0] };

out1213[] = Extrude {-2*H,0,0} { Line{1213}; };
out1314[] = Extrude {-2*H,0,0} { Line{1314}; };
out1415[] = Extrude {-2*H,0,0} { Line{1415}; };
out1512[] = Extrude {-2*H,0,0} { Line{1512}; };
ll3 = newll ; Line Loop (ll3) = {out1213[0], out1314[0], out1415[0], out1512[0] };

out1718[] = Extrude {2*H,0,0} { Line{1718}; };
out1819[] = Extrude {2*H,0,0} { Line{1819}; };
out1920[] = Extrude {2*H,0,0} { Line{1920}; };
out2017[] = Extrude {2*H,0,0} { Line{2017}; };
ll4 = newll ; Line Loop (ll4) = {out1718[0], out1819[0], out1920[0], out2017[0] };

out2223[] = Extrude {0,-2*H,0} { Line{2223}; };
out2324[] = Extrude {0,-2*H,0} { Line{2324}; };
out2425[] = Extrude {0,-2*H,0} { Line{2425}; };
out2522[] = Extrude {0,-2*H,0} { Line{2522}; };
ll5 = newll ; Line Loop (ll5) = {out2223[0], out2324[0], out2425[0], out2522[0] };

out2728[] = Extrude {0,2*H,0} { Line{2728}; };
out2829[] = Extrude {0,2*H,0} { Line{2829}; };
out2930[] = Extrude {0,2*H,0} { Line{2930}; };
out3027[] = Extrude {0,2*H,0} { Line{3027}; };
ll6 = newll ; Line Loop (ll6) = {out2728[0], out2829[0], out2930[0], out3027[0] };

// les surfaces
Plane Surface(1) = {ll1};
Plane Surface(2) = {ll2};
Plane Surface(3) = {ll3};
Plane Surface(4) = {ll4};
Plane Surface(5) = {ll5};
Plane Surface(6) = {ll6};

// les line loop des faces du cube
Line Loop(1234) = {101102, 102103, 103104, 104101};
Plane Surface(1234) = {1234,ll1};

Line Loop(1265) = {101102, 102106, -105106, -101105};
Plane Surface(1265) = {1265,ll6};

Line Loop(2376) = {102103, 103107, -106107, -102106};
Plane Surface(2376) = {2376,ll3};

Line Loop(5678) = {105106, 106107, 107108, 108105};
Plane Surface(5678) = {5678,ll2};

Line Loop(3487) = {103104, 104108, -107108, -103107};
Plane Surface(3487) = {3487,ll5};

Line Loop(4158) = {104101, 101105, -108105, -104108};
Plane Surface(4158) = {4158,ll4};


Circle(208) = {20, 100, 8};

Line Loop(7) = {717, -2017, 208, -78};
Ruled Surface(7) = {7};

Line Loop(8) = {-208, 2030, 3027, 278};
Ruled Surface(8) = {8};

Circle(257) = {25, 100, 7};

Line Loop(9) = {-107, 1022, -2522, 257};
Ruled Surface(9) = {9};

Line Loop(10) = {-257, 2518, -1718, -717};
Ruled Surface(10) = {10};

Circle(302) = {30, 100, 2};

Line Loop(11) = {-302, -2030, -1920, 192};
Ruled Surface(11) = {11};

Line Loop(12) = {329, 2930, 302, 23};
Ruled Surface(12) = {12};

Circle(185) = {18, 100, 5};

Line Loop(13) = {-192, -1819, 185, 52};
Ruled Surface(13) = {13};

Line Loop(14) = {-2518, -2425, 245, -185};
Ruled Surface(14) = {14};

Circle(239) = {23, 100, 9};

Line Loop(15) = {-129, 1213, 1323, 239};
Ruled Surface(15) = {15};

Line Loop(16) = {2223, 239, 910, 1022};
Ruled Surface(16) = {16};

Circle(2914) = {29, 100, 14};

Line Loop(17) = {-2914, -329, 34, 414};
Ruled Surface(17) = {17};

Line Loop(18) = {-2815, 2829, 2914, 1415};
Ruled Surface(18) = {18};

Circle(234) = {23, 100, 4};

Line Loop(19) = {234, 45, -245, -2324};
Ruled Surface(19) = {19};

Line Loop(20) = {-1323, 1314, -414, -234};
Ruled Surface(20) = {20};

Circle(289) = {28, 100, 9};

Line Loop(21) = {-89, -278, 2728, 289};
Ruled Surface(21) = {21};

Line Loop(22) = {2815, 1512, 129, -289};
Ruled Surface(22) = {22};

/*
//Surface Loop(23) = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22};
//Volume(23) = {23};

// les faces du cube
//Surface Loop(24) = {1234, 1265, 2376, 5678, 3487, 4158};
//Volume(24) = {24, 23};
*/
Surface Loop(108208) = {1234, 1265, 2376, 3487, 4158, 5678, 108121, 13, 11, 12, 17, 18, 22, 108155, 108143, 15, 20, 108147, 108151, 19, 108117, 108113, 108109, 14, 10, 9, 108138, 108126, 7, 108172, 108160, 108164, 108168, 8, 108206, 108194, 21, 108130, 108134, 16, 108177, 108181, 108185, 108189, 108198, 108202};
Volume(108209) = {108208};
