// kleines Startvolumen
// Einheit mm
// x, y, z

ir = 8.00;
// Ventilvolumen mm^3
vv = 5000.0;
// geplantes gesamtvolumen
vg = 20000.0;
// res. Zylindervolumen
vz = vg - 2* vv;
l  = vz/(Pi*ir^2);

Point(10) = {0.0, 0.0, 0.0};
Point(11) = {ir, 0.0, 0.0};
Point(12) = {0.0, ir, 0.0};
Point(13) = {-ir, 0.0, 0.0};
Point(14) = {0.0, -ir, 0.0};

Circle(10) = {11,10,12};
Circle(11) = {12,10,13};
Circle(12) = {13,10,14};
Circle(13) = {14,10,11};

Point(20) = {0.0, 0.0, l};
Point(21) = {ir, 0.0,  l};
Point(22) = {0.0, ir,  l};
Point(23) = {-ir, 0.0, l};
Point(24) = {0.0, -ir, l};

Circle(20) = {21,20,22};
Circle(21) = {22,20,23};
Circle(22) = {23,20,24};
Circle(23) = {24,20,21};

Line(1) = {10,20};
Line(2) = {11,21};
Line(3) = {12,22};
Line(4) = {13,23};
Line(5) = {14,24};


// Radius Schneide
r6 = 18.3/2;
// Schneidenschutzhöhe
ssh = 1.2;

//Höhe Schneide
hs = ssh - 0.65;

//vorderer Winkel
wv = 2 /360*2*Pi;
//Radius Fusspunkt Schneide Innen
r6f = r6*Cos(wv);

// linke Seite
Point(150) = {r6f, 0.0, 0.0};
Point(160) = {0.0, r6f, 0.0};
Point(170) = {-r6f, 0.0, 0.0};
Point(180) = {0.0, -r6f, 0.0};

Circle(140) = {150,10,160};
Circle(150) = {160,10,170};
Circle(160) = {170,10,180};
Circle(170) = {180,10,150};

// SchneidePoint
Point(110) = {0.0, 0.0, -hs};
Point(151) = {r6, 0.0, -hs};
Point(161) = {0.0, r6, -hs};
Point(171) = {-r6, 0.0, -hs};
Point(181) = {0.0, -r6, -hs};

Circle(141) = {151,110,161};
Circle(151) = {161,110,171};
Circle(161) = {171,110,181};
Circle(171) = {181,110,151};

Line(142) ={11,150};
Line(143) ={12,160};
Line(144) ={13,170};
Line(145) ={14,180};

Line(152) ={150,151};
Line(153) ={160,161};
Line(154) ={170,171};
Line(155) ={180,181};



// rechte Seite
Point(250) = {r6f, 0.0, l};
Point(260) = {0.0, r6f, l};
Point(270) = {-r6f, 0.0, l};
Point(280) = {0.0, -r6f, l};

Circle(240) = {250,20,260};
Circle(250) = {260,20,270};
Circle(260) = {270,20,280};
Circle(270) = {280,20,250};




// SchneidePoint
Point(210) = {0.0, 0.0, l+hs};
Point(251) = {r6, 0.0, l+hs};
Point(261) = {0.0, r6, l+hs};
Point(271) = {-r6, 0.0, l+hs};
Point(281) = {0.0, -r6, l+hs};

Circle(241) = {251,210,261};
Circle(251) = {261,210,271};
Circle(261) = {271,210,281};
Circle(271) = {281,210,251};

Line(242) ={21,250};
Line(243) ={22,260};
Line(244) ={23,270};
Line(245) ={24,280};

Line(252) ={250,251};
Line(253) ={260,261};
Line(254) ={270,271};
Line(255) ={280,281};


//hinterer Winkel
wh = 20 /360*2*Pi;
r5 = 21.40/2;
//Radius Fusspunkt Schneide außen
dh = (r5 - r6)*Tan(wh);

// linke Seite
Point(310) = {0.0, 0.0, -hs + dh};
Point(350) = {r5, 0.0, -hs + dh};
Point(360) = {0.0, r5, -hs + dh};
Point(370) = {-r5, 0.0,-hs + dh};
Point(380) = {0.0, -r5,-hs + dh};

Circle(341) = {350,310,360};
Circle(351) = {360,310,370};
Circle(361) = {370,310,380};
Circle(371) = {380,310,350};

// rechte Seite
Point(410) = {0.0, 0.0, l + hs - dh};
Point(450) = {r5, 0.0, l + hs - dh};
Point(460) = {0.0, r5, l + hs - dh};
Point(470) = {-r5, 0.0,l + hs - dh};
Point(480) = {0.0, -r5,l + hs - dh};

Circle(441) = {450,410,460};
Circle(451) = {460,410,470};
Circle(461) = {470,410,480};
Circle(471) = {480,410,450};

Line(552) ={151,350};
Line(553) ={161,360};
Line(554) ={171,370};
Line(555) ={181,380};

Line(562) ={251,450};
Line(563) ={261,460};
Line(564) ={271,470};
Line(565) ={281,480};

// hoch auf Flanschhöhe
// linke Seite
fhl = -hs + dh - ssh;
Point(1010) = {0.0, 0.0, fhl};
Point(1020) = {r5, 0.0,  fhl};
Point(1030) = {0.0, r5,  fhl};
Point(1040) = {-r5, 0.0, fhl};
Point(1050) = {0.0, -r5, fhl};

Circle(1011) = {1020, 1010, 1030};
Circle(1012) = {1030, 1010, 1040};
Circle(1013) = {1040, 1010, 1050};
Circle(1014) = {1050, 1010, 1020};


Line(1100) ={350,1020};
Line(1101) ={360,1030};
Line(1102) ={370,1040};
Line(1103) ={380,1050};

// rechte Seite
fhr =  hs - dh + ssh + l;
Point(2010) = {0.0, 0.0,fhr};
Point(2020) = {r5, 0.0,fhr};
Point(2030) = {0.0, r5,fhr};
Point(2040) = {-r5, 0.0,fhr};
Point(2050) = {0.0, -r5,fhr};

Circle(2011) = {2020, 2010, 2030};
Circle(2012) = {2030, 2010, 2040};
Circle(2013) = {2040, 2010, 2050};
Circle(2014) = {2050, 2010, 2020};

Line(2100) ={450,2020};
Line(2101) ={460,2030};
Line(2102) ={470,2040};
Line(2103) ={480,2050};

// Flansch Kante 
// Ausenradius
r1 = 33.8/2;
// links
Point(1021) = {r1, 0.0,  fhl};
Point(1031) = {0.0, r1,  fhl};
Point(1041) = {-r1, 0.0, fhl};
Point(1051) = {0.0, -r1, fhl};


Circle(1111) = {1021, 1010, 1031};
Circle(1112) = {1031, 1010, 1041};
Circle(1113) = {1041, 1010, 1051};
Circle(1114) = {1051, 1010, 1021};

// rechts
Point(2021) = {r1, 0.0,  fhr};
Point(2031) = {0.0, r1,  fhr};
Point(2041) = {-r1, 0.0, fhr};
Point(2051) = {0.0, -r1, fhr};


Circle(2111) = {2021, 2010, 2031};
Circle(2112) = {2031, 2010, 2041};
Circle(2113) = {2041, 2010, 2051};
Circle(2114) = {2051, 2010, 2021};

Include "gewinde.geo";

// Mantelstreben
Line(4010)={1021,2021};
Line(4020)={1031,2031};
Line(4030)={1041,2041};
Line(4040)={1051,2051};



Line Loop(17318) = {4, -21, -3, 11};
Ruled Surface(17319) = {17318};
Line Loop(17320) = {4, 22, -5, -12};
Ruled Surface(17321) = {17320};
Line Loop(17322) = {13, 2, -23, -5};
Ruled Surface(17323) = {17322};
Line Loop(17324) = {2, 20, -3, -10};
Ruled Surface(17325) = {17324};
Line Loop(17326) = {12, 145, -160, -144};
Ruled Surface(17327) = {17326};
Line Loop(17328) = {144, -150, -143, 11};
Ruled Surface(17329) = {17328};
Line Loop(17330) = {143, -140, -142, 10};
Ruled Surface(17331) = {17330};
Line Loop(17332) = {13, 142, -170, -145};
Ruled Surface(17333) = {17332};
Line Loop(17334) = {154, -151, -153, 150};
Ruled Surface(17335) = {17334};
Line Loop(17336) = {140, 153, -141, -152};
Ruled Surface(17337) = {17336};
Line Loop(17338) = {152, -171, -155, 170};
Ruled Surface(17339) = {17338};
Line Loop(17340) = {155, -161, -154, 160};
Ruled Surface(17341) = {17340};
Line Loop(17342) = {161, 555, -361, -554};
Ruled Surface(17343) = {17342};
Line Loop(17344) = {555, 371, -552, -171};
Ruled Surface(17345) = {17344};
Line Loop(17346) = {552, 341, -553, -141};
Ruled Surface(17347) = {17346};
Line Loop(17348) = {553, 351, -554, -151};
Ruled Surface(17349) = {17348};
Line Loop(17350) = {1102, -1012, -1101, 351};
Ruled Surface(17351) = {17350};
Line Loop(17352) = {1011, -1101, -341, 1100};
Ruled Surface(17353) = {17352};
Line Loop(17354) = {1014, -1100, -371, 1103};
Ruled Surface(17355) = {17354};
Line Loop(17356) = {1103, -1013, -1102, 361};
Ruled Surface(17357) = {17356};
Line Loop(17358) = {23, 242, -270, -245};
Ruled Surface(17359) = {17358};
Line Loop(17360) = {22, 245, -260, -244};
Ruled Surface(17361) = {17360};
Line Loop(17362) = {244, -250, -243, 21};
Ruled Surface(17363) = {17362};
Line Loop(17364) = {243, -240, -242, 20};
Ruled Surface(17365) = {17364};
Line Loop(17366) = {252, 241, -253, -240};
Ruled Surface(17367) = {17366};
Line Loop(17368) = {251, -254, -250, 253};
Ruled Surface(17369) = {17368};
Line Loop(17370) = {254, 261, -255, -260};
Ruled Surface(17371) = {17370};
Line Loop(17372) = {255, 271, -252, -270};
Ruled Surface(17373) = {17372};
Line Loop(17374) = {271, 562, -471, -565};
Ruled Surface(17375) = {17374};
Line Loop(17376) = {565, -461, -564, 261};
Ruled Surface(17377) = {17376};
Line Loop(17378) = {564, -451, -563, 251};
Ruled Surface(17379) = {17378};
Line Loop(17380) = {563, -441, -562, 241};
Ruled Surface(17381) = {17380};
Line Loop(17382) = {441, 2101, -2011, -2100};
Ruled Surface(17383) = {17382};
Line Loop(17384) = {2101, 2012, -2102, -451};
Ruled Surface(17385) = {17384};
Line Loop(17386) = {461, 2103, -2013, -2102};
Ruled Surface(17387) = {17386};
Line Loop(17388) = {471, 2100, -2014, -2103};
Ruled Surface(17389) = {17388};
Line Loop(17390) = {3121, 3122, 3123, 3120};
Ruled Surface(17391) = {17390};
Line Loop(17392) = {3316, 3122, -3317, -3222};
Ruled Surface(17393) = {17392};
Line Loop(17394) = {3317, 3123, -3314, -3223};
Ruled Surface(17395) = {17394};
Line Loop(17396) = {3120, -3315, -3220, 3314};
Ruled Surface(17397) = {17396};
Line Loop(17398) = {3315, 3121, -3316, -3221};
Ruled Surface(17399) = {17398};
Line Loop(17400) = {3311, -3312, -3221};
Ruled Surface(17401) = {17400};
Line Loop(17402) = {3311, -3310, 3220};
Ruled Surface(17403) = {17402};
Line Loop(17404) = {3310, -3313, 3223};
Ruled Surface(17405) = {17404};
Line Loop(17406) = {3313, -3312, 3222};
Ruled Surface(17407) = {17406};
Line Loop(17408) = {5220, 5315, -5120, -5314};
Ruled Surface(17409) = {17408};
Line Loop(17410) = {5315, 5121, -5316, -5221};
Ruled Surface(17411) = {17410};
Line Loop(17412) = {5222, 5317, -5122, -5316};
Ruled Surface(17413) = {17412};
Line Loop(17414) = {5317, 5123, -5314, -5223};
Ruled Surface(17415) = {17414};
Line Loop(17416) = {5222, 5313, -5312};
Ruled Surface(17417) = {17416};
Line Loop(17418) = {5312, -5311, 5221};
Ruled Surface(17419) = {17418};
Line Loop(17420) = {5311, -5310, 5220};
Ruled Surface(17421) = {17420};
Line Loop(17422) = {5310, -5313, 5223};
Ruled Surface(17423) = {17422};
Line Loop(17424) = {7315, -7120, -7314, 7220};
Ruled Surface(17425) = {17424};
Line Loop(17426) = {7315, 7121, -7316, -7221};
Ruled Surface(17427) = {17426};
Line Loop(17428) = {7316, 7122, -7317, -7222};
Ruled Surface(17429) = {17428};
Line Loop(17430) = {7317, 7123, -7314, -7223};
Ruled Surface(17431) = {17430};
Line Loop(17432) = {7223, 7310, -7313};
Ruled Surface(17433) = {17432};
Line Loop(17434) = {7310, -7311, -7220};
Ruled Surface(17435) = {17434};
Line Loop(17436) = {7311, -7312, -7221};
Ruled Surface(17437) = {17436};
Line Loop(17438) = {7222, 7313, -7312};
Ruled Surface(17439) = {17438};
Line Loop(17440) = {9222, 9313, -9312};
Ruled Surface(17441) = {17440};
Line Loop(17442) = {9312, -9311, 9221};
Ruled Surface(17443) = {17442};
Line Loop(17444) = {9311, -9310, 9220};
Ruled Surface(17445) = {17444};
Line Loop(17446) = {9310, -9313, 9223};
Ruled Surface(17447) = {17446};
Line Loop(17448) = {9316, -9121, -9315, 9221};
Ruled Surface(17449) = {17448};
Line Loop(17450) = {9315, -9120, -9314, 9220};
Ruled Surface(17451) = {17450};
Line Loop(17452) = {9314, -9123, -9317, 9223};
Ruled Surface(17453) = {17452};
Line Loop(17454) = {9317, -9122, -9316, 9222};
Ruled Surface(17455) = {17454};
Line Loop(17456) = {11122, -11317, -11222, 11316};
Ruled Surface(17457) = {17456};
Line Loop(17458) = {11316, -11121, -11315, 11221};
Ruled Surface(17459) = {17458};
Line Loop(17460) = {11315, -11120, -11314, 11220};
Ruled Surface(17461) = {17460};
Line Loop(17462) = {11314, -11123, -11317, 11223};
Ruled Surface(17463) = {17462};
Line Loop(17464) = {11312, -11311, 11221};
Ruled Surface(17465) = {17464};
Line Loop(17466) = {11312, -11313, -11222};
Ruled Surface(17467) = {17466};
Line Loop(17468) = {11311, -11310, 11220};
Ruled Surface(17469) = {17468};
Line Loop(17470) = {1221, 1316, -1121, -1315};
Ruled Surface(17471) = {17470};
Line Loop(17472) = {1316, 1122, -1317, -1222};
Ruled Surface(17473) = {17472};
Line Loop(17474) = {1315, -1120, -1314, 1220};
Ruled Surface(17475) = {17474};
Line Loop(17476) = {1314, -1123, -1317, 1223};
Ruled Surface(17477) = {17476};
Line Loop(17478) = {1312, -1313, -1222};
Ruled Surface(17479) = {17478};
Line Loop(17480) = {1312, -1311, 1221};
Ruled Surface(17481) = {17480};
Line Loop(17482) = {1220, 1311, -1310};
Ruled Surface(17483) = {17482};
Line Loop(17484) = {1310, -1313, 1223};
Ruled Surface(17485) = {17484};
Line Loop(17486) = {17222, 17313, -17312};
Ruled Surface(17487) = {17486};
Line Loop(17488) = {17313, -17310, -17223};
Ruled Surface(17489) = {17488};
Line Loop(17490) = {17310, -17311, -17220};
Ruled Surface(17491) = {17490};
Line Loop(17492) = {17221, 17312, -17311};
Ruled Surface(17493) = {17492};
Line Loop(17494) = {17222, 17317, -17122, -17316};
Ruled Surface(17495) = {17494};
Line Loop(17496) = {17317, 17123, -17314, -17223};
Ruled Surface(17497) = {17496};
Line Loop(17498) = {17314, 17120, -17315, -17220};
Ruled Surface(17499) = {17498};
Line Loop(17500) = {17315, 17121, -17316, -17221};
Ruled Surface(17501) = {17500};
Line Loop(17502) = {16223, 16314, -16123, -16317};
Ruled Surface(17503) = {17502};
Line Loop(17504) = {16314, 16120, -16315, -16220};
Ruled Surface(17505) = {17504};
Line Loop(17506) = {16121, -16316, -16221, 16315};
Ruled Surface(17507) = {17506};
Line Loop(17508) = {16316, 16122, -16317, -16222};
Ruled Surface(17509) = {17508};
Line Loop(17510) = {16221, 16312, -16311};
Ruled Surface(17511) = {17510};
Line Loop(17512) = {16222, 16313, -16312};
Ruled Surface(17513) = {17512};
Line Loop(17514) = {16310, -16313, 16223};
Ruled Surface(17515) = {17514};
Line Loop(17516) = {16310, -16311, -16220};
Ruled Surface(17517) = {17516};
Line Loop(17518) = {12311, -12312, -12221};
Ruled Surface(17519) = {17518};
Line Loop(17520) = {12312, -12313, -12222};
Ruled Surface(17521) = {17520};
Line Loop(17522) = {12223, 12310, -12313};
Ruled Surface(17523) = {17522};
Line Loop(17524) = {12310, -12311, -12220};
Ruled Surface(17525) = {17524};
Line Loop(17526) = {12221, 12316, -12121, -12315};
Ruled Surface(17527) = {17526};
Line Loop(17528) = {12316, 12122, -12317, -12222};
Ruled Surface(17529) = {17528};
Line Loop(17530) = {12317, 12123, -12314, -12223};
Ruled Surface(17531) = {17530};
Line Loop(17532) = {12220, 12315, -12120, -12314};
Ruled Surface(17533) = {17532};
Line Loop(17534) = {13221, 13312, -13311};
Ruled Surface(17535) = {17534};
Line Loop(17536) = {13312, -13313, -13222};
Ruled Surface(17537) = {17536};
Line Loop(17538) = {13313, -13310, -13223};
Ruled Surface(17539) = {17538};
Line Loop(17540) = {13310, -13311, -13220};
Ruled Surface(17541) = {17540};
Line Loop(17542) = {13316, 13122, -13317, -13222};
Ruled Surface(17543) = {17542};
Line Loop(17544) = {13317, 13123, -13314, -13223};
Ruled Surface(17545) = {17544};
Line Loop(17546) = {13314, 13120, -13315, -13220};
Ruled Surface(17547) = {17546};
Line Loop(17548) = {13315, 13121, -13316, -13221};
Ruled Surface(17549) = {17548};
Line Loop(17550) = {14122, -14317, -14222, 14316};
Ruled Surface(17551) = {17550};
Line Loop(17552) = {14313, -14312, 14222};
Ruled Surface(17553) = {17552};
Line Loop(17554) = {14313, -14310, -14223};
Ruled Surface(17555) = {17554};
Line Loop(17556) = {14310, -14311, -14220};
Ruled Surface(17557) = {17556};
Line Loop(17558) = {14311, -14312, -14221};
Ruled Surface(17559) = {17558};
Line Loop(17560) = {14315, -14120, -14314, 14220};
Ruled Surface(17561) = {17560};
Line Loop(17562) = {14123, -14314, -14223, 14317};
Ruled Surface(17563) = {17562};
Ruled Surface(17564) = {17550};
Line Loop(17565) = {14316, -14121, -14315, 14221};
Ruled Surface(17566) = {17565};
Line Loop(17567) = {15317, -15122, -15316, 15222};
Ruled Surface(17568) = {17567};
Line Loop(17569) = {15316, -15121, -15315, 15221};
Ruled Surface(17570) = {17569};
Line Loop(17571) = {15315, -15120, -15314, 15220};
Ruled Surface(17572) = {17571};
Line Loop(17573) = {15314, -15123, -15317, 15223};
Ruled Surface(17574) = {17573};
Line Loop(17575) = {15311, -15312, -15221};
Ruled Surface(17576) = {17575};
Line Loop(17577) = {15312, -15313, -15222};
Ruled Surface(17578) = {17577};
Line Loop(17579) = {15313, -15310, -15223};
Ruled Surface(17580) = {17579};
Line Loop(17581) = {15310, -15311, -15220};
Ruled Surface(17582) = {17581};
Line Loop(17583) = {2112, 2113, 2114, 2111};
Line Loop(17584) = {9123, 9120, 9121, 9122};
Line Loop(17585) = {11122, 11123, 11120, 11121};
Line Loop(17586) = {1123, 1120, 1121, 1122};
Line Loop(17587) = {5120, 5121, 5122, 5123};
Line Loop(17588) = {7120, 7121, 7122, 7123};
Plane Surface(17589) = {17390, 17583, 17584, 17585, 17586, 17587, 17588};
Delete {
  Surface{17589};
}
Line Loop(17589) = {2011, 2012, 2013, 2014};
Plane Surface(17590) = {17390, 17583, 17584, 17585, 17586, 17587, 17588, 17589};
Line Loop(17591) = {1111, 1112, 1113, 1114};
Line Loop(17592) = {1011, 1012, 1013, 1014};
Line Loop(17593) = {12121, 12122, 12123, 12120};
Line Loop(17594) = {13120, 13121, 13122, 13123};
Line Loop(17595) = {14120, 14121, 14122, 14123};
Line Loop(17596) = {15120, 15121, 15122, 15123};
Line Loop(17597) = {16121, 16122, 16123, 16120};
Line Loop(17598) = {17123, 17120, 17121, 17122};
Plane Surface(17599) = {17591, 17592, 17593, 17594, 17595, 17596, 17597, 17598};
Line Loop(17600) = {2111, -4020, -1111, 4010};
Ruled Surface(17601) = {17600};
Line Loop(17602) = {4020, 2112, -4030, -1112};
Ruled Surface(17603) = {17602};
Line Loop(17604) = {4030, 2113, -4040, -1113};
Ruled Surface(17605) = {17604};
Line Loop(17606) = {4040, 2114, -4010, -1114};
Ruled Surface(17607) = {17606};
Delete {
  Surface{17391};
}
Line Loop(17608) = {11313, -11310, -11223};
Ruled Surface(17609) = {17608};
Surface Loop(17610) = {17590, 17399, 17397, 17403, 17401, 17407, 17405, 17395, 17393, 17601, 17603, 17605, 17607, 17599, 17355, 17353, 17351, 17357, 17343, 17341, 17339, 17337, 17331, 17329, 17327, 17321, 17319, 17363, 17361, 17359, 17323, 17333, 17325, 17365, 17367, 17373, 17371, 17369, 17379, 17377, 17375, 17381, 17383, 17385, 17387, 17389, 17335, 17349, 17347, 17345, 17533, 17525, 17523, 17531, 17529, 17527, 17519, 17521, 17545, 17543, 17549, 17547, 17541, 17539, 17537, 17535, 17563, 17561, 17566, 17559, 17557, 17555, 17553, 17574, 17572, 17570, 17568, 17578, 17576, 17582, 17580, 17505, 17503, 17515, 17517, 17511, 17507, 17509, 17513, 17495, 17487, 17489, 17491, 17493, 17501, 17499, 17497, 17455, 17453, 17451, 17449, 17443, 17441, 17447, 17445, 17459, 17457, 17463, 17461, 17469, 17465, 17467, 17609, 17473, 17471, 17481, 17479, 17485, 17483, 17475, 17477, 17415, 17413, 17417, 17423, 17421, 17419, 17411, 17409, 17431, 17429, 17427, 17425, 17435, 17433, 17439, 17437, 17551};
Volume(17611) = {17610};
Line Loop(17612) = {251, 261, 271, 241};
Plane Surface(17613) = {17612};
Line Loop(17614) = {141, 151, 161, 171};
Plane Surface(17615) = {17614};
Surface Loop(17616) = {17615, 17319, 17321, 17361, 17359, 17323, 17333, 17331, 17329, 17327, 17341, 17339, 17337, 17335, 17325, 17365, 17363, 17369, 17371, 17373, 17367, 17613};
Volume(17617) = {17616};
