use crate::geometry::{Point, Polygon};
use crate::material::Material;
use crate::section::Section;
use crate::section_library::{
ParametricSection, draw_radius, rectangle_polygon, rounded_rectangle_polygon,
};
use std::f64::consts::PI;
#[derive(Debug, Clone, PartialEq)]
pub struct ISection {
pub height: f64, pub flange_width: f64, pub web_thickness: f64, pub flange_thickness: f64, pub root_radius: f64, label: Option<String>, }
impl ISection {
pub fn new(
height: f64,
flange_width: f64,
web_thickness: f64,
flange_thickness: f64,
root_radius: f64,
) -> Self {
assert!(
height > 0.0 && flange_width > 0.0,
"Dimensions must be positive"
);
assert!(
web_thickness > 0.0 && flange_thickness > 0.0,
"Thicknesses must be positive"
);
assert!(
2.0 * flange_thickness < height,
"Flange thickness too large for height"
);
assert!(
web_thickness < flange_width,
"Web thickness must be less than flange width"
);
Self {
height,
flange_width,
web_thickness,
flange_thickness,
root_radius,
label: None,
}
}
pub fn from_designation(designation: &str) -> Option<Self> {
let dims = match designation.to_uppercase().as_str() {
"IPE80" => (80.0, 46.0, 3.8, 5.2, 5.0),
"IPE100" => (100.0, 55.0, 4.1, 5.7, 7.0),
"IPE120" => (120.0, 64.0, 4.4, 6.3, 7.0),
"IPE140" => (140.0, 73.0, 4.7, 6.9, 7.0),
"IPE160" => (160.0, 82.0, 5.0, 7.4, 9.0),
"IPE180" => (180.0, 91.0, 5.3, 8.0, 9.0),
"IPE200" => (200.0, 100.0, 5.6, 8.5, 12.0),
"IPE220" => (220.0, 110.0, 5.9, 9.2, 12.0),
"IPE240" => (240.0, 120.0, 6.2, 9.8, 15.0),
"IPE270" => (270.0, 135.0, 6.6, 10.2, 15.0),
"IPE300" => (300.0, 150.0, 7.1, 10.7, 15.0),
"IPE330" => (330.0, 160.0, 7.5, 11.5, 18.0),
"IPE360" => (360.0, 170.0, 8.0, 12.7, 18.0),
"IPE400" => (400.0, 180.0, 8.6, 13.5, 21.0),
"IPE450" => (450.0, 190.0, 9.4, 14.6, 21.0),
"IPE500" => (500.0, 200.0, 10.2, 16.0, 21.0),
"IPE550" => (550.0, 210.0, 11.1, 17.2, 24.0),
"IPE600" => (600.0, 220.0, 12.0, 19.0, 24.0),
"HEA100" => (96.0, 100.0, 5.0, 8.0, 12.0),
"HEA120" => (114.0, 120.0, 5.0, 8.0, 12.0),
"HEA140" => (133.0, 140.0, 5.5, 8.5, 12.0),
"HEA160" => (152.0, 160.0, 6.0, 9.0, 15.0),
"HEA180" => (171.0, 180.0, 6.0, 9.5, 15.0),
"HEA200" => (190.0, 200.0, 6.5, 10.0, 18.0),
"HEA220" => (210.0, 220.0, 7.0, 11.0, 18.0),
"HEA240" => (230.0, 240.0, 7.5, 12.0, 21.0),
"HEA260" => (250.0, 260.0, 7.5, 12.5, 24.0),
"HEA280" => (270.0, 280.0, 8.0, 13.0, 24.0),
"HEA300" => (290.0, 300.0, 8.5, 14.0, 27.0),
"HEA320" => (310.0, 300.0, 9.0, 15.5, 27.0),
"HEA340" => (330.0, 300.0, 9.5, 16.5, 27.0),
"HEA360" => (350.0, 300.0, 10.0, 17.5, 27.0),
"HEA400" => (390.0, 300.0, 11.0, 19.0, 27.0),
"HEA450" => (440.0, 300.0, 11.5, 21.0, 27.0),
"HEA500" => (490.0, 300.0, 12.0, 23.0, 27.0),
"HEA550" => (540.0, 300.0, 12.5, 24.0, 27.0),
"HEA600" => (590.0, 300.0, 13.0, 25.0, 27.0),
"HEB100" => (100.0, 100.0, 6.0, 10.0, 12.0),
"HEB120" => (120.0, 120.0, 6.5, 11.0, 12.0),
"HEB140" => (140.0, 140.0, 7.0, 12.0, 12.0),
"HEB160" => (160.0, 160.0, 8.0, 13.0, 15.0),
"HEB180" => (180.0, 180.0, 8.5, 14.0, 15.0),
"HEB200" => (200.0, 200.0, 9.0, 15.0, 18.0),
"HEB220" => (220.0, 220.0, 9.5, 16.0, 18.0),
"HEB240" => (240.0, 240.0, 10.0, 17.0, 21.0),
"HEB260" => (260.0, 260.0, 10.0, 17.5, 24.0),
"HEB280" => (280.0, 280.0, 10.5, 18.0, 24.0),
"HEB300" => (300.0, 300.0, 11.0, 19.0, 27.0),
"HEB320" => (320.0, 300.0, 11.5, 20.5, 27.0),
"HEB340" => (340.0, 300.0, 12.0, 21.5, 27.0),
"HEB360" => (360.0, 300.0, 12.0, 22.5, 27.0),
"HEB400" => (400.0, 300.0, 13.5, 24.0, 27.0),
"HEB450" => (450.0, 300.0, 14.0, 26.0, 27.0),
"HEB500" => (500.0, 300.0, 14.5, 28.0, 27.0),
"HEB550" => (550.0, 300.0, 15.0, 29.0, 27.0),
"HEB600" => (600.0, 300.0, 15.5, 30.0, 27.0),
"W150X14" => (150.0, 100.0, 5.0, 7.0, 8.0),
"W200X19" => (200.0, 102.0, 5.1, 7.1, 9.0),
"W250X28" => (250.0, 126.0, 5.6, 8.9, 11.0),
"W310X39" => (310.0, 166.0, 6.1, 10.0, 13.0),
"W360X51" => (360.0, 170.0, 7.1, 11.7, 14.0),
"W410X60" => (410.0, 178.0, 7.6, 12.8, 14.0),
"W460X74" => (460.0, 191.0, 8.1, 14.5, 16.0),
"W530X92" => (530.0, 209.0, 9.5, 15.6, 18.0),
"W610X113" => (610.0, 228.0, 10.9, 17.4, 19.0),
"UB152X89X16" => (152.4, 88.7, 4.5, 7.7, 7.6),
"UB178X102X19" => (177.8, 101.2, 4.8, 7.9, 7.6),
"UB203X102X23" => (203.2, 101.8, 5.4, 9.3, 7.6),
"UB254X102X25" => (257.2, 101.9, 5.7, 8.7, 7.6),
"UB254X146X31" => (251.4, 146.1, 6.0, 8.6, 10.2),
"UB305X102X28" => (308.7, 101.1, 5.8, 9.0, 7.6),
"UB305X127X37" => (304.4, 123.4, 7.1, 10.7, 8.9),
"UB305X165X40" => (303.4, 165.0, 6.7, 10.2, 10.2),
"UB356X127X39" => (355.6, 126.0, 6.6, 10.7, 10.2),
"UB406X140X39" => (398.0, 141.8, 6.4, 8.6, 10.2),
"UB406X178X54" => (402.6, 177.7, 7.7, 10.9, 10.2),
"UB457X152X52" => (449.8, 152.4, 7.6, 10.9, 10.2),
"UB457X191X67" => (453.4, 189.9, 8.5, 12.7, 10.2),
"UB533X210X82" => (528.3, 208.8, 9.6, 13.2, 12.7),
"UB610X229X101" => (602.6, 227.6, 10.5, 14.8, 12.7),
"UB686X254X125" => (677.9, 253.0, 11.7, 16.2, 15.2),
"UB762X267X134" => (750.0, 264.4, 12.0, 15.5, 15.2),
"UB838X292X176" => (834.9, 291.7, 14.0, 18.8, 17.8),
"UB914X305X201" => (903.0, 303.3, 15.1, 20.2, 17.8),
"UB914X419X343" => (911.8, 418.5, 19.1, 32.0, 22.9),
"UB1016X305X222" => (970.3, 300.0, 15.4, 21.1, 17.8),
"UB1016X305X249" => (980.1, 300.0, 16.5, 23.7, 17.8),
"UB1016X305X272" => (990.1, 300.0, 18.4, 26.8, 17.8),
"UB1016X305X314" => (1000.1, 300.0, 19.8, 30.7, 17.8),
"UB1016X305X350" => (1008.1, 302.0, 21.1, 34.3, 17.8),
"UB1016X305X393" => (1016.0, 303.0, 24.4, 38.4, 17.8),
"UB1016X305X438" => (1025.8, 304.6, 26.8, 43.4, 17.8),
"UB1016X305X487" => (1036.6, 308.1, 30.0, 48.2, 17.8),
"UB1016X305X584" => (1055.6, 311.4, 36.1, 58.2, 17.8),
"I100" => (100.0, 68.0, 4.5, 7.0, 7.0),
"I120" => (120.0, 74.0, 5.0, 8.0, 7.0),
"I140" => (140.0, 80.0, 5.5, 8.5, 8.0),
"I160" => (160.0, 88.0, 6.0, 9.0, 8.0),
"I180" => (180.0, 94.0, 6.5, 10.0, 9.0),
"I200A" => (200.0, 100.0, 7.0, 10.0, 9.0),
"I200B" => (200.0, 102.0, 9.0, 12.0, 9.0),
"I220A" => (220.0, 110.0, 7.5, 11.0, 10.0),
"I220B" => (220.0, 112.0, 9.5, 13.0, 10.0),
"I250A" => (250.0, 116.0, 8.0, 11.0, 10.0),
"I250B" => (250.0, 118.0, 10.0, 13.0, 10.0),
"I280A" => (280.0, 122.0, 8.5, 12.0, 11.0),
"I280B" => (280.0, 124.0, 10.5, 14.0, 11.0),
"I300A" => (300.0, 126.0, 9.0, 12.0, 11.0),
"I300B" => (300.0, 128.0, 11.0, 15.0, 11.0),
"I320A" => (320.0, 130.0, 9.5, 13.0, 12.0),
"I320B" => (320.0, 132.0, 11.5, 15.5, 12.0),
"I320C" => (320.0, 134.0, 13.5, 17.5, 12.0),
"I360A" => (360.0, 136.0, 10.0, 13.0, 12.0),
"I360B" => (360.0, 138.0, 12.0, 16.0, 12.0),
"I360C" => (360.0, 140.0, 14.0, 18.0, 12.0),
"I400A" => (400.0, 142.0, 10.5, 14.0, 13.0),
"I400B" => (400.0, 144.0, 12.5, 17.0, 13.0),
"I400C" => (400.0, 146.0, 14.5, 19.0, 13.0),
"I450A" => (450.0, 150.0, 11.5, 15.0, 13.0),
"I450B" => (450.0, 152.0, 13.5, 18.0, 13.0),
"I450C" => (450.0, 154.0, 15.5, 20.0, 13.0),
"I500A" => (500.0, 158.0, 12.0, 16.0, 14.0),
"I500B" => (500.0, 160.0, 14.0, 19.0, 14.0),
"I500C" => (500.0, 162.0, 16.0, 21.0, 14.0),
"I550A" => (550.0, 166.0, 13.0, 17.0, 14.0),
"I550B" => (550.0, 168.0, 15.0, 20.0, 14.0),
"I550C" => (550.0, 170.0, 17.0, 22.0, 14.0),
"I600A" => (600.0, 174.0, 13.5, 17.0, 15.0),
"I600B" => (600.0, 176.0, 15.5, 20.0, 15.0),
"I600C" => (600.0, 178.0, 17.5, 22.0, 15.0),
"I630A" => (630.0, 180.0, 14.0, 18.0, 15.0),
"I630B" => (630.0, 182.0, 16.0, 21.0, 15.0),
"I630C" => (630.0, 184.0, 18.0, 23.0, 15.0),
"HW100X100" => (100.0, 100.0, 6.0, 8.0, 10.0),
"HW125X125" => (125.0, 125.0, 6.5, 9.0, 10.0),
"HW150X150" => (150.0, 150.0, 7.0, 10.0, 10.0),
"HW175X175" => (175.0, 175.0, 7.5, 10.5, 10.0),
"HW200X200" => (200.0, 200.0, 8.0, 12.0, 12.0),
"HW250X250" => (250.0, 250.0, 9.0, 14.0, 12.0),
"HW300X300" => (300.0, 300.0, 10.0, 15.0, 12.0),
"HW350X350" => (350.0, 350.0, 11.0, 16.0, 12.0),
"HW400X400" => (400.0, 400.0, 12.0, 18.0, 12.0),
"HM100X100" => (100.0, 100.0, 6.0, 8.0, 10.0),
"HM150X100" => (150.0, 100.0, 6.0, 10.0, 10.0),
"HM200X150" => (200.0, 150.0, 7.0, 11.0, 10.0),
"HM250X175" => (250.0, 175.0, 7.5, 12.0, 12.0),
"HM300X200" => (300.0, 200.0, 8.0, 13.0, 12.0),
"HM350X250" => (350.0, 250.0, 9.0, 14.0, 12.0),
"HM400X300" => (400.0, 300.0, 10.0, 16.0, 12.0),
"HM450X300" => (450.0, 300.0, 11.0, 17.0, 12.0),
"HM500X300" => (500.0, 300.0, 11.0, 17.0, 12.0),
"HM550X300" => (550.0, 300.0, 12.0, 18.0, 12.0),
"HM600X300" => (600.0, 300.0, 12.0, 18.0, 12.0),
"HN200X100" => (200.0, 100.0, 5.5, 8.0, 10.0),
"HN250X125" => (250.0, 125.0, 6.0, 9.0, 10.0),
"HN300X150" => (300.0, 150.0, 6.5, 9.0, 10.0),
"HN350X175" => (350.0, 175.0, 7.0, 10.0, 12.0),
"HN400X200" => (400.0, 200.0, 7.5, 11.0, 12.0),
"HN450X200" => (450.0, 200.0, 8.0, 12.0, 12.0),
"HN500X200" => (500.0, 200.0, 8.5, 12.0, 12.0),
"HN550X200" => (550.0, 200.0, 9.0, 13.0, 12.0),
"HN600X200" => (600.0, 200.0, 9.0, 13.0, 12.0),
"HN700X300" => (700.0, 300.0, 12.0, 17.0, 15.0),
"HN800X300" => (800.0, 300.0, 13.0, 18.0, 15.0),
"HN900X300" => (900.0, 300.0, 14.0, 19.0, 15.0),
"HN1000X300" => (1000.0, 300.0, 15.0, 21.0, 15.0),
"UC152X152X23" => (152.4, 152.2, 5.8, 6.8, 7.6),
"UC152X152X30" => (157.6, 152.9, 6.5, 9.4, 7.6),
"UC152X152X37" => (161.8, 154.4, 8.1, 11.5, 7.6),
"UC203X203X46" => (203.2, 203.6, 7.2, 11.0, 10.2),
"UC203X203X52" => (206.2, 204.3, 7.9, 12.5, 10.2),
"UC203X203X60" => (209.6, 205.8, 9.4, 14.2, 10.2),
"UC203X203X71" => (215.8, 206.4, 10.0, 17.3, 10.2),
"UC203X203X86" => (222.2, 209.1, 12.7, 20.5, 10.2),
"UC254X254X73" => (254.1, 254.6, 8.6, 14.2, 12.7),
"UC254X254X89" => (260.3, 256.3, 10.3, 17.3, 12.7),
"UC254X254X107" => (266.7, 258.8, 12.8, 20.5, 12.7),
"UC254X254X132" => (276.3, 261.3, 15.3, 25.3, 12.7),
"UC254X254X167" => (289.1, 265.2, 19.2, 31.7, 12.7),
"UC305X305X97" => (307.9, 305.3, 9.9, 15.4, 15.2),
"UC305X305X118" => (314.5, 307.4, 12.0, 18.7, 15.2),
"UC305X305X137" => (320.5, 309.2, 13.8, 21.7, 15.2),
"UC305X305X158" => (327.1, 311.2, 15.8, 25.0, 15.2),
"UC305X305X198" => (339.9, 314.5, 19.1, 31.4, 15.2),
"UC305X305X240" => (352.5, 318.4, 23.0, 37.7, 15.2),
"UC305X305X283" => (365.3, 322.2, 26.8, 44.1, 15.2),
"UC356X368X129" => (355.6, 368.6, 10.4, 17.5, 15.2),
"UC356X368X153" => (362.0, 370.5, 12.3, 20.7, 15.2),
"UC356X368X177" => (368.2, 372.6, 14.4, 23.8, 15.2),
"UC356X368X202" => (374.6, 374.7, 16.5, 27.0, 15.2),
"UC356X406X235" => (381.0, 394.8, 18.4, 30.2, 15.2),
"UC356X406X287" => (393.6, 399.0, 22.6, 36.5, 15.2),
"UC356X406X340" => (406.4, 403.0, 27.0, 42.9, 15.2),
"UC356X406X393" => (419.0, 407.0, 30.6, 49.2, 15.2),
"UC356X406X467" => (436.6, 412.2, 35.8, 58.0, 15.2),
"UC356X406X551" => (455.6, 418.5, 42.1, 67.5, 15.2),
"UC356X406X634" => (474.6, 424.0, 47.6, 77.0, 15.2),
_ => return None,
};
let (h, b, s, t, r) = dims;
let mut section = Self::new(h / 1000.0, b / 1000.0, s / 1000.0, t / 1000.0, r / 1000.0);
section.label = Some(designation.to_uppercase());
Some(section)
}
}
impl ParametricSection for ISection {
fn build(&self) -> Section {
let h = self.height;
let b = self.flange_width;
let s = self.web_thickness;
let t = self.flange_thickness;
let r = self.root_radius;
let hw = b / 2.0;
let hh = h / 2.0;
let sw = s / 2.0;
let n_r = 8usize;
let mut vertices = Vec::new();
vertices.push(Point::new(-hw, -hh));
vertices.push(Point::new(hw, -hh));
vertices.push(Point::new(hw, -hh + t));
if r > 0.0 {
let (cx, cy) = (sw + r, -hh + t + r);
for i in 0..=n_r {
let theta = -std::f64::consts::FRAC_PI_2
- i as f64 / n_r as f64 * std::f64::consts::FRAC_PI_2;
vertices.push(Point::new(cx + r * theta.cos(), cy + r * theta.sin()));
}
let (cx, cy) = (sw + r, hh - t - r);
for i in 0..=n_r {
let theta =
std::f64::consts::PI - i as f64 / n_r as f64 * std::f64::consts::FRAC_PI_2;
vertices.push(Point::new(cx + r * theta.cos(), cy + r * theta.sin()));
}
} else {
vertices.push(Point::new(sw, -hh + t));
vertices.push(Point::new(sw, hh - t));
}
vertices.push(Point::new(hw, hh - t));
vertices.push(Point::new(hw, hh));
vertices.push(Point::new(-hw, hh));
vertices.push(Point::new(-hw, hh - t));
if r > 0.0 {
let (cx, cy) = (-sw - r, hh - t - r);
for i in 0..=n_r {
let theta = std::f64::consts::FRAC_PI_2
- i as f64 / n_r as f64 * std::f64::consts::FRAC_PI_2;
vertices.push(Point::new(cx + r * theta.cos(), cy + r * theta.sin()));
}
let (cx, cy) = (-sw - r, -hh + t + r);
for i in 0..=n_r {
let theta = -(i as f64) / n_r as f64 * std::f64::consts::FRAC_PI_2;
vertices.push(Point::new(cx + r * theta.cos(), cy + r * theta.sin()));
}
} else {
vertices.push(Point::new(-sw, hh - t));
vertices.push(Point::new(-sw, -hh + t));
}
vertices.push(Point::new(-hw, -hh + t));
let mut clean = Vec::new();
for v in vertices {
if clean.last() != Some(&v) {
clean.push(v);
}
}
if clean.len() > 1 && clean[0] == clean[clean.len() - 1] {
clean.pop();
}
let outer = Polygon::new(clean);
Section::new(outer, Vec::new())
}
fn designation(&self) -> String {
if let Some(ref label) = self.label {
return label.clone();
}
format!(
"I {:.0}x{:.0}x{:.1}x{:.1}",
self.height * 1000.0,
self.flange_width * 1000.0,
self.web_thickness * 1000.0,
self.flange_thickness * 1000.0
)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ChannelSection {
pub height: f64,
pub flange_width: f64,
pub web_thickness: f64,
pub flange_thickness: f64,
pub root_radius: f64,
pub lip_length: f64, }
impl ChannelSection {
pub fn new(
height: f64,
flange_width: f64,
web_thickness: f64,
flange_thickness: f64,
root_radius: f64,
lip_length: f64,
) -> Self {
assert!(
height > 0.0 && flange_width > 0.0,
"Dimensions must be positive"
);
assert!(
web_thickness > 0.0 && flange_thickness > 0.0,
"Thicknesses must be positive"
);
assert!(lip_length >= 0.0, "Lip length must be non-negative");
Self {
height,
flange_width,
web_thickness,
flange_thickness,
root_radius,
lip_length,
}
}
pub fn standard(
height: f64,
flange_width: f64,
web_thickness: f64,
flange_thickness: f64,
) -> Self {
Self::new(
height,
flange_width,
web_thickness,
flange_thickness,
0.0,
0.0,
)
}
pub fn from_designation(designation: &str) -> Option<Self> {
let dims = match designation.to_uppercase().as_str() {
"UPN50" => (50.0, 38.0, 4.5, 7.0, 7.0, 0.0),
"UPN65" => (65.0, 42.0, 5.0, 7.5, 7.0, 0.0),
"UPN80" => (80.0, 45.0, 5.0, 8.0, 8.0, 0.0),
"UPN100" => (100.0, 50.0, 5.5, 8.5, 8.0, 0.0),
"UPN120" => (120.0, 55.0, 6.0, 9.0, 9.0, 0.0),
"UPN140" => (140.0, 60.0, 6.5, 10.0, 10.0, 0.0),
"UPN160" => (160.0, 65.0, 7.0, 10.5, 10.0, 0.0),
"UPN180" => (180.0, 70.0, 7.5, 11.0, 11.0, 0.0),
"UPN200" => (200.0, 75.0, 8.0, 11.5, 12.0, 0.0),
"UPN220" => (220.0, 80.0, 8.5, 12.5, 12.0, 0.0),
"UPN240" => (240.0, 85.0, 9.0, 13.0, 13.0, 0.0),
"UPN260" => (260.0, 90.0, 9.5, 14.0, 13.0, 0.0),
"UPN280" => (280.0, 95.0, 10.0, 14.5, 13.0, 0.0),
"UPN300" => (300.0, 100.0, 10.5, 15.5, 15.0, 0.0),
"UPN320" => (320.0, 100.0, 11.5, 17.5, 15.0, 0.0),
"UPN350" => (350.0, 100.0, 12.5, 16.0, 15.0, 0.0),
"UPN380" => (380.0, 102.0, 13.5, 16.0, 15.0, 0.0),
"UPN400" => (400.0, 110.0, 14.0, 18.0, 18.0, 0.0),
"C75X50X15" => (75.0, 50.0, 1.5, 1.5, 3.0, 0.0),
"C100X50X15" => (100.0, 50.0, 1.5, 1.5, 3.0, 0.0),
"C150X50X20" => (150.0, 50.0, 2.0, 2.0, 4.0, 0.0),
"C200X60X20" => (200.0, 60.0, 2.0, 2.0, 4.0, 0.0),
"C250X75X25" => (250.0, 75.0, 2.5, 2.5, 5.0, 0.0),
"C300X90X30" => (300.0, 90.0, 3.0, 3.0, 6.0, 0.0),
"LC100X50X15" => (100.0, 50.0, 1.5, 1.5, 3.0, 15.0),
"LC150X50X20" => (150.0, 50.0, 2.0, 2.0, 4.0, 15.0),
"LC200X60X20" => (200.0, 60.0, 2.0, 2.0, 4.0, 20.0),
"LC250X75X25" => (250.0, 75.0, 2.5, 2.5, 5.0, 20.0),
"LC300X90X30" => (300.0, 90.0, 3.0, 3.0, 6.0, 25.0),
"C50" => (50.0, 37.0, 4.5, 7.0, 7.0, 0.0),
"C63" => (63.0, 40.0, 4.8, 7.5, 7.0, 0.0),
"C75" => (75.0, 43.0, 5.0, 8.0, 8.0, 0.0),
"C80" => (80.0, 43.0, 5.0, 8.0, 8.0, 0.0),
"C100" => (100.0, 48.0, 5.3, 8.5, 8.0, 0.0),
"C120" => (120.0, 53.0, 5.5, 9.0, 9.0, 0.0),
"C140A" => (140.0, 58.0, 6.0, 9.5, 10.0, 0.0),
"C140B" => (140.0, 60.0, 8.0, 11.5, 10.0, 0.0),
"C160A" => (160.0, 63.0, 6.5, 10.0, 10.0, 0.0),
"C160B" => (160.0, 65.0, 8.5, 12.0, 10.0, 0.0),
"C180A" => (180.0, 68.0, 7.0, 10.5, 11.0, 0.0),
"C180B" => (180.0, 70.0, 9.0, 12.5, 11.0, 0.0),
"C200A" => (200.0, 73.0, 7.5, 11.0, 12.0, 0.0),
"C200B" => (200.0, 75.0, 9.5, 13.0, 12.0, 0.0),
"C220A" => (220.0, 77.0, 8.0, 11.5, 12.0, 0.0),
"C220B" => (220.0, 79.0, 10.0, 13.5, 12.0, 0.0),
"C250A" => (250.0, 82.0, 9.0, 12.0, 13.0, 0.0),
"C250B" => (250.0, 84.0, 11.0, 14.0, 13.0, 0.0),
"C280A" => (280.0, 86.0, 9.5, 12.5, 13.0, 0.0),
"C280B" => (280.0, 88.0, 11.5, 14.5, 13.0, 0.0),
"C300A" => (300.0, 90.0, 10.0, 13.0, 13.0, 0.0),
"C300B" => (300.0, 92.0, 12.0, 15.0, 13.0, 0.0),
"C320A" => (320.0, 94.0, 10.5, 13.5, 14.0, 0.0),
"C320B" => (320.0, 96.0, 12.5, 15.5, 14.0, 0.0),
"C360A" => (360.0, 98.0, 11.0, 14.0, 14.0, 0.0),
"C360B" => (360.0, 100.0, 13.0, 16.0, 14.0, 0.0),
"C400A" => (400.0, 102.0, 11.5, 14.5, 14.0, 0.0),
"C400B" => (400.0, 104.0, 13.5, 16.5, 14.0, 0.0),
"CF40X20X3" => (40.0, 20.0, 3.0, 3.0, 4.0, 0.0),
"CF50X25X3" => (50.0, 25.0, 3.0, 3.0, 4.0, 0.0),
"CF60X30X4" => (60.0, 30.0, 4.0, 4.0, 5.0, 0.0),
"CF75X40X4" => (75.0, 40.0, 4.0, 4.0, 5.0, 0.0),
"CF80X40X4" => (80.0, 40.0, 4.0, 4.0, 5.0, 0.0),
"CF100X50X5" => (100.0, 50.0, 5.0, 5.0, 6.0, 0.0),
"CF120X50X5" => (120.0, 50.0, 5.0, 5.0, 6.0, 0.0),
"CF140X60X6" => (140.0, 60.0, 6.0, 6.0, 7.0, 0.0),
"CF160X60X6" => (160.0, 60.0, 6.0, 6.0, 7.0, 0.0),
"CF180X70X6" => (180.0, 70.0, 6.0, 6.0, 7.0, 0.0),
"CF200X70X6" => (200.0, 70.0, 6.0, 6.0, 7.0, 0.0),
"CF220X70X6" => (220.0, 70.0, 6.0, 6.0, 7.0, 0.0),
"CF250X75X8" => (250.0, 75.0, 8.0, 8.0, 8.0, 0.0),
"CF280X80X8" => (280.0, 80.0, 8.0, 8.0, 8.0, 0.0),
"CF300X80X8" => (300.0, 80.0, 8.0, 8.0, 8.0, 0.0),
"CFU100X40X4" => (100.0, 40.0, 4.0, 4.0, 5.0, 0.0),
"CFU120X50X4" => (120.0, 50.0, 4.0, 4.0, 5.0, 0.0),
"CFU140X50X5" => (140.0, 50.0, 5.0, 5.0, 6.0, 0.0),
"CFU160X50X5" => (160.0, 50.0, 5.0, 5.0, 6.0, 0.0),
"CFU180X60X5" => (180.0, 60.0, 5.0, 5.0, 6.0, 0.0),
"CFU200X60X5" => (200.0, 60.0, 5.0, 5.0, 6.0, 0.0),
"CFU220X60X6" => (220.0, 60.0, 6.0, 6.0, 7.0, 0.0),
"CFU250X75X6" => (250.0, 75.0, 6.0, 6.0, 7.0, 0.0),
"CFU280X75X6" => (280.0, 75.0, 6.0, 6.0, 7.0, 0.0),
"CFU300X75X6" => (300.0, 75.0, 6.0, 6.0, 7.0, 0.0),
_ => return None,
};
let (h, b, s, t, r, lip) = dims;
Some(Self::new(
h / 1000.0,
b / 1000.0,
s / 1000.0,
t / 1000.0,
r / 1000.0,
lip / 1000.0,
))
}
}
impl ParametricSection for ChannelSection {
fn build(&self) -> Section {
let h = self.height;
let b = self.flange_width;
let s = self.web_thickness;
let t = self.flange_thickness;
let _r = self.root_radius;
let lip = self.lip_length;
let hh = h / 2.0;
let sw = s;
let mut vertices = Vec::new();
vertices.push(Point::new(0.0, -hh));
vertices.push(Point::new(sw, -hh));
vertices.push(Point::new(sw + b, -hh));
if lip > 0.0 {
vertices.push(Point::new(sw + b, -hh + t + lip));
vertices.push(Point::new(sw + b - t, -hh + t + lip));
vertices.push(Point::new(sw + b - t, -hh + t));
} else {
vertices.push(Point::new(sw + b, -hh + t));
}
vertices.push(Point::new(sw, -hh + t));
vertices.push(Point::new(sw, hh - t));
vertices.push(Point::new(sw + b - t, hh - t));
if lip > 0.0 {
vertices.push(Point::new(sw + b - t, hh - t - lip));
vertices.push(Point::new(sw + b, hh - t - lip));
vertices.push(Point::new(sw + b, hh));
} else {
vertices.push(Point::new(sw + b, hh - t));
vertices.push(Point::new(sw + b, hh));
}
vertices.push(Point::new(sw, hh));
vertices.push(Point::new(0.0, hh));
let mut clean = Vec::new();
for v in vertices {
if clean.last() != Some(&v) {
clean.push(v);
}
}
if clean.len() > 1 && clean[0] == clean[clean.len() - 1] {
clean.pop();
}
let outer = Polygon::new(clean);
Section::new(outer, Vec::new())
}
fn designation(&self) -> String {
if self.lip_length > 0.0 {
format!(
"LC {:.0}x{:.0}x{:.1}x{:.1} lip{:.0}",
self.height * 1000.0,
self.flange_width * 1000.0,
self.web_thickness * 1000.0,
self.flange_thickness * 1000.0,
self.lip_length * 1000.0
)
} else {
format!(
"C {:.0}x{:.0}x{:.1}x{:.1}",
self.height * 1000.0,
self.flange_width * 1000.0,
self.web_thickness * 1000.0,
self.flange_thickness * 1000.0
)
}
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct AngleSection {
pub leg_a: f64, pub leg_b: f64, pub thickness: f64, pub root_radius: f64, pub toe_radius: f64, }
impl AngleSection {
pub fn new(leg_a: f64, leg_b: f64, thickness: f64, root_radius: f64, toe_radius: f64) -> Self {
assert!(
leg_a > 0.0 && leg_b > 0.0 && thickness > 0.0,
"Dimensions must be positive"
);
assert!(
thickness < leg_a.min(leg_b),
"Thickness must be less than leg lengths"
);
Self {
leg_a,
leg_b,
thickness,
root_radius,
toe_radius,
}
}
pub fn equal_leg(leg: f64, thickness: f64) -> Self {
Self::new(leg, leg, thickness, 0.0, 0.0)
}
pub fn from_designation(designation: &str) -> Option<Self> {
let dims = match designation.to_uppercase().as_str() {
"L20X20X3" => (20.0, 20.0, 3.0, 3.5, 2.0),
"L25X25X3" => (25.0, 25.0, 3.0, 3.5, 2.0),
"L30X30X3" => (30.0, 30.0, 3.0, 3.5, 2.0),
"L30X30X4" => (30.0, 30.0, 4.0, 3.5, 2.0),
"L40X40X3" => (40.0, 40.0, 3.0, 4.5, 2.5),
"L40X40X4" => (40.0, 40.0, 4.0, 4.5, 2.5),
"L40X40X5" => (40.0, 40.0, 5.0, 4.5, 2.5),
"L45X45X3" => (45.0, 45.0, 3.0, 4.5, 2.5),
"L45X45X4" => (45.0, 45.0, 4.0, 4.5, 2.5),
"L45X45X5" => (45.0, 45.0, 5.0, 4.5, 2.5),
"L50X50X3" => (50.0, 50.0, 3.0, 5.5, 3.0),
"L50X50X4" => (50.0, 50.0, 4.0, 5.5, 3.0),
"L50X50X5" => (50.0, 50.0, 5.0, 5.5, 3.0),
"L50X50X6" => (50.0, 50.0, 6.0, 5.5, 3.0),
"L60X60X4" => (60.0, 60.0, 4.0, 6.5, 3.5),
"L60X60X5" => (60.0, 60.0, 5.0, 6.5, 3.5),
"L60X60X6" => (60.0, 60.0, 6.0, 6.5, 3.5),
"L60X60X7" => (60.0, 60.0, 7.0, 6.5, 3.5),
"L60X60X8" => (60.0, 60.0, 8.0, 6.5, 3.5),
"L70X70X5" => (70.0, 70.0, 5.0, 7.5, 4.0),
"L70X70X6" => (70.0, 70.0, 6.0, 7.5, 4.0),
"L70X70X7" => (70.0, 70.0, 7.0, 7.5, 4.0),
"L70X70X8" => (70.0, 70.0, 8.0, 7.5, 4.0),
"L75X75X5" => (75.0, 75.0, 5.0, 8.0, 4.0),
"L75X75X6" => (75.0, 75.0, 6.0, 8.0, 4.0),
"L75X75X7" => (75.0, 75.0, 7.0, 8.0, 4.0),
"L75X75X8" => (75.0, 75.0, 8.0, 8.0, 4.0),
"L80X80X5" => (80.0, 80.0, 5.0, 8.5, 4.5),
"L80X80X6" => (80.0, 80.0, 6.0, 8.5, 4.5),
"L80X80X7" => (80.0, 80.0, 7.0, 8.5, 4.5),
"L80X80X8" => (80.0, 80.0, 8.0, 8.5, 4.5),
"L80X80X9" => (80.0, 80.0, 9.0, 8.5, 4.5),
"L80X80X10" => (80.0, 80.0, 10.0, 8.5, 4.5),
"L90X90X6" => (90.0, 90.0, 6.0, 9.5, 5.0),
"L90X90X7" => (90.0, 90.0, 7.0, 9.5, 5.0),
"L90X90X8" => (90.0, 90.0, 8.0, 9.5, 5.0),
"L90X90X9" => (90.0, 90.0, 9.0, 9.5, 5.0),
"L90X90X10" => (90.0, 90.0, 10.0, 9.5, 5.0),
"L100X100X6" => (100.0, 100.0, 6.0, 10.5, 5.5),
"L100X100X7" => (100.0, 100.0, 7.0, 10.5, 5.5),
"L100X100X8" => (100.0, 100.0, 8.0, 10.5, 5.5),
"L100X100X9" => (100.0, 100.0, 9.0, 10.5, 5.5),
"L100X100X10" => (100.0, 100.0, 10.0, 10.5, 5.5),
"L100X100X12" => (100.0, 100.0, 12.0, 10.5, 5.5),
"L120X120X8" => (120.0, 120.0, 8.0, 12.5, 6.5),
"L120X120X10" => (120.0, 120.0, 10.0, 12.5, 6.5),
"L120X120X12" => (120.0, 120.0, 12.0, 12.5, 6.5),
"L150X150X10" => (150.0, 150.0, 10.0, 15.5, 8.0),
"L150X150X12" => (150.0, 150.0, 12.0, 15.5, 8.0),
"L150X150X15" => (150.0, 150.0, 15.0, 15.5, 8.0),
"L200X200X12" => (200.0, 200.0, 12.0, 18.0, 10.0),
"L200X200X15" => (200.0, 200.0, 15.0, 18.0, 10.0),
"L200X200X18" => (200.0, 200.0, 18.0, 18.0, 10.0),
"L200X200X20" => (200.0, 200.0, 20.0, 18.0, 10.0),
"L30X20X3" => (30.0, 20.0, 3.0, 3.5, 2.0),
"L40X20X3" => (40.0, 20.0, 3.0, 4.5, 2.5),
"L40X25X3" => (40.0, 25.0, 3.0, 4.5, 2.5),
"L50X30X4" => (50.0, 30.0, 4.0, 5.5, 3.0),
"L50X40X4" => (50.0, 40.0, 4.0, 5.5, 3.0),
"L60X30X5" => (60.0, 30.0, 5.0, 6.5, 3.5),
"L60X40X4" => (60.0, 40.0, 4.0, 6.5, 3.5),
"L60X40X5" => (60.0, 40.0, 5.0, 6.5, 3.5),
"L65X50X5" => (65.0, 50.0, 5.0, 7.0, 4.0),
"L75X50X5" => (75.0, 50.0, 5.0, 8.0, 4.0),
"L75X50X6" => (75.0, 50.0, 6.0, 8.0, 4.0),
"L80X60X6" => (80.0, 60.0, 6.0, 8.5, 4.5),
"L80X60X7" => (80.0, 60.0, 7.0, 8.5, 4.5),
"L100X65X7" => (100.0, 65.0, 7.0, 10.5, 5.5),
"L100X65X8" => (100.0, 65.0, 8.0, 10.5, 5.5),
"L100X75X8" => (100.0, 75.0, 8.0, 10.5, 5.5),
"L125X75X8" => (125.0, 75.0, 8.0, 12.5, 6.5),
"L150X75X10" => (150.0, 75.0, 10.0, 15.5, 8.0),
"L150X90X10" => (150.0, 90.0, 10.0, 15.5, 8.0),
"L200X100X10" => (200.0, 100.0, 10.0, 18.0, 10.0),
"L200X100X12" => (200.0, 100.0, 12.0, 18.0, 10.0),
"LA20X3" => (20.0, 20.0, 3.0, 3.5, 2.0),
"LA25X3" => (25.0, 25.0, 3.0, 3.5, 2.0),
"LA30X3" => (30.0, 30.0, 3.0, 3.5, 2.0),
"LA30X4" => (30.0, 30.0, 4.0, 3.5, 2.0),
"LA35X3" => (35.0, 35.0, 3.0, 4.0, 2.5),
"LA35X4" => (35.0, 35.0, 4.0, 4.0, 2.5),
"LA40X3" => (40.0, 40.0, 3.0, 4.5, 2.5),
"LA40X4" => (40.0, 40.0, 4.0, 4.5, 2.5),
"LA40X5" => (40.0, 40.0, 5.0, 4.5, 2.5),
"LA45X3" => (45.0, 45.0, 3.0, 4.5, 2.5),
"LA45X4" => (45.0, 45.0, 4.0, 4.5, 2.5),
"LA45X5" => (45.0, 45.0, 5.0, 4.5, 2.5),
"LA50X3" => (50.0, 50.0, 3.0, 5.5, 3.0),
"LA50X4" => (50.0, 50.0, 4.0, 5.5, 3.0),
"LA50X5" => (50.0, 50.0, 5.0, 5.5, 3.0),
"LA50X6" => (50.0, 50.0, 6.0, 5.5, 3.0),
"LA56X3" => (56.0, 56.0, 3.0, 6.0, 3.0),
"LA56X4" => (56.0, 56.0, 4.0, 6.0, 3.0),
"LA56X5" => (56.0, 56.0, 5.0, 6.0, 3.0),
"LA63X4" => (63.0, 63.0, 4.0, 6.5, 3.5),
"LA63X5" => (63.0, 63.0, 5.0, 6.5, 3.5),
"LA63X6" => (63.0, 63.0, 6.0, 6.5, 3.5),
"LA63X7" => (63.0, 63.0, 7.0, 6.5, 3.5),
"LA63X8" => (63.0, 63.0, 8.0, 6.5, 3.5),
"LA70X5" => (70.0, 70.0, 5.0, 7.0, 4.0),
"LA70X6" => (70.0, 70.0, 6.0, 7.0, 4.0),
"LA70X7" => (70.0, 70.0, 7.0, 7.0, 4.0),
"LA70X8" => (70.0, 70.0, 8.0, 7.0, 4.0),
"LA75X5" => (75.0, 75.0, 5.0, 7.5, 4.0),
"LA75X6" => (75.0, 75.0, 6.0, 7.5, 4.0),
"LA75X7" => (75.0, 75.0, 7.0, 7.5, 4.0),
"LA75X8" => (75.0, 75.0, 8.0, 7.5, 4.0),
"LA80X5" => (80.0, 80.0, 5.0, 8.0, 4.5),
"LA80X6" => (80.0, 80.0, 6.0, 8.0, 4.5),
"LA80X7" => (80.0, 80.0, 7.0, 8.0, 4.5),
"LA80X8" => (80.0, 80.0, 8.0, 8.0, 4.5),
"LA80X9" => (80.0, 80.0, 9.0, 8.0, 4.5),
"LA80X10" => (80.0, 80.0, 10.0, 8.0, 4.5),
"LA90X6" => (90.0, 90.0, 6.0, 9.0, 5.0),
"LA90X7" => (90.0, 90.0, 7.0, 9.0, 5.0),
"LA90X8" => (90.0, 90.0, 8.0, 9.0, 5.0),
"LA90X9" => (90.0, 90.0, 9.0, 9.0, 5.0),
"LA90X10" => (90.0, 90.0, 10.0, 9.0, 5.0),
"LA90X11" => (90.0, 90.0, 11.0, 9.0, 5.0),
"LA100X6" => (100.0, 100.0, 6.0, 10.0, 5.5),
"LA100X7" => (100.0, 100.0, 7.0, 10.0, 5.5),
"LA100X8" => (100.0, 100.0, 8.0, 10.0, 5.5),
"LA100X9" => (100.0, 100.0, 9.0, 10.0, 5.5),
"LA100X10" => (100.0, 100.0, 10.0, 10.0, 5.5),
"LA100X11" => (100.0, 100.0, 11.0, 10.0, 5.5),
"LA100X12" => (100.0, 100.0, 12.0, 10.0, 5.5),
"LA110X7" => (110.0, 110.0, 7.0, 11.0, 6.0),
"LA110X8" => (110.0, 110.0, 8.0, 11.0, 6.0),
"LA110X9" => (110.0, 110.0, 9.0, 11.0, 6.0),
"LA110X10" => (110.0, 110.0, 10.0, 11.0, 6.0),
"LA110X11" => (110.0, 110.0, 11.0, 11.0, 6.0),
"LA110X12" => (110.0, 110.0, 12.0, 11.0, 6.0),
"LA125X8" => (125.0, 125.0, 8.0, 12.0, 6.5),
"LA125X9" => (125.0, 125.0, 9.0, 12.0, 6.5),
"LA125X10" => (125.0, 125.0, 10.0, 12.0, 6.5),
"LA125X11" => (125.0, 125.0, 11.0, 12.0, 6.5),
"LA125X12" => (125.0, 125.0, 12.0, 12.0, 6.5),
"LA125X13" => (125.0, 125.0, 13.0, 12.0, 6.5),
"LA125X14" => (125.0, 125.0, 14.0, 12.0, 6.5),
"LA140X10" => (140.0, 140.0, 10.0, 13.0, 7.0),
"LA140X11" => (140.0, 140.0, 11.0, 13.0, 7.0),
"LA140X12" => (140.0, 140.0, 12.0, 13.0, 7.0),
"LA140X13" => (140.0, 140.0, 13.0, 13.0, 7.0),
"LA140X14" => (140.0, 140.0, 14.0, 13.0, 7.0),
"LA140X15" => (140.0, 140.0, 15.0, 13.0, 7.0),
"LA160X10" => (160.0, 160.0, 10.0, 14.0, 8.0),
"LA160X11" => (160.0, 160.0, 11.0, 14.0, 8.0),
"LA160X12" => (160.0, 160.0, 12.0, 14.0, 8.0),
"LA160X13" => (160.0, 160.0, 13.0, 14.0, 8.0),
"LA160X14" => (160.0, 160.0, 14.0, 14.0, 8.0),
"LA160X15" => (160.0, 160.0, 15.0, 14.0, 8.0),
"LA180X12" => (180.0, 180.0, 12.0, 15.0, 9.0),
"LA180X13" => (180.0, 180.0, 13.0, 15.0, 9.0),
"LA180X14" => (180.0, 180.0, 14.0, 15.0, 9.0),
"LA180X15" => (180.0, 180.0, 15.0, 15.0, 9.0),
"LA180X16" => (180.0, 180.0, 16.0, 15.0, 9.0),
"LA200X14" => (200.0, 200.0, 14.0, 16.0, 10.0),
"LA200X15" => (200.0, 200.0, 15.0, 16.0, 10.0),
"LA200X16" => (200.0, 200.0, 16.0, 16.0, 10.0),
"LA200X18" => (200.0, 200.0, 18.0, 16.0, 10.0),
"LA200X20" => (200.0, 200.0, 20.0, 16.0, 10.0),
"LUA32X20X3" => (32.0, 20.0, 3.0, 4.0, 2.5),
"LUA32X20X4" => (32.0, 20.0, 4.0, 4.0, 2.5),
"LUA40X25X3" => (40.0, 25.0, 3.0, 4.5, 2.5),
"LUA40X25X4" => (40.0, 25.0, 4.0, 4.5, 2.5),
"LUA45X30X4" => (45.0, 30.0, 4.0, 5.0, 3.0),
"LUA45X30X5" => (45.0, 30.0, 5.0, 5.0, 3.0),
"LUA50X32X4" => (50.0, 32.0, 4.0, 5.5, 3.0),
"LUA50X32X5" => (50.0, 32.0, 5.0, 5.5, 3.0),
"LUA56X36X4" => (56.0, 36.0, 4.0, 6.0, 3.0),
"LUA56X36X5" => (56.0, 36.0, 5.0, 6.0, 3.0),
"LUA63X40X5" => (63.0, 40.0, 5.0, 6.5, 3.5),
"LUA63X40X6" => (63.0, 40.0, 6.0, 6.5, 3.5),
"LUA70X45X5" => (70.0, 45.0, 5.0, 7.0, 4.0),
"LUA70X45X6" => (70.0, 45.0, 6.0, 7.0, 4.0),
"LUA75X50X5" => (75.0, 50.0, 5.0, 7.5, 4.0),
"LUA75X50X6" => (75.0, 50.0, 6.0, 7.5, 4.0),
"LUA80X50X6" => (80.0, 50.0, 6.0, 8.0, 4.5),
"LUA80X50X7" => (80.0, 50.0, 7.0, 8.0, 4.5),
"LUA90X56X6" => (90.0, 56.0, 6.0, 9.0, 5.0),
"LUA90X56X7" => (90.0, 56.0, 7.0, 9.0, 5.0),
"LUA100X63X7" => (100.0, 63.0, 7.0, 10.0, 5.5),
"LUA100X63X8" => (100.0, 63.0, 8.0, 10.0, 5.5),
"LUA100X75X7" => (100.0, 75.0, 7.0, 10.0, 5.5),
"LUA100X75X8" => (100.0, 75.0, 8.0, 10.0, 5.5),
"LUA100X75X9" => (100.0, 75.0, 9.0, 10.0, 5.5),
"LUA110X70X7" => (110.0, 70.0, 7.0, 11.0, 6.0),
"LUA110X70X8" => (110.0, 70.0, 8.0, 11.0, 6.0),
"LUA125X80X8" => (125.0, 80.0, 8.0, 12.0, 6.5),
"LUA125X80X9" => (125.0, 80.0, 9.0, 12.0, 6.5),
"LUA125X80X10" => (125.0, 80.0, 10.0, 12.0, 6.5),
"LUA140X90X10" => (140.0, 90.0, 10.0, 13.0, 7.0),
"LUA140X90X11" => (140.0, 90.0, 11.0, 13.0, 7.0),
"LUA140X90X12" => (140.0, 90.0, 12.0, 13.0, 7.0),
"LUA160X100X10" => (160.0, 100.0, 10.0, 14.0, 8.0),
"LUA160X100X11" => (160.0, 100.0, 11.0, 14.0, 8.0),
"LUA160X100X12" => (160.0, 100.0, 12.0, 14.0, 8.0),
"LUA180X110X12" => (180.0, 110.0, 12.0, 15.0, 9.0),
"LUA180X110X13" => (180.0, 110.0, 13.0, 15.0, 9.0),
"LUA200X125X14" => (200.0, 125.0, 14.0, 16.0, 10.0),
"LUA200X125X15" => (200.0, 125.0, 15.0, 16.0, 10.0),
"LUA200X125X16" => (200.0, 125.0, 16.0, 16.0, 10.0),
_ => return None,
};
let (a, b, t, r, rt) = dims;
Some(Self::new(
a / 1000.0,
b / 1000.0,
t / 1000.0,
r / 1000.0,
rt / 1000.0,
))
}
}
impl ParametricSection for AngleSection {
fn build(&self) -> Section {
let a = self.leg_a;
let b = self.leg_b;
let t = self.thickness;
let cx = a / 2.0;
let cy = b / 2.0;
let vertices = vec![
Point::new(-cx, -cy),
Point::new(a - cx, -cy),
Point::new(a - cx, t - cy),
Point::new(t - cx, t - cy),
Point::new(t - cx, b - cy),
Point::new(-cx, b - cy),
];
let outer = Polygon::new(vertices);
Section::new(outer, Vec::new())
}
fn designation(&self) -> String {
if (self.leg_a - self.leg_b).abs() < 1e-9 {
format!(
"L{:.0}x{:.0}x{:.1}",
self.leg_a * 1000.0,
self.leg_b * 1000.0,
self.thickness * 1000.0
)
} else {
format!(
"L{:.0}x{:.0}x{:.1}",
self.leg_a * 1000.0,
self.leg_b * 1000.0,
self.thickness * 1000.0
)
}
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct TeeSection {
pub height: f64, pub flange_width: f64, pub web_thickness: f64, pub flange_thickness: f64, pub root_radius: f64,
}
impl TeeSection {
pub fn new(
height: f64,
flange_width: f64,
web_thickness: f64,
flange_thickness: f64,
root_radius: f64,
) -> Self {
assert!(
height > 0.0 && flange_width > 0.0,
"Dimensions must be positive"
);
assert!(
web_thickness > 0.0 && flange_thickness > 0.0,
"Thicknesses must be positive"
);
assert!(
flange_thickness < height,
"Flange thickness must be less than height"
);
Self {
height,
flange_width,
web_thickness,
flange_thickness,
root_radius,
}
}
pub fn from_i_section(i_sec: &ISection) -> Self {
Self::new(
i_sec.height,
i_sec.flange_width,
i_sec.web_thickness,
i_sec.flange_thickness,
i_sec.root_radius,
)
}
}
impl ParametricSection for TeeSection {
fn build(&self) -> Section {
let h = self.height;
let b = self.flange_width;
let s = self.web_thickness;
let t = self.flange_thickness;
let hw = b / 2.0;
let hh = h / 2.0;
let sw = s / 2.0;
let vertices = vec![
Point::new(-hw, hh), Point::new(hw, hh), Point::new(hw, hh - t), Point::new(sw, hh - t), Point::new(sw, -hh), Point::new(-sw, -hh), Point::new(-sw, hh - t), Point::new(-hw, hh - t), ];
let outer = Polygon::new(vertices);
Section::new(outer, Vec::new())
}
fn designation(&self) -> String {
format!(
"T {:.0}x{:.0}x{:.1}x{:.1}",
self.height * 1000.0,
self.flange_width * 1000.0,
self.web_thickness * 1000.0,
self.flange_thickness * 1000.0
)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RectangularHollowSection {
pub width: f64,
pub height: f64,
pub thickness: f64,
pub outer_radius: f64,
pub inner_radius: f64,
}
impl RectangularHollowSection {
pub fn new(
width: f64,
height: f64,
thickness: f64,
outer_radius: f64,
inner_radius: f64,
) -> Self {
assert!(width > 0.0 && height > 0.0, "Dimensions must be positive");
assert!(thickness > 0.0, "Thickness must be positive");
assert!(
2.0 * thickness < width.min(height),
"Thickness too large for dimensions"
);
Self {
width,
height,
thickness,
outer_radius,
inner_radius,
}
}
pub fn square(side: f64, thickness: f64) -> Self {
Self::new(side, side, thickness, 0.0, 0.0)
}
pub fn from_designation(designation: &str) -> Option<Self> {
let upper = designation.to_uppercase();
if upper.starts_with("SHS") || upper.starts_with("RHS") {
let rest = &upper[3..];
let parts: Vec<&str> = rest.split('X').collect();
if parts.len() == 3 {
let w = parts[0].parse::<f64>().ok()?;
let h = parts[1].parse::<f64>().ok()?;
let t = parts[2].parse::<f64>().ok()?;
let r_out = 1.5 * t;
let r_in = r_out - t;
return Some(Self::new(
w / 1000.0,
h / 1000.0,
t / 1000.0,
r_out / 1000.0,
r_in / 1000.0,
));
}
}
None
}
}
impl ParametricSection for RectangularHollowSection {
fn build(&self) -> Section {
let w = self.width;
let h = self.height;
let t = self.thickness;
let r_out = self.outer_radius;
let r_in = self.inner_radius;
if r_out > 0.0 {
let outer = rounded_rectangle_polygon(w, h, r_out, 8);
let inner = rounded_rectangle_polygon(w - 2.0 * t, h - 2.0 * t, r_in, 8);
Section::new(outer, vec![inner])
} else {
let outer = rectangle_polygon(w, h);
let inner = rectangle_polygon(w - 2.0 * t, h - 2.0 * t);
Section::new(outer, vec![inner])
}
}
fn designation(&self) -> String {
if (self.width - self.height).abs() < 1e-9 {
format!(
"SHS {:.0}x{:.0}",
self.width * 1000.0,
self.thickness * 1000.0
)
} else {
format!(
"RHS {:.0}x{:.0}x{:.0}",
self.width * 1000.0,
self.height * 1000.0,
self.thickness * 1000.0
)
}
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CircularHollowSectionLib {
pub outer_diameter: f64,
pub wall_thickness: f64,
pub n_vertices: usize,
}
impl CircularHollowSectionLib {
pub fn new(outer_diameter: f64, wall_thickness: f64) -> Self {
Self::with_vertices(outer_diameter, wall_thickness, 64)
}
pub fn from_designation(designation: &str) -> Option<Self> {
let upper = designation.to_uppercase();
let rest = upper.strip_prefix("CHS")?.trim_start_matches('Ø');
let parts: Vec<&str> = rest.split('X').collect();
if parts.len() != 2 {
return None;
}
let d = parts[0].parse::<f64>().ok()? / 1000.0;
let t = parts[1].parse::<f64>().ok()? / 1000.0;
if d <= 0.0 || t <= 0.0 || 2.0 * t >= d {
return None;
}
Some(Self::new(d, t))
}
pub fn with_vertices(outer_diameter: f64, wall_thickness: f64, n_vertices: usize) -> Self {
assert!(outer_diameter > 0.0, "Diameter must be positive");
assert!(wall_thickness > 0.0, "Thickness must be positive");
assert!(
2.0 * wall_thickness < outer_diameter,
"Wall thickness too large"
);
assert!(n_vertices >= 8, "At least 8 vertices");
Self {
outer_diameter,
wall_thickness,
n_vertices,
}
}
}
impl ParametricSection for CircularHollowSectionLib {
fn build(&self) -> Section {
use crate::section_library::hollow_circle_polygon;
let ro = self.outer_diameter / 2.0;
let ri = ro - self.wall_thickness;
let (outer, inner) = hollow_circle_polygon(ro, ri, self.n_vertices);
Section::new(outer, vec![inner])
}
fn designation(&self) -> String {
format!(
"CHS Ø{:.0}x{:.1}",
self.outer_diameter * 1000.0,
self.wall_thickness * 1000.0
)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct ZSection {
pub height: f64,
pub flange_width: f64,
pub web_thickness: f64,
pub flange_thickness: f64,
pub lip_length: f64,
}
impl ZSection {
pub fn new(
height: f64,
flange_width: f64,
web_thickness: f64,
flange_thickness: f64,
lip_length: f64,
) -> Self {
assert!(
height > 0.0 && flange_width > 0.0,
"Dimensions must be positive"
);
assert!(
web_thickness > 0.0 && flange_thickness > 0.0,
"Thicknesses must be positive"
);
Self {
height,
flange_width,
web_thickness,
flange_thickness,
lip_length,
}
}
}
impl ParametricSection for ZSection {
fn build(&self) -> Section {
let h = self.height;
let b = self.flange_width;
let s = self.web_thickness;
let t = self.flange_thickness;
let lip = self.lip_length;
let hh = h / 2.0;
let mut vertices = Vec::new();
vertices.push(Point::new(-b, hh));
vertices.push(Point::new(0.0, hh));
vertices.push(Point::new(s, hh));
vertices.push(Point::new(s, -hh + t));
if lip > 0.0 {
vertices.push(Point::new(s + b - t, -hh + t));
vertices.push(Point::new(s + b - t, -hh + t + lip));
vertices.push(Point::new(s + b, -hh + t + lip));
} else {
vertices.push(Point::new(s + b, -hh + t));
}
vertices.push(Point::new(s + b, -hh));
vertices.push(Point::new(s, -hh));
vertices.push(Point::new(0.0, -hh));
vertices.push(Point::new(0.0, hh - t));
if lip > 0.0 {
vertices.push(Point::new(-b + t, hh - t));
vertices.push(Point::new(-b + t, hh - t - lip));
vertices.push(Point::new(-b, hh - t - lip));
} else {
vertices.push(Point::new(-b, hh - t));
}
let mut clean = Vec::new();
for v in vertices {
if clean.last() != Some(&v) {
clean.push(v);
}
}
if clean.len() > 1 && clean[0] == clean[clean.len() - 1] {
clean.pop();
}
let outer = Polygon::new(clean);
Section::new(outer, Vec::new())
}
fn designation(&self) -> String {
format!(
"Z {:.0}x{:.0}x{:.1}x{:.1}",
self.height * 1000.0,
self.flange_width * 1000.0,
self.web_thickness * 1000.0,
self.flange_thickness * 1000.0
)
}
}
#[derive(Debug)]
pub struct BuiltUpSection {
pub components: Vec<(Box<dyn ParametricSection>, Point, Material)>, }
impl BuiltUpSection {
pub fn new() -> Self {
Self {
components: Vec::new(),
}
}
pub fn add(
mut self,
section: impl ParametricSection + 'static,
offset: Point,
material: Material,
) -> Self {
self.components.push((Box::new(section), offset, material));
self
}
pub fn build(&self) -> crate::section_library::CompositeSection {
let mut all_polygons = Vec::new();
let mut material_groups = Vec::new();
let mut current_index = 0;
for (section, offset, material) in &self.components {
let built = section.build();
let mut outer = built.outer;
for v in &mut outer.vertices {
v.x += offset.x;
v.y += offset.y;
}
let n_holes = built.holes.len();
let mut holes = built.holes;
for h in &mut holes {
for v in &mut h.vertices {
v.x += offset.x;
v.y += offset.y;
}
}
all_polygons.push(outer);
all_polygons.extend(holes);
material_groups.push(crate::material::MaterialGroup::new(
material.clone(),
(current_index..current_index + 1 + n_holes).collect(),
));
current_index += 1 + n_holes;
}
crate::section_library::CompositeSection::new(
all_polygons[0].clone(),
all_polygons[1..].to_vec(),
material_groups,
)
}
}
impl Default for BuiltUpSection {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct MonosymmetricISection {
pub depth: f64,
pub top_flange_width: f64,
pub bottom_flange_width: f64,
pub top_flange_thickness: f64,
pub bottom_flange_thickness: f64,
pub web_thickness: f64,
pub root_radius: f64,
pub n_r: usize,
}
impl MonosymmetricISection {
pub fn new(
depth: f64,
top_flange_width: f64,
bottom_flange_width: f64,
top_flange_thickness: f64,
bottom_flange_thickness: f64,
web_thickness: f64,
root_radius: f64,
n_r: usize,
) -> Self {
assert!(depth > 0.0, "Depth must be positive");
assert!(web_thickness > 0.0, "Web thickness must be positive");
assert!(n_r >= 1, "Need at least 1 point for radius");
Self {
depth,
top_flange_width,
bottom_flange_width,
top_flange_thickness,
bottom_flange_thickness,
web_thickness,
root_radius,
n_r,
}
}
}
impl ParametricSection for MonosymmetricISection {
fn build(&self) -> Section {
let d = self.depth;
let b_t = self.top_flange_width;
let b_b = self.bottom_flange_width;
let t_ft = self.top_flange_thickness;
let t_fb = self.bottom_flange_thickness;
let t_w = self.web_thickness;
let r = self.root_radius;
let n_r = self.n_r;
let x_c = b_t.max(b_b) * 0.5;
let mut points = Vec::new();
points.push(Point::new(x_c - b_b * 0.5, 0.0));
points.push(Point::new(x_c + b_b * 0.5, 0.0));
points.push(Point::new(x_c + b_b * 0.5, t_fb));
if r > 0.0 {
let pt = Point::new(x_c + t_w * 0.5 + r, t_fb + r);
points.extend(draw_radius(pt, r, 1.5 * PI, n_r, false, PI / 2.0));
let pt = Point::new(x_c + t_w * 0.5 + r, d - t_ft - r);
points.extend(draw_radius(pt, r, PI, n_r, false, PI / 2.0));
} else {
points.push(Point::new(x_c + t_w * 0.5, t_fb));
points.push(Point::new(x_c + t_w * 0.5, d - t_ft));
}
points.push(Point::new(x_c + b_t * 0.5, d - t_ft));
points.push(Point::new(x_c + b_t * 0.5, d));
points.push(Point::new(x_c - b_t * 0.5, d));
points.push(Point::new(x_c - b_t * 0.5, d - t_ft));
if r > 0.0 {
let pt = Point::new(x_c - t_w * 0.5 - r, d - t_ft - r);
points.extend(draw_radius(pt, r, 0.5 * PI, n_r, false, PI / 2.0));
let pt = Point::new(x_c - t_w * 0.5 - r, t_fb + r);
points.extend(draw_radius(pt, r, 0.0, n_r, false, PI / 2.0));
} else {
points.push(Point::new(x_c - t_w * 0.5, d - t_ft));
points.push(Point::new(x_c - t_w * 0.5, t_fb));
}
points.push(Point::new(x_c - b_b * 0.5, t_fb));
Section::new(Polygon::new(points), vec![])
}
fn designation(&self) -> String {
format!(
"Mono-I {:.0}x{:.0}/{:.0}",
self.depth * 1000.0,
self.top_flange_width * 1000.0,
self.bottom_flange_width * 1000.0
)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TaperedFlangeISection {
pub depth: f64,
pub width: f64,
pub mid_flange_thickness: f64,
pub web_thickness: f64,
pub root_radius: f64,
pub flange_radius: f64,
pub alpha: f64,
pub n_r: usize,
}
impl TaperedFlangeISection {
pub fn new(
depth: f64,
width: f64,
mid_flange_thickness: f64,
web_thickness: f64,
root_radius: f64,
flange_radius: f64,
alpha_deg: f64,
n_r: usize,
) -> Self {
assert!(depth > 0.0 && width > 0.0, "Dimensions must be positive");
assert!(n_r >= 1, "Need at least 1 point for radius");
Self {
depth,
width,
mid_flange_thickness,
web_thickness,
root_radius,
flange_radius,
alpha: alpha_deg,
n_r,
}
}
}
impl ParametricSection for TaperedFlangeISection {
fn build(&self) -> Section {
let d = self.depth;
let b = self.width;
let t_f = self.mid_flange_thickness;
let t_w = self.web_thickness;
let r_r = self.root_radius;
let r_f = self.flange_radius;
let n_r = self.n_r;
let alpha = self.alpha * PI / 180.0;
let x1 = b * 0.25 - t_w * 0.25 - r_f * (1.0 - alpha.sin());
let y1 = x1 * alpha.tan();
let x2 = b * 0.25 - t_w * 0.25 - r_r * (1.0 - alpha.sin());
let y2 = x2 * alpha.tan();
let y_t = t_f - y1 - r_f * alpha.cos();
let mut points = Vec::new();
points.push(Point::new(0.0, 0.0));
points.push(Point::new(b, 0.0));
if r_f == 0.0 {
points.push(Point::new(b, y_t));
} else {
for i in 0..n_r {
let theta = i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
b - r_f + r_f * theta.cos(),
y_t + r_f * theta.sin(),
));
}
}
if r_r == 0.0 {
points.push(Point::new(b * 0.5 + t_w * 0.5, t_f + y2));
} else {
for i in 0..n_r {
let theta = (1.5 * PI - alpha)
- i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
b * 0.5 + t_w * 0.5 + r_r + r_r * theta.cos(),
t_f + y2 + r_r * alpha.cos() + r_r * theta.sin(),
));
}
}
if r_r == 0.0 {
points.push(Point::new(b * 0.5 + t_w * 0.5, d - t_f - y2));
} else {
for i in 0..n_r {
let theta = PI - i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
b * 0.5 + t_w * 0.5 + r_r + r_r * theta.cos(),
d - t_f - y2 - r_r * alpha.cos() + r_r * theta.sin(),
));
}
}
if r_f == 0.0 {
points.push(Point::new(b, d - y_t));
} else {
for i in 0..n_r {
let theta = (1.5 * PI + alpha)
+ i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
b - r_f + r_f * theta.cos(),
d - y_t + r_f * theta.sin(),
));
}
}
points.push(Point::new(b, d));
points.push(Point::new(0.0, d));
if r_f == 0.0 {
points.push(Point::new(0.0, d - y_t));
} else {
for i in 0..n_r {
let theta = PI + i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
r_f + r_f * theta.cos(),
d - y_t + r_f * theta.sin(),
));
}
}
if r_r == 0.0 {
points.push(Point::new(b * 0.5 - t_w * 0.5, d - t_f - y2));
} else {
for i in 0..n_r {
let theta = (PI / 2.0 - alpha)
- i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
b * 0.5 - t_w * 0.5 - r_r + r_r * theta.cos(),
d - t_f - y2 - r_r * alpha.cos() + r_r * theta.sin(),
));
}
}
if r_r == 0.0 {
points.push(Point::new(b * 0.5 - t_w * 0.5, t_f + y2));
} else {
for i in 0..n_r {
let theta = -(i as f64) / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
b * 0.5 - t_w * 0.5 - r_r + r_r * theta.cos(),
t_f + y2 + r_r * alpha.cos() + r_r * theta.sin(),
));
}
}
if r_f == 0.0 {
points.push(Point::new(0.0, y_t));
} else {
for i in 0..n_r {
let theta = (PI / 2.0 + alpha)
+ i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(r_f + r_f * theta.cos(), y_t + r_f * theta.sin()));
}
}
Section::new(Polygon::new(points), vec![])
}
fn designation(&self) -> String {
format!(
"Tapered-I {:.0}x{:.0}",
self.depth * 1000.0,
self.width * 1000.0
)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct TaperedFlangeChannel {
pub depth: f64,
pub width: f64,
pub mid_flange_thickness: f64,
pub web_thickness: f64,
pub root_radius: f64,
pub flange_radius: f64,
pub alpha: f64,
pub n_r: usize,
}
impl TaperedFlangeChannel {
pub fn new(
depth: f64,
width: f64,
mid_flange_thickness: f64,
web_thickness: f64,
root_radius: f64,
flange_radius: f64,
alpha_deg: f64,
n_r: usize,
) -> Self {
assert!(depth > 0.0 && width > 0.0, "Dimensions must be positive");
assert!(n_r >= 1, "Need at least 1 point for radius");
Self {
depth,
width,
mid_flange_thickness,
web_thickness,
root_radius,
flange_radius,
alpha: alpha_deg,
n_r,
}
}
}
impl ParametricSection for TaperedFlangeChannel {
fn build(&self) -> Section {
let d = self.depth;
let b = self.width;
let t_f = self.mid_flange_thickness;
let t_w = self.web_thickness;
let r_r = self.root_radius;
let r_f = self.flange_radius;
let n_r = self.n_r;
let alpha = self.alpha * PI / 180.0;
let x1 = b * 0.5 - t_w * 0.5 - r_f * (1.0 - alpha.sin());
let y1 = x1 * alpha.tan();
let x2 = b * 0.5 - t_w * 0.5 - r_r * (1.0 - alpha.sin());
let y2 = x2 * alpha.tan();
let y_t = t_f - y1 - r_f * alpha.cos();
let mut points = Vec::new();
points.push(Point::new(0.0, 0.0));
points.push(Point::new(b, 0.0));
if r_f == 0.0 {
points.push(Point::new(b, y_t));
} else {
for i in 0..n_r {
let theta = i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
b - r_f + r_f * theta.cos(),
y_t + r_f * theta.sin(),
));
}
}
if r_r == 0.0 {
points.push(Point::new(t_w, t_f + y2));
} else {
for i in 0..n_r {
let theta = (1.5 * PI - alpha)
- i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
t_w + r_r + r_r * theta.cos(),
t_f + y2 + r_r * alpha.cos() + r_r * theta.sin(),
));
}
}
if r_r == 0.0 {
points.push(Point::new(t_w, d - t_f - y2));
} else {
for i in 0..n_r {
let theta = PI - i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
t_w + r_r + r_r * theta.cos(),
d - t_f - y2 - r_r * alpha.cos() + r_r * theta.sin(),
));
}
}
if r_f == 0.0 {
points.push(Point::new(b, d - y_t));
} else {
for i in 0..n_r {
let theta = (1.5 * PI + alpha)
+ i as f64 / (n_r.max(1) - 1).max(1) as f64 * (PI / 2.0 - alpha);
points.push(Point::new(
b - r_f + r_f * theta.cos(),
d - y_t + r_f * theta.sin(),
));
}
}
points.push(Point::new(b, d));
points.push(Point::new(0.0, d));
Section::new(Polygon::new(points), vec![])
}
fn designation(&self) -> String {
format!(
"Tapered-C {:.0}x{:.0}",
self.depth * 1000.0,
self.width * 1000.0
)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct BoxGirderSection {
pub depth: f64,
pub top_width: f64,
pub bottom_width: f64,
pub top_thickness: f64,
pub bottom_thickness: f64,
pub web_thickness: f64,
}
impl BoxGirderSection {
pub fn new(
depth: f64,
top_width: f64,
bottom_width: f64,
top_thickness: f64,
bottom_thickness: f64,
web_thickness: f64,
) -> Self {
assert!(depth > 0.0, "Depth must be positive");
assert!(
top_thickness + bottom_thickness < depth,
"Flanges too thick"
);
Self {
depth,
top_width,
bottom_width,
top_thickness,
bottom_thickness,
web_thickness,
}
}
}
impl ParametricSection for BoxGirderSection {
fn build(&self) -> Section {
let d = self.depth;
let b_t = self.top_width;
let b_b = self.bottom_width;
let t_ft = self.top_thickness;
let t_fb = self.bottom_thickness;
let t_w = self.web_thickness;
let x_c = b_t.max(b_b) * 0.5;
let (phi_b, phi_t) = if b_t < b_b {
let phi_b = (d).atan2(0.5 * (b_b - b_t));
(phi_b, PI - phi_b)
} else {
let phi_t = (d).atan2(0.5 * (b_t - b_b));
(PI - phi_t, phi_t)
};
let x_bot = t_fb / (PI - phi_b).tan();
let x_top = t_ft / (PI - phi_t).tan();
let web_x = (t_w / (PI - phi_b).sin()).abs();
let outer = Polygon::new(vec![
Point::new(x_c - 0.5 * b_b, 0.0),
Point::new(x_c + 0.5 * b_b, 0.0),
Point::new(x_c + 0.5 * b_t, d),
Point::new(x_c - 0.5 * b_t, d),
]);
let inner = Polygon::new(vec![
Point::new(x_c - 0.5 * b_b - x_bot + web_x, t_fb),
Point::new(x_c + 0.5 * b_b + x_bot - web_x, t_fb),
Point::new(x_c + 0.5 * b_t + x_top - web_x, d - t_ft),
Point::new(x_c - 0.5 * b_t - x_top + web_x, d - t_ft),
]);
Section::new(outer, vec![inner])
}
fn designation(&self) -> String {
format!(
"BoxGirder {:.0}x{:.0}/{:.0}",
self.depth * 1000.0,
self.top_width * 1000.0,
self.bottom_width * 1000.0
)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct BulbSection {
pub depth: f64,
pub bulb_width: f64,
pub web_thickness: f64,
pub radius: f64,
pub n_r: usize,
pub bulb_depth: Option<f64>,
}
impl BulbSection {
pub fn new(depth: f64, bulb_width: f64, web_thickness: f64, radius: f64, n_r: usize) -> Self {
assert!(
depth > 0.0 && web_thickness > 0.0,
"Dimensions must be positive"
);
assert!(n_r >= 2, "Need at least 2 points for radius");
Self {
depth,
bulb_width,
web_thickness,
radius,
n_r,
bulb_depth: None,
}
}
pub fn with_bulb_depth(
depth: f64,
bulb_width: f64,
web_thickness: f64,
radius: f64,
n_r: usize,
bulb_depth: f64,
) -> Self {
Self {
depth,
bulb_width,
web_thickness,
radius,
n_r,
bulb_depth: Some(bulb_depth),
}
}
}
impl ParametricSection for BulbSection {
fn build(&self) -> Section {
let d = self.depth;
let b = self.bulb_width;
let t = self.web_thickness;
let r = self.radius;
let n_r = self.n_r;
let d_b = self
.bulb_depth
.unwrap_or_else(|| r * (PI / 3.0).cos() / (PI / 6.0).cos() + r + b * (PI / 6.0).tan());
let mut points = Vec::new();
points.push(Point::new(-t * 0.5, 0.0));
points.push(Point::new(t * 0.5, 0.0));
let dc = r / (2.0 / 3.0 * PI / 2.0).sin();
let ptb0 = Point::new(
t * 0.5 + dc * (PI / 6.0).cos(),
d - d_b - dc * (PI / 3.0).cos(),
);
points.extend(draw_radius(ptb0, r, PI, n_r, false, PI / 3.0));
let ptb = Point::new(b + t * 0.5 - r, d - r);
let mut arc1 = draw_radius(ptb, r, -PI / 3.0, n_r, true, PI / 3.0);
arc1.pop(); points.extend(arc1);
points.extend(draw_radius(ptb, r, 0.0, n_r, true, PI / 2.0));
points.push(Point::new(-t * 0.5, d));
Section::new(Polygon::new(points), vec![])
}
fn designation(&self) -> String {
format!(
"Bulb {:.0}x{:.0}x{:.0}",
self.depth * 1000.0,
self.bulb_width * 1000.0,
self.web_thickness * 1000.0
)
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::f64::consts::PI;
#[test]
fn i_section_basic() {
let i = ISection::new(0.3, 0.15, 0.007, 0.01, 0.012);
let sec = i.build();
assert!(sec.area() > 0.0);
let props = crate::section_properties::SectionProperties::from_section(&sec);
assert!(props.ix > 0.0);
assert!(props.iy > 0.0);
}
#[test]
fn i_section_from_designation() {
let i = ISection::from_designation("IPE300").expect("IPE300 should exist");
assert!((i.height - 0.3).abs() < 1e-6);
assert!((i.flange_width - 0.15).abs() < 1e-6);
let sec = i.build();
assert!(sec.area() > 0.0);
}
#[test]
fn channel_section() {
let c = ChannelSection::new(0.2, 0.07, 0.006, 0.009, 0.008, 0.0);
let sec = c.build();
assert!(sec.area() > 0.0);
let expected_area = 0.006 * 0.2 + 2.0 * 0.07 * 0.009;
assert!(
(sec.area() - expected_area).abs() / expected_area < 0.01,
"channel area = {}, expected {}",
sec.area(),
expected_area
);
}
#[test]
fn channel_section_with_lip_area() {
let c = ChannelSection::new(0.2, 0.07, 0.003, 0.005, 0.0, 0.015);
let sec = c.build();
let expected_area = 0.003 * 0.2 + 2.0 * 0.07 * 0.005 + 2.0 * 0.015 * 0.005;
assert!(
(sec.area() - expected_area).abs() / expected_area < 0.05,
"lipped channel area = {}, expected {}",
sec.area(),
expected_area
);
}
#[test]
fn angle_section() {
let a = AngleSection::equal_leg(0.1, 0.01);
let sec = a.build();
assert!(sec.area() > 0.0);
let props = crate::section_properties::SectionProperties::from_section(&sec);
assert!((props.ix - props.iy).abs() / props.ix < 0.05);
}
#[test]
fn angle_from_designation() {
let a = AngleSection::from_designation("L100X100X8").expect("L100X100X8 should exist");
assert!((a.leg_a - 0.1).abs() < 1e-6);
assert!((a.leg_b - 0.1).abs() < 1e-6);
assert!((a.thickness - 0.008).abs() < 1e-6);
}
#[test]
fn tee_section() {
let t = TeeSection::new(0.2, 0.1, 0.006, 0.01, 0.008);
let sec = t.build();
assert!(sec.area() > 0.0);
}
#[test]
fn rhs_section() {
let rhs = RectangularHollowSection::new(0.2, 0.1, 0.005, 0.0, 0.0);
let sec = rhs.build();
assert!(sec.area() > 0.0);
let expected = 0.2 * 0.1 - 0.19 * 0.09;
assert!((sec.area() - expected).abs() < 1e-6);
}
#[test]
fn chs_section_lib() {
let chs = CircularHollowSectionLib::new(0.2191, 0.0082); let sec = chs.build();
let expected = PI * (0.10955_f64.powi(2) - 0.10135_f64.powi(2));
assert!((sec.area() - expected).abs() < 1e-4);
}
#[test]
fn z_section() {
let z = ZSection::new(0.2, 0.07, 0.002, 0.002, 0.015);
let sec = z.build();
assert!(sec.area() > 0.0);
}
#[test]
fn z_section_area_and_centroid() {
let h = 0.2;
let b = 0.07;
let s = 0.002;
let t = 0.002;
let lip = 0.015;
let z = ZSection::new(h, b, s, t, lip);
let sec = z.build();
let area = sec.area();
let expected = s * h + 2.0 * b * t + 2.0 * lip * t;
assert!(
(area - expected).abs() / expected < 1e-6,
"Z-section area: got {}, expected {}",
area,
expected
);
let c = sec.centroid();
assert!(
(c.x - s / 2.0).abs() < 1e-9,
"Z-section cx: got {}, expected {}",
c.x,
s / 2.0
);
assert!(c.y.abs() < 1e-9, "Z-section cy: got {}, expected 0", c.y);
}
#[test]
fn z_section_no_lip_area() {
let h = 0.2;
let b = 0.07;
let s = 0.002;
let t = 0.002;
let z = ZSection::new(h, b, s, t, 0.0);
let sec = z.build();
let area = sec.area();
let expected = s * h + 2.0 * b * t;
assert!(
(area - expected).abs() / expected < 1e-6,
"Z-section (no lip) area: got {}, expected {}",
area,
expected
);
}
#[test]
fn nastran_chan_area() {
let chan = NastranChan::new(200.0, 50.0, 5.0, 10.0);
let sec = chan.build();
let area = sec.area();
let h = 0.2;
let b = 0.05;
let tw = 0.005;
let tf = 0.01;
let expected = tw * h + 2.0 * b * tf;
assert!(
(area - expected).abs() / expected < 1e-6,
"NastranChan area: got {}, expected {}",
area,
expected
);
}
#[test]
fn monosymmetric_i_section() {
let mono = MonosymmetricISection::new(0.2, 0.05, 0.13, 0.012, 0.008, 0.006, 0.008, 16);
let sec = mono.build();
assert!(sec.area() > 0.0);
let expected = 0.006 * 0.2 + 0.05 * 0.012 + 0.13 * 0.008;
assert!(
(sec.area() - expected).abs() / expected < 0.1,
"Mono-I area: got {}, expected {}",
sec.area(),
expected
);
}
#[test]
fn tapered_flange_i_section() {
let tfi = TaperedFlangeISection::new(0.588, 0.191, 0.0272, 0.0152, 0.0178, 0.0089, 8.0, 16);
let sec = tfi.build();
assert!(sec.area() > 0.0);
let props = crate::section_properties::SectionProperties::from_section(&sec);
assert!(props.ix > 0.0);
assert!(props.iy > 0.0);
}
#[test]
fn tapered_flange_i_no_radius() {
let tfi = TaperedFlangeISection::new(0.2, 0.1, 0.01, 0.006, 0.0, 0.0, 8.0, 1);
let sec = tfi.build();
assert!(sec.area() > 0.0);
}
#[test]
fn tapered_flange_channel() {
let tfc = TaperedFlangeChannel::new(0.254, 0.089, 0.0146, 0.0061, 0.0178, 0.0089, 8.0, 16);
let sec = tfc.build();
assert!(sec.area() > 0.0);
}
#[test]
fn tapered_flange_channel_no_radius() {
let tfc = TaperedFlangeChannel::new(0.2, 0.1, 0.01, 0.006, 0.0, 0.0, 8.0, 1);
let sec = tfc.build();
assert!(sec.area() > 0.0);
}
#[test]
fn box_girder_section() {
let bg = BoxGirderSection::new(1.2, 1.2, 0.4, 0.1, 0.08, 0.05);
let sec = bg.build();
assert!(sec.area() > 0.0);
let outer = 0.5 * (1.2 + 0.4) * 1.2;
assert!(sec.area() < outer);
}
#[test]
fn box_girder_symmetric() {
let bg = BoxGirderSection::new(1.0, 0.6, 0.6, 0.05, 0.05, 0.03);
let sec = bg.build();
let expected = 0.6 * 1.0 - (0.6 - 2.0 * 0.03) * (1.0 - 2.0 * 0.05);
assert!(
(sec.area() - expected).abs() / expected < 0.01,
"Box girder symm: got {}, expected {}",
sec.area(),
expected
);
}
#[test]
fn bulb_section() {
let bulb = BulbSection::new(0.24, 0.034, 0.012, 0.01, 16);
let sec = bulb.build();
assert!(sec.area() > 0.0);
assert!(sec.area() > 0.012 * 0.24);
}
#[test]
fn bulb_section_with_depth() {
let bulb = BulbSection::with_bulb_depth(0.24, 0.034, 0.012, 0.01, 16, 0.05);
let sec = bulb.build();
assert!(sec.area() > 0.0);
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct NastranBar {
pub diameter: f64, }
impl NastranBar {
pub fn new(diameter: f64) -> Self {
assert!(diameter > 0.0);
Self { diameter }
}
}
impl ParametricSection for NastranBar {
fn build(&self) -> Section {
use crate::section_library::circle_polygon;
Section::new(circle_polygon(self.diameter / 2000.0, 32), Vec::new())
}
fn designation(&self) -> String {
format!("NASTRAN BAR Ø{:.1}", self.diameter)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct NastranBox {
pub width: f64, pub height: f64, pub thickness: f64, }
impl NastranBox {
pub fn new(width: f64, height: f64, thickness: f64) -> Self {
assert!(width > 0.0 && height > 0.0 && thickness > 0.0);
assert!(2.0 * thickness < width.min(height));
Self {
width,
height,
thickness,
}
}
}
impl ParametricSection for NastranBox {
fn build(&self) -> Section {
use crate::section_library::rectangle_polygon;
let outer = rectangle_polygon(self.width / 1000.0, self.height / 1000.0);
let inner = rectangle_polygon(
(self.width - 2.0 * self.thickness) / 1000.0,
(self.height - 2.0 * self.thickness) / 1000.0,
);
Section::new(outer, vec![inner])
}
fn designation(&self) -> String {
format!(
"NASTRAN BOX {:.1}x{:.1}x{:.1}",
self.width, self.height, self.thickness
)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct NastranChan {
pub height: f64, pub width: f64, pub web_thick: f64, pub flange_thick: f64, }
impl NastranChan {
pub fn new(height: f64, width: f64, web_thick: f64, flange_thick: f64) -> Self {
assert!(height > 0.0 && width > 0.0 && web_thick > 0.0 && flange_thick > 0.0);
Self {
height,
width,
web_thick,
flange_thick,
}
}
}
impl ParametricSection for NastranChan {
fn build(&self) -> Section {
let h = self.height / 1000.0;
let b = self.width / 1000.0;
let tw = self.web_thick / 1000.0;
let tf = self.flange_thick / 1000.0;
let hh = h / 2.0;
let vertices = vec![
crate::geometry::Point::new(0.0, -hh),
crate::geometry::Point::new(tw, -hh),
crate::geometry::Point::new(tw + b, -hh),
crate::geometry::Point::new(tw + b, -hh + tf),
crate::geometry::Point::new(tw, -hh + tf),
crate::geometry::Point::new(tw, hh - tf),
crate::geometry::Point::new(tw + b, hh - tf),
crate::geometry::Point::new(tw + b, hh),
crate::geometry::Point::new(tw, hh),
crate::geometry::Point::new(0.0, hh),
];
Section::new(crate::geometry::Polygon::new(vertices), Vec::new())
}
fn designation(&self) -> String {
format!(
"NASTRAN CHAN {:.1}x{:.1}x{:.1}x{:.1}",
self.height, self.width, self.web_thick, self.flange_thick
)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct NastranCross {
pub height: f64, pub width: f64, pub thickness: f64, }
impl NastranCross {
pub fn new(height: f64, width: f64, thickness: f64) -> Self {
assert!(height > 0.0 && width > 0.0 && thickness > 0.0);
assert!(thickness < height.min(width));
Self {
height,
width,
thickness,
}
}
}
impl ParametricSection for NastranCross {
fn build(&self) -> Section {
let h = self.height / 1000.0;
let b = self.width / 1000.0;
let t = self.thickness / 1000.0;
let mut vertices = Vec::new();
let vw = t / 2.0;
let vh = h / 2.0;
let hw = b / 2.0;
let hh = t / 2.0;
vertices.push(crate::geometry::Point::new(-vw, -vh));
vertices.push(crate::geometry::Point::new(vw, -vh));
vertices.push(crate::geometry::Point::new(vw, -hh));
vertices.push(crate::geometry::Point::new(hw, -hh));
vertices.push(crate::geometry::Point::new(hw, hh));
vertices.push(crate::geometry::Point::new(vw, hh));
vertices.push(crate::geometry::Point::new(vw, vh));
vertices.push(crate::geometry::Point::new(-vw, vh));
vertices.push(crate::geometry::Point::new(-vw, hh));
vertices.push(crate::geometry::Point::new(-hw, hh));
vertices.push(crate::geometry::Point::new(-hw, -hh));
vertices.push(crate::geometry::Point::new(-vw, -hh));
Section::new(crate::geometry::Polygon::new(vertices), Vec::new())
}
fn designation(&self) -> String {
format!(
"NASTRAN CROSS {:.1}x{:.1}x{:.1}",
self.height, self.width, self.thickness
)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct NastranI {
pub height: f64, pub width: f64, pub web_thick: f64, pub flange_thick: f64, }
impl NastranI {
pub fn new(height: f64, width: f64, web_thick: f64, flange_thick: f64) -> Self {
assert!(height > 0.0 && width > 0.0 && web_thick > 0.0 && flange_thick > 0.0);
assert!(2.0 * flange_thick < height);
assert!(web_thick < width);
Self {
height,
width,
web_thick,
flange_thick,
}
}
}
impl ParametricSection for NastranI {
fn build(&self) -> Section {
let i_sec = ISection::new(
self.height / 1000.0,
self.width / 1000.0,
self.web_thick / 1000.0,
self.flange_thick / 1000.0,
0.0, );
i_sec.build()
}
fn designation(&self) -> String {
format!(
"NASTRAN I {:.1}x{:.1}x{:.1}x{:.1}",
self.height, self.width, self.web_thick, self.flange_thick
)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct NastranTee {
pub height: f64, pub width: f64, pub web_thick: f64, pub flange_thick: f64, }
impl NastranTee {
pub fn new(height: f64, width: f64, web_thick: f64, flange_thick: f64) -> Self {
assert!(height > 0.0 && width > 0.0 && web_thick > 0.0 && flange_thick > 0.0);
assert!(flange_thick < height);
Self {
height,
width,
web_thick,
flange_thick,
}
}
}
impl ParametricSection for NastranTee {
fn build(&self) -> Section {
let t_sec = TeeSection::new(
self.height / 1000.0,
self.width / 1000.0,
self.web_thick / 1000.0,
self.flange_thick / 1000.0,
0.0,
);
t_sec.build()
}
fn designation(&self) -> String {
format!(
"NASTRAN TEE {:.1}x{:.1}x{:.1}x{:.1}",
self.height, self.width, self.web_thick, self.flange_thick
)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct NastranTube {
pub outer_diameter: f64, pub wall_thickness: f64, }
impl NastranTube {
pub fn new(outer_diameter: f64, wall_thickness: f64) -> Self {
assert!(outer_diameter > 0.0 && wall_thickness > 0.0);
assert!(2.0 * wall_thickness < outer_diameter);
Self {
outer_diameter,
wall_thickness,
}
}
}
impl ParametricSection for NastranTube {
fn build(&self) -> Section {
use crate::section_library::hollow_circle_polygon;
let ro = self.outer_diameter / 2000.0;
let ri = ro - self.wall_thickness / 1000.0;
let (outer, inner) = hollow_circle_polygon(ro, ri, 48);
Section::new(outer, vec![inner])
}
fn designation(&self) -> String {
format!(
"NASTRAN TUBE Ø{:.1}x{:.1}",
self.outer_diameter, self.wall_thickness
)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct NastranZed {
pub height: f64, pub width: f64, pub web_thick: f64, pub flange_thick: f64, }
impl NastranZed {
pub fn new(height: f64, width: f64, web_thick: f64, flange_thick: f64) -> Self {
assert!(height > 0.0 && width > 0.0 && web_thick > 0.0 && flange_thick > 0.0);
Self {
height,
width,
web_thick,
flange_thick,
}
}
}
impl ParametricSection for NastranZed {
fn build(&self) -> Section {
let z_sec = ZSection::new(
self.height / 1000.0,
self.width / 1000.0,
self.web_thick / 1000.0,
self.flange_thick / 1000.0,
0.0, );
z_sec.build()
}
fn designation(&self) -> String {
format!(
"NASTRAN ZED {:.1}x{:.1}x{:.1}x{:.1}",
self.height, self.width, self.web_thick, self.flange_thick
)
}
}
impl NastranChan {
pub fn standard_c3x4_1() -> Self {
Self::new(76.2, 34.9, 4.4, 6.9)
} pub fn standard_c4x5_4() -> Self {
Self::new(101.6, 38.1, 4.8, 8.1)
} pub fn standard_c5x6_7() -> Self {
Self::new(127.0, 41.3, 5.1, 8.9)
} pub fn standard_c6x8_2() -> Self {
Self::new(152.4, 44.5, 5.1, 9.7)
} pub fn standard_c7x9_8() -> Self {
Self::new(177.8, 47.6, 5.3, 10.4)
} pub fn standard_c8x11_5() -> Self {
Self::new(203.2, 50.8, 5.6, 11.2)
} pub fn standard_c9x13_4() -> Self {
Self::new(228.6, 53.3, 6.1, 11.9)
} pub fn standard_c10x15_3() -> Self {
Self::new(254.0, 55.9, 6.4, 12.7)
} pub fn standard_c12x20_7() -> Self {
Self::new(304.8, 63.5, 7.1, 14.5)
} pub fn standard_c15x33_9() -> Self {
Self::new(381.0, 76.2, 10.2, 16.8)
} }
impl NastranI {
pub fn standard_w4x13() -> Self {
Self::new(101.6, 101.6, 5.8, 6.4)
} pub fn standard_w6x15() -> Self {
Self::new(152.4, 101.6, 5.8, 6.6)
} pub fn standard_w8x18() -> Self {
Self::new(203.2, 133.4, 6.1, 7.4)
} pub fn standard_w10x22() -> Self {
Self::new(254.0, 146.1, 6.1, 8.6)
} pub fn standard_w12x26() -> Self {
Self::new(304.8, 165.1, 6.4, 9.7)
} pub fn standard_w14x30() -> Self {
Self::new(355.6, 177.8, 6.9, 9.7)
} pub fn standard_w16x31() -> Self {
Self::new(406.4, 203.2, 7.4, 9.9)
} pub fn standard_w18x35() -> Self {
Self::new(457.2, 203.2, 7.6, 10.4)
} pub fn standard_w21x44() -> Self {
Self::new(533.4, 203.2, 8.9, 11.2)
} pub fn standard_w24x55() -> Self {
Self::new(609.6, 203.2, 9.7, 12.7)
} }
impl NastranTube {
pub fn standard_25x3() -> Self {
Self::new(25.0, 3.0)
}
pub fn standard_32x3() -> Self {
Self::new(32.0, 3.0)
}
pub fn standard_38x4() -> Self {
Self::new(38.0, 4.0)
}
pub fn standard_51x5() -> Self {
Self::new(51.0, 5.0)
}
pub fn standard_63x6() -> Self {
Self::new(63.0, 6.0)
}
pub fn standard_76x6() -> Self {
Self::new(76.0, 6.0)
}
pub fn standard_102x8() -> Self {
Self::new(102.0, 8.0)
}
pub fn standard_152x10() -> Self {
Self::new(152.0, 10.0)
}
}
impl NastranZed {
pub fn standard_z100() -> Self {
Self::new(100.0, 50.0, 2.0, 2.0)
}
pub fn standard_z150() -> Self {
Self::new(150.0, 60.0, 2.5, 2.5)
}
pub fn standard_z200() -> Self {
Self::new(200.0, 70.0, 3.0, 3.0)
}
pub fn standard_z250() -> Self {
Self::new(250.0, 80.0, 3.5, 3.5)
}
pub fn standard_z300() -> Self {
Self::new(300.0, 90.0, 4.0, 4.0)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SuperTGirder {
pub girder_type: SuperTType,
pub top_flange_width: f64,
pub top_flange_thick: f64,
pub bot_flange_width: f64,
pub bot_flange_thick: f64,
pub web_thick: f64,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum SuperTType {
Type1000, Type1200, Type1400, Type1600, Type1800, Type2000, }
impl SuperTGirder {
pub fn new(girder_type: SuperTType) -> Self {
let (_depth, tfw, tfth, bfw, bfth, tw) = match girder_type {
SuperTType::Type1000 => (1000.0, 1000.0, 150.0, 1000.0, 150.0, 200.0),
SuperTType::Type1200 => (1200.0, 1200.0, 150.0, 1200.0, 150.0, 200.0),
SuperTType::Type1400 => (1400.0, 1400.0, 150.0, 1400.0, 150.0, 200.0),
SuperTType::Type1600 => (1600.0, 1600.0, 150.0, 1600.0, 150.0, 200.0),
SuperTType::Type1800 => (1800.0, 1800.0, 150.0, 1800.0, 150.0, 200.0),
SuperTType::Type2000 => (2000.0, 2000.0, 150.0, 2000.0, 150.0, 200.0),
};
Self {
girder_type,
top_flange_width: tfw,
top_flange_thick: tfth,
bot_flange_width: bfw,
bot_flange_thick: bfth,
web_thick: tw,
}
}
pub fn custom(
_depth: f64,
top_flange_width: f64,
top_flange_thick: f64,
bot_flange_width: f64,
bot_flange_thick: f64,
web_thick: f64,
) -> Self {
Self {
girder_type: SuperTType::Type1000, top_flange_width,
top_flange_thick,
bot_flange_width,
bot_flange_thick,
web_thick,
}
}
}
impl ParametricSection for SuperTGirder {
fn build(&self) -> Section {
let h = match self.girder_type {
SuperTType::Type1000 => 1000.0,
SuperTType::Type1200 => 1200.0,
SuperTType::Type1400 => 1400.0,
SuperTType::Type1600 => 1600.0,
SuperTType::Type1800 => 1800.0,
SuperTType::Type2000 => 2000.0,
} / 1000.0;
let tfw = self.top_flange_width / 1000.0;
let tfth = self.top_flange_thick / 1000.0;
let bfw = self.bot_flange_width / 1000.0;
let bfth = self.bot_flange_thick / 1000.0;
let tw = self.web_thick / 1000.0;
let hh = h / 2.0;
let tfw2 = tfw / 2.0;
let bfw2 = bfw / 2.0;
let tw2 = tw / 2.0;
let mut vertices = Vec::new();
vertices.push(crate::geometry::Point::new(-tfw2, hh));
vertices.push(crate::geometry::Point::new(tfw2, hh));
vertices.push(crate::geometry::Point::new(tfw2, hh - tfth));
vertices.push(crate::geometry::Point::new(tw2, hh - tfth));
vertices.push(crate::geometry::Point::new(tw2, -hh + bfth));
vertices.push(crate::geometry::Point::new(bfw2, -hh + bfth));
vertices.push(crate::geometry::Point::new(bfw2, -hh));
vertices.push(crate::geometry::Point::new(-bfw2, -hh));
vertices.push(crate::geometry::Point::new(-bfw2, -hh + bfth));
vertices.push(crate::geometry::Point::new(-tw2, -hh + bfth));
vertices.push(crate::geometry::Point::new(-tw2, hh - tfth));
vertices.push(crate::geometry::Point::new(-tfw2, hh - tfth));
Section::new(crate::geometry::Polygon::new(vertices), Vec::new())
}
fn designation(&self) -> String {
format!("Super-T {:?}", self.girder_type)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct IGirder {
pub girder_type: IGirderType,
pub custom_dims: Option<(f64, f64, f64, f64, f64, f64)>, }
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum IGirderType {
TypeI, TypeII, TypeIII, TypeIV, TypeV, TypeVI, BT54, BT63, BT72, Custom,
}
impl IGirder {
pub fn new(girder_type: IGirderType) -> Self {
Self {
girder_type,
custom_dims: None,
}
}
pub fn custom(
depth: f64,
top_w: f64,
top_th: f64,
bot_w: f64,
bot_th: f64,
web_th: f64,
) -> Self {
Self {
girder_type: IGirderType::Custom,
custom_dims: Some((depth, top_w, top_th, bot_w, bot_th, web_th)),
}
}
}
impl ParametricSection for IGirder {
fn build(&self) -> Section {
let (h, tfw, tfth, bfw, bfth, tw) = if let Some(dims) = self.custom_dims {
dims
} else {
match self.girder_type {
IGirderType::TypeI => (711.0, 406.0, 89.0, 406.0, 89.0, 152.0),
IGirderType::TypeII => (914.0, 406.0, 89.0, 406.0, 89.0, 152.0),
IGirderType::TypeIII => (1143.0, 406.0, 102.0, 406.0, 102.0, 178.0),
IGirderType::TypeIV => (1372.0, 406.0, 114.0, 406.0, 114.0, 178.0),
IGirderType::TypeV => (1600.0, 406.0, 127.0, 406.0, 127.0, 178.0),
IGirderType::TypeVI => (1829.0, 406.0, 140.0, 406.0, 140.0, 203.0),
IGirderType::BT54 => (1372.0, 610.0, 102.0, 610.0, 102.0, 178.0),
IGirderType::BT63 => (1600.0, 610.0, 114.0, 610.0, 114.0, 178.0),
IGirderType::BT72 => (1829.0, 610.0, 127.0, 610.0, 127.0, 203.0),
IGirderType::Custom => (1000.0, 500.0, 100.0, 500.0, 100.0, 200.0), }
};
let h = h / 1000.0;
let tfw = tfw / 1000.0;
let tfth = tfth / 1000.0;
let bfw = bfw / 1000.0;
let bfth = bfth / 1000.0;
let tw = tw / 1000.0;
let hh = h / 2.0;
let tfw2 = tfw / 2.0;
let bfw2 = bfw / 2.0;
let tw2 = tw / 2.0;
let mut vertices = Vec::new();
vertices.push(crate::geometry::Point::new(-tfw2, hh));
vertices.push(crate::geometry::Point::new(tfw2, hh));
vertices.push(crate::geometry::Point::new(tfw2, hh - tfth));
vertices.push(crate::geometry::Point::new(tw2, hh - tfth));
vertices.push(crate::geometry::Point::new(tw2, -hh + bfth));
vertices.push(crate::geometry::Point::new(bfw2, -hh + bfth));
vertices.push(crate::geometry::Point::new(bfw2, -hh));
vertices.push(crate::geometry::Point::new(-bfw2, -hh));
vertices.push(crate::geometry::Point::new(-bfw2, -hh + bfth));
vertices.push(crate::geometry::Point::new(-tw2, -hh + bfth));
vertices.push(crate::geometry::Point::new(-tw2, hh - tfth));
vertices.push(crate::geometry::Point::new(-tfw2, hh - tfth));
Section::new(crate::geometry::Polygon::new(vertices), Vec::new())
}
fn designation(&self) -> String {
format!("I-Girder {:?}", self.girder_type)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct UGirder {
pub depth: f64, pub bottom_width: f64, pub top_width: f64, pub web_thick: f64, pub flange_thick: f64, }
impl UGirder {
pub fn new(
depth: f64,
bottom_width: f64,
top_width: f64,
web_thick: f64,
flange_thick: f64,
) -> Self {
Self {
depth,
bottom_width,
top_width,
web_thick,
flange_thick,
}
}
}
impl ParametricSection for UGirder {
fn build(&self) -> Section {
let h = self.depth / 1000.0;
let bw = self.bottom_width / 1000.0;
let tw = self.top_width / 1000.0;
let wth = self.web_thick / 1000.0;
let fth = self.flange_thick / 1000.0;
let hh = h / 2.0;
let bw2 = bw / 2.0;
let tw2 = tw / 2.0;
let wth2 = wth / 2.0;
let mut vertices = Vec::new();
vertices.push(crate::geometry::Point::new(-tw2, hh));
vertices.push(crate::geometry::Point::new(tw2, hh));
vertices.push(crate::geometry::Point::new(tw2, hh - fth));
vertices.push(crate::geometry::Point::new(wth2, hh - fth));
vertices.push(crate::geometry::Point::new(wth2, -hh + fth));
vertices.push(crate::geometry::Point::new(bw2, -hh + fth));
vertices.push(crate::geometry::Point::new(bw2, -hh));
vertices.push(crate::geometry::Point::new(-bw2, -hh));
vertices.push(crate::geometry::Point::new(-bw2, -hh + fth));
vertices.push(crate::geometry::Point::new(-wth2, -hh + fth));
vertices.push(crate::geometry::Point::new(-wth2, hh - fth));
vertices.push(crate::geometry::Point::new(-tw2, hh - fth));
Section::new(crate::geometry::Polygon::new(vertices), Vec::new())
}
fn designation(&self) -> String {
format!(
"U-Girder {:.0}x{:.0}x{:.0}",
self.depth, self.bottom_width, self.web_thick
)
}
}