//=INPUTS=====================================================

BGM_L = 600;
BGM_H = 600;
OFFSET_FROM_CNT = 100;
OFFSET_MX = 150;
OFFSET_MY = 70;
PADDING = 30;
MY = 20;
MX = 40;
PRX = 1;
PRY = 1;

//============================================================

BGM_CNT_X = BGM_L/2;
BGM_CNT_Y = BGM_H/2;
MESH_MIN_X = BGM_CNT_X - OFFSET_MX/2;
MESH_MIN_Y = BGM_CNT_Y - OFFSET_FROM_CNT - OFFSET_MY/2;
MESH_MAX_X = MESH_MIN_X + OFFSET_MX;
MESH_MAX_Y = MESH_MIN_Y + OFFSET_MY;
SELF_CNT_X = (MESH_MAX_X + MESH_MIN_X)/2;
SELF_CNT_Y = (MESH_MAX_Y + MESH_MIN_Y)/2;

COMP_MIN_X = MESH_MIN_X + PADDING;
COMP_MIN_Y = MESH_MIN_Y + PADDING;
COMP_MAX_X = MESH_MAX_X - PADDING;
COMP_MAX_Y = MESH_MAX_Y - PADDING;

pMLL = newp; Point(pMLL) = {MESH_MIN_X,MESH_MIN_Y,0};
pMUL = newp; Point(pMUL) = {MESH_MIN_X,MESH_MAX_Y,0};
pMLR = newp; Point(pMLR) = {MESH_MAX_X,MESH_MIN_Y,0};
pMUR = newp; Point(pMUR) = {MESH_MAX_X,MESH_MAX_Y,0};

pCLL = newp; Point(pCLL) = {COMP_MIN_X,COMP_MIN_Y,0};
pCUL = newp; Point(pCUL) = {COMP_MIN_X,COMP_MAX_Y,0};
pCLR = newp; Point(pCLR) = {COMP_MAX_X,COMP_MIN_Y,0};
pCUR = newp; Point(pCUR) = {COMP_MAX_X,COMP_MAX_Y,0};

lML = newl; Line(lML) = {pMLL,pMUL};
lMB = newl; Line(lMB) = {pMLR,pMLL};
lMR = newl; Line(lMR) = {pMUR,pMLR};
lMT = newl; Line(lMT) = {pMUL,pMUR};

lCL = newl; Line(lCL) = {pCLL,pCUL};
lCB = newl; Line(lCB) = {pCLR,pCLL};
lCR = newl; Line(lCR) = {pCUR,pCLR};
lCT = newl; Line(lCT) = {pCUL,pCUR};

lLL = newl; Line(lLL) = {pCLL,pMLL};
lUL = newl; Line(lUL) = {pCUL,pMUL};
lLR = newl; Line(lLR) = {pCLR,pMLR};
lUR = newl; Line(lUR) = {pCUR,pMUR};

Rotate {{0,0,1},{SELF_CNT_X,SELF_CNT_Y,0},-Pi/2}{Line{lML};Line{lMB};Line{lMR};Line{lMT};Line{lCL};Line{lCB};Line{lCR};Line{lCT};Line{lLL};Line{lUL};Line{lLR};Line{lUR};}

Transfinite Line{lML} = MY Using Progression PRY;
Transfinite Line{lMR} = MY Using Progression PRY;
Transfinite Line{lMB} = MX Using Progression PRX;
Transfinite Line{lMT} = MX Using Progression 1/PRX;

Transfinite Line{lCL} = MY Using Progression PRY;
Transfinite Line{lCR} = MY Using Progression PRY;
Transfinite Line{lCB} = MX Using Progression PRX;
Transfinite Line{lCT} = MX Using Progression 1/PRX;

//Line Loop(1) = {lUL, lMT, -lUR, -lCT};
Line Loop(1) = {-lUL, lCT, lUR, -lMT};
//Line Loop(2) = {lUR, lMR, -lLR, -lCR};
Line Loop(2) = {-lUR, lCR, lLR, -lMR};
//Line Loop(3) = {lLR, lMB, -lLL, -lCB};
Line Loop(3) = {-lLR, lCB, lLL, -lMB};
//Line Loop(4) = {lLL, lML, -lUL, -lCL};
Line Loop(4) = {-lLL, lCL, lUL, -lML};

s0 = news; Plane Surface(s0) = {1};
s1 = news; Plane Surface(s1) = {2};
s2 = news; Plane Surface(s2) = {3};
s3 = news; Plane Surface(s3) = {4};

Transfinite Surface{s0};
Recombine Surface{s0};
Transfinite Surface{s1};
Recombine Surface{s1};
Transfinite Surface{s2};
Recombine Surface{s2};
Transfinite Surface{s3};
Recombine Surface{s3};

Physical Line(1) = {lCL, lCB, lCR, lCT};
Physical Line(2) = {lML, lMB, lMR, lMT};
Physical Surface(1) = {s0, s1, s2, s3};

Mesh 2;
Coherence Mesh;
Save "blade3.msh";
