lc = .1;

Merge "sphinxs.stl";
//Merge "sphere-surf.stl";
Surface Loop(1) = {1};
//Volume(1) = {1};

RB=.5;
LB=.5;
FB=.5;
BB=.5;
TB=.5;

xmin = General.MinX;
xmax = General.MaxX;
ymin = General.MinY;
ymax = General.MaxY;
zmin = General.MinZ;
zmax = General.MaxZ;

// Boundaries are set as a function of the object length
Right_Boundary=RB*(zmax-zmin);
Left_Boundary=LB*(zmax-zmin);
Front_Boundary=FB*(zmax-zmin);
Back_Boundary=BB*(zmax-zmin);
Top_Boundary=TB*(zmax-zmin);


Point(10001) = { xmin - Right_Boundary, ymin-1, zmin - Back_Boundary, lc};
Point(10002) = { xmax + Left_Boundary, ymin-1, zmin - Back_Boundary, lc};
Point(10003) = { xmax + Left_Boundary, ymin-1, zmax + Front_Boundary, lc};
Point(10004) = { xmin - Right_Boundary, ymin-1, zmax+ Front_Boundary, lc};
Line(10001) = {10004, 10003};
Line(10002) = {10003, 10002};
Line(10003) = {10002, 10001};
Line(10004) = {10001, 10004};
Line Loop(10005) = {10002, 10003, 10004, 10001};
Plane Surface(10006) = {10005};
tmp[] = Extrude {0, Top_Boundary-ymin, 0} {
  Surface{10006};
};
Delete { Volume{tmp[1]}; }
Surface Loop(10029) = {10027,10006,10015,10019,10023,10028};
Volume(10031) = {10029,1};

