1use crate::geometry::{Point, Polygon};
6use crate::material::Material;
7use crate::section::Section;
8use crate::section_library::{ParametricSection, rectangle_polygon};
9
10#[derive(Debug, Clone, Copy, PartialEq)]
12pub struct SolidRectangularTimber {
13 pub width: f64, pub height: f64, }
16
17impl SolidRectangularTimber {
18 pub fn new(width: f64, height: f64) -> Self {
19 assert!(width > 0.0 && height > 0.0, "Dimensions must be positive");
20 Self { width, height }
21 }
22
23 pub fn from_designation(designation: &str) -> Option<Self> {
25 let dims = match designation.to_uppercase().as_str() {
27 "38X75" => (38.0, 75.0),
28 "38X100" => (38.0, 100.0),
29 "38X125" => (38.0, 125.0),
30 "38X150" => (38.0, 150.0),
31 "38X175" => (38.0, 175.0),
32 "38X200" => (38.0, 200.0),
33 "38X225" => (38.0, 225.0),
34 "38X250" => (38.0, 250.0),
35 "47X75" => (47.0, 75.0),
36 "47X100" => (47.0, 100.0),
37 "47X125" => (47.0, 125.0),
38 "47X150" => (47.0, 150.0),
39 "47X175" => (47.0, 175.0),
40 "47X200" => (47.0, 200.0),
41 "47X225" => (47.0, 225.0),
42 "47X250" => (47.0, 250.0),
43 "50X100" => (50.0, 100.0),
44 "50X150" => (50.0, 150.0),
45 "50X200" => (50.0, 200.0),
46 "50X250" => (50.0, 250.0),
47 "50X300" => (50.0, 300.0),
48 "63X100" => (63.0, 100.0),
49 "63X125" => (63.0, 125.0),
50 "63X150" => (63.0, 150.0),
51 "63X175" => (63.0, 175.0),
52 "63X200" => (63.0, 200.0),
53 "63X225" => (63.0, 225.0),
54 "63X250" => (63.0, 250.0),
55 "63X300" => (63.0, 300.0),
56 "75X100" => (75.0, 100.0),
57 "75X150" => (75.0, 150.0),
58 "75X200" => (75.0, 200.0),
59 "75X250" => (75.0, 250.0),
60 "75X300" => (75.0, 300.0),
61 "100X100" => (100.0, 100.0),
62 "100X150" => (100.0, 150.0),
63 "100X200" => (100.0, 200.0),
64 "100X250" => (100.0, 250.0),
65 "100X300" => (100.0, 300.0),
66 "150X150" => (150.0, 150.0),
67 "150X200" => (150.0, 200.0),
68 "150X250" => (150.0, 250.0),
69 "150X300" => (150.0, 300.0),
70 "200X200" => (200.0, 200.0),
71 "200X250" => (200.0, 250.0),
72 "200X300" => (200.0, 300.0),
73 _ => return None,
74 };
75
76 let (b, h) = dims;
77 Some(Self::new(b / 1000.0, h / 1000.0))
78 }
79}
80
81impl ParametricSection for SolidRectangularTimber {
82 fn build(&self) -> Section {
83 Section::new(rectangle_polygon(self.width, self.height), Vec::new())
84 }
85
86 fn designation(&self) -> String {
87 format!(
88 "TIMBER RECT {:.0}x{:.0}",
89 self.width * 1000.0,
90 self.height * 1000.0
91 )
92 }
93}
94
95#[derive(Debug, Clone, Copy, PartialEq)]
97pub struct SolidCircularTimber {
98 pub diameter: f64,
99 pub n_vertices: usize,
100}
101
102impl SolidCircularTimber {
103 pub fn new(diameter: f64) -> Self {
104 Self::with_vertices(diameter, 64)
105 }
106
107 pub fn with_vertices(diameter: f64, n_vertices: usize) -> Self {
108 assert!(diameter > 0.0, "Diameter must be positive");
109 assert!(n_vertices >= 8, "At least 8 vertices");
110 Self {
111 diameter,
112 n_vertices,
113 }
114 }
115}
116
117impl ParametricSection for SolidCircularTimber {
118 fn build(&self) -> Section {
119 use crate::section_library::circle_polygon;
120 Section::new(
121 circle_polygon(self.diameter / 2.0, self.n_vertices),
122 Vec::new(),
123 )
124 }
125
126 fn designation(&self) -> String {
127 format!("TIMBER LOG Ø{:.0}", self.diameter * 1000.0)
128 }
129}
130
131#[derive(Debug, Clone, Copy, PartialEq)]
133pub struct GlulamRectangular {
134 pub width: f64,
135 pub height: f64,
136 pub lamination_thickness: f64, pub n_laminations: usize, }
139
140impl GlulamRectangular {
141 pub fn new(width: f64, height: f64, lamination_thickness: f64) -> Self {
142 assert!(width > 0.0 && height > 0.0 && lamination_thickness > 0.0);
143 let n_lam = (height / lamination_thickness).round() as usize;
144 assert!(n_lam >= 2, "At least 2 laminations");
145 Self {
146 width,
147 height,
148 lamination_thickness,
149 n_laminations: n_lam,
150 }
151 }
152
153 pub fn from_designation(designation: &str) -> Option<Self> {
155 let upper = designation.to_uppercase();
157 if upper.starts_with("GL") {
158 let rest = &upper[2..];
159 let parts: Vec<&str> = rest.split('X').collect();
160 if parts.len() == 2 {
161 let w = parts[0].parse::<f64>().ok()?;
162 let h = parts[1].parse::<f64>().ok()?;
163 let lam_t = if h <= 300.0 { 33.0 } else { 45.0 };
165 return Some(Self::new(w / 1000.0, h / 1000.0, lam_t / 1000.0));
166 }
167 }
168 None
169 }
170}
171
172impl ParametricSection for GlulamRectangular {
173 fn build(&self) -> Section {
174 Section::new(rectangle_polygon(self.width, self.height), Vec::new())
177 }
178
179 fn designation(&self) -> String {
180 format!(
181 "GLULAM {:.0}x{:.0} (lam={:.0}mm x{})",
182 self.width * 1000.0,
183 self.height * 1000.0,
184 self.lamination_thickness * 1000.0,
185 self.n_laminations
186 )
187 }
188}
189
190#[derive(Debug, Clone, Copy, PartialEq)]
192pub struct GlulamCurved {
193 pub width: f64,
194 pub height: f64,
195 pub radius: f64, pub angle: f64, pub lamination_thickness: f64,
198}
199
200impl GlulamCurved {
201 pub fn new(
202 width: f64,
203 height: f64,
204 radius: f64,
205 angle: f64,
206 lamination_thickness: f64,
207 ) -> Self {
208 assert!(width > 0.0 && height > 0.0 && radius > 0.0 && angle > 0.0);
209 assert!(lamination_thickness > 0.0);
210 Self {
211 width,
212 height,
213 radius,
214 angle,
215 lamination_thickness,
216 }
217 }
218}
219
220impl ParametricSection for GlulamCurved {
221 fn build(&self) -> Section {
222 Section::new(rectangle_polygon(self.width, self.height), Vec::new())
224 }
225
226 fn designation(&self) -> String {
227 format!(
228 "GLULAM CURVED {:.0}x{:.0} R{:.0} ∠{:.1}°",
229 self.width * 1000.0,
230 self.height * 1000.0,
231 self.radius * 1000.0,
232 self.angle.to_degrees()
233 )
234 }
235}
236
237#[derive(Debug, Clone, PartialEq)]
239pub struct CLTPanel {
240 pub thickness: f64,
241 pub layers: Vec<CLTLayer>,
242 pub width: f64, }
244
245#[derive(Debug, Clone, Copy, PartialEq)]
246pub struct CLTLayer {
247 pub thickness: f64,
248 pub orientation: CLTOrientation,
249 pub grade: CLTGrade,
250}
251
252#[derive(Debug, Clone, Copy, PartialEq, Eq)]
253pub enum CLTOrientation {
254 Longitudinal, Transverse, }
257
258#[derive(Debug, Clone, Copy, PartialEq, Eq)]
259pub enum CLTGrade {
260 C16,
261 C24,
262 C30, GL24h,
264 GL28h,
265 GL32h, }
267
268impl CLTPanel {
269 pub fn new(thickness: f64, layers: Vec<CLTLayer>, width: f64) -> Self {
270 assert!(thickness > 0.0 && width > 0.0);
271 assert!(!layers.is_empty(), "At least one layer");
272 let sum_t: f64 = layers.iter().map(|l| l.thickness).sum();
273 assert!(
274 (sum_t - thickness).abs() < 1e-6,
275 "Layer thicknesses must sum to total thickness"
276 );
277 Self {
278 thickness,
279 layers,
280 width,
281 }
282 }
283
284 pub fn three_layer(thickness: f64, _lam_thickness: f64, width: f64) -> Self {
286 let t = thickness / 3.0;
287 Self::new(
288 thickness,
289 vec![
290 CLTLayer {
291 thickness: t,
292 orientation: CLTOrientation::Longitudinal,
293 grade: CLTGrade::C24,
294 },
295 CLTLayer {
296 thickness: t,
297 orientation: CLTOrientation::Transverse,
298 grade: CLTGrade::C24,
299 },
300 CLTLayer {
301 thickness: t,
302 orientation: CLTOrientation::Longitudinal,
303 grade: CLTGrade::C24,
304 },
305 ],
306 width,
307 )
308 }
309
310 pub fn five_layer(thickness: f64, _lam_thickness: f64, width: f64) -> Self {
312 let t = thickness / 5.0;
313 Self::new(
314 thickness,
315 vec![
316 CLTLayer {
317 thickness: t,
318 orientation: CLTOrientation::Longitudinal,
319 grade: CLTGrade::C24,
320 },
321 CLTLayer {
322 thickness: t,
323 orientation: CLTOrientation::Transverse,
324 grade: CLTGrade::C24,
325 },
326 CLTLayer {
327 thickness: t,
328 orientation: CLTOrientation::Longitudinal,
329 grade: CLTGrade::C24,
330 },
331 CLTLayer {
332 thickness: t,
333 orientation: CLTOrientation::Transverse,
334 grade: CLTGrade::C24,
335 },
336 CLTLayer {
337 thickness: t,
338 orientation: CLTOrientation::Longitudinal,
339 grade: CLTGrade::C24,
340 },
341 ],
342 width,
343 )
344 }
345
346 pub fn seven_layer(thickness: f64, _lam_thickness: f64, width: f64) -> Self {
348 let t = thickness / 7.0;
349 Self::new(
350 thickness,
351 vec![
352 CLTLayer {
353 thickness: t,
354 orientation: CLTOrientation::Longitudinal,
355 grade: CLTGrade::C24,
356 },
357 CLTLayer {
358 thickness: t,
359 orientation: CLTOrientation::Transverse,
360 grade: CLTGrade::C24,
361 },
362 CLTLayer {
363 thickness: t,
364 orientation: CLTOrientation::Longitudinal,
365 grade: CLTGrade::C24,
366 },
367 CLTLayer {
368 thickness: t,
369 orientation: CLTOrientation::Transverse,
370 grade: CLTGrade::C24,
371 },
372 CLTLayer {
373 thickness: t,
374 orientation: CLTOrientation::Longitudinal,
375 grade: CLTGrade::C24,
376 },
377 CLTLayer {
378 thickness: t,
379 orientation: CLTOrientation::Transverse,
380 grade: CLTGrade::C24,
381 },
382 CLTLayer {
383 thickness: t,
384 orientation: CLTOrientation::Longitudinal,
385 grade: CLTGrade::C24,
386 },
387 ],
388 width,
389 )
390 }
391
392 pub fn effective_bending_stiffness(&self, ref_material: &Material) -> f64 {
394 let mut ei = 0.0;
395 let mut z = -self.thickness / 2.0;
396 for layer in &self.layers {
397 let mat = match layer.grade {
398 CLTGrade::C16 => crate::material::presets::TIMBER_GL24H, CLTGrade::C24 => crate::material::presets::TIMBER_GL24H,
400 CLTGrade::C30 => crate::material::presets::TIMBER_GL24H,
401 CLTGrade::GL24h => crate::material::presets::TIMBER_GL24H,
402 _ => crate::material::presets::TIMBER_GL24H,
403 };
404 let n = mat.modular_ratio(ref_material);
405 let layer_z = z + layer.thickness / 2.0;
406 let i_self = self.width * layer.thickness.powi(3) / 12.0;
407 ei += n
408 * (mat.youngs_modulus * i_self
409 + mat.youngs_modulus * self.width * layer.thickness * layer_z.powi(2));
410 z += layer.thickness;
411 }
412 ei
413 }
414}
415
416impl ParametricSection for CLTPanel {
417 fn build(&self) -> Section {
418 Section::new(rectangle_polygon(self.width, self.thickness), Vec::new())
420 }
421
422 fn designation(&self) -> String {
423 format!(
424 "CLT {}L {:.0}mm x {:.0}mm",
425 self.layers.len(),
426 self.thickness * 1000.0,
427 self.width * 1000.0
428 )
429 }
430}
431
432#[derive(Debug, Clone, Copy, PartialEq)]
434pub struct BuiltUpTimber {
435 pub width: f64,
436 pub height: f64,
437 pub element_width: f64, pub element_height: f64, pub n_elements_wide: usize,
440 pub n_elements_high: usize,
441 pub gap: f64, }
443
444impl BuiltUpTimber {
445 pub fn new(width: f64, height: f64, element_width: f64, element_height: f64, gap: f64) -> Self {
446 assert!(width > 0.0 && height > 0.0);
447 assert!(element_width > 0.0 && element_height > 0.0);
448 assert!(gap >= 0.0);
449 let n_w = (width / (element_width + gap)).floor() as usize;
450 let n_h = (height / (element_height + gap)).floor() as usize;
451 assert!(n_w >= 1 && n_h >= 1);
452 Self {
453 width,
454 height,
455 element_width,
456 element_height,
457 n_elements_wide: n_w,
458 n_elements_high: n_h,
459 gap,
460 }
461 }
462
463 pub fn nail_laminated(width: f64, height: f64, board_size: (f64, f64), gap: f64) -> Self {
464 Self::new(width, height, board_size.0, board_size.1, gap)
465 }
466
467 pub fn dowel_laminated(width: f64, height: f64, board_size: (f64, f64)) -> Self {
468 Self::new(width, height, board_size.0, board_size.1, 0.0)
469 }
470}
471
472impl ParametricSection for BuiltUpTimber {
473 fn build(&self) -> Section {
474 let solid_area = self.width * self.height;
477 let board_area = self.element_width
478 * self.element_height
479 * self.n_elements_wide as f64
480 * self.n_elements_high as f64;
481 let _fill_factor = board_area / solid_area;
482
483 Section::new(rectangle_polygon(self.width, self.height), Vec::new())
485 }
486
487 fn designation(&self) -> String {
488 format!(
489 "BUILT-UP TIMBER {:.0}x{:.0} ({:.0}x{:.0} x{}x{})",
490 self.width * 1000.0,
491 self.height * 1000.0,
492 self.element_width * 1000.0,
493 self.element_height * 1000.0,
494 self.n_elements_wide,
495 self.n_elements_high
496 )
497 }
498
499 fn mass_per_length(&self, material: &Material) -> f64 {
500 let solid_area = self.width * self.height;
501 let board_area = self.element_width
502 * self.element_height
503 * self.n_elements_wide as f64
504 * self.n_elements_high as f64;
505 let fill_factor = board_area / solid_area;
506 solid_area * fill_factor * material.density
507 }
508}
509
510#[derive(Debug, Clone, Copy, PartialEq)]
512pub struct TimberIJoist {
513 pub height: f64,
514 pub flange_width: f64,
515 pub flange_thickness: f64,
516 pub web_thickness: f64,
517 pub flange_material: TimberFlangeMaterial,
518 pub web_material: TimberWebMaterial,
519}
520
521#[derive(Debug, Clone, Copy, PartialEq, Eq)]
522pub enum TimberFlangeMaterial {
523 SolidSawn, Glulam,
525}
526
527#[derive(Debug, Clone, Copy, PartialEq, Eq)]
528pub enum TimberWebMaterial {
529 OSB,
530 Plywood,
531 LVL,
532}
533
534impl TimberIJoist {
535 pub fn new(
536 height: f64,
537 flange_width: f64,
538 flange_thickness: f64,
539 web_thickness: f64,
540 flange_material: TimberFlangeMaterial,
541 web_material: TimberWebMaterial,
542 ) -> Self {
543 assert!(height > 0.0 && flange_width > 0.0);
544 assert!(flange_thickness > 0.0 && web_thickness > 0.0);
545 assert!(2.0 * flange_thickness < height);
546 Self {
547 height,
548 flange_width,
549 flange_thickness,
550 web_thickness,
551 flange_material,
552 web_material,
553 }
554 }
555
556 pub fn from_series(series: &str, depth_mm: f64) -> Option<Self> {
558 match series.to_uppercase().as_str() {
559 "TJI" => {
560 let (fw, ft, wt) = match depth_mm as i32 {
562 235..=241 => (38.0, 38.0, 9.5),
563 300..=302 => (38.0, 38.0, 9.5),
564 356..=360 => (38.0, 38.0, 11.0),
565 400..=406 => (38.0, 38.0, 11.0),
566 450..=457 => (38.0, 38.0, 12.5),
567 500..=510 => (38.0, 38.0, 12.5),
568 550..=560 => (38.0, 38.0, 14.0),
569 600..=610 => (38.0, 38.0, 14.0),
570 _ => return None,
571 };
572 Some(Self::new(
573 depth_mm / 1000.0,
574 fw / 1000.0,
575 ft / 1000.0,
576 wt / 1000.0,
577 TimberFlangeMaterial::SolidSawn,
578 TimberWebMaterial::OSB,
579 ))
580 }
581 "IJ" => {
582 let (fw, ft, wt) = match depth_mm as i32 {
584 200..=250 => (45.0, 35.0, 8.0),
585 251..=300 => (45.0, 35.0, 9.0),
586 301..=350 => (45.0, 35.0, 10.0),
587 351..=400 => (45.0, 35.0, 11.0),
588 401..=450 => (45.0, 40.0, 12.0),
589 451..=500 => (45.0, 40.0, 12.0),
590 _ => return None,
591 };
592 Some(Self::new(
593 depth_mm / 1000.0,
594 fw / 1000.0,
595 ft / 1000.0,
596 wt / 1000.0,
597 TimberFlangeMaterial::SolidSawn,
598 TimberWebMaterial::OSB,
599 ))
600 }
601 _ => None,
602 }
603 }
604}
605
606impl ParametricSection for TimberIJoist {
607 fn build(&self) -> Section {
608 let h = self.height;
611 let bf = self.flange_width;
612 let tf = self.flange_thickness;
613 let tw = self.web_thickness;
614
615 let bf2 = bf / 2.0;
616 let tw2 = tw / 2.0;
617 let hh = h / 2.0;
618
619 let mut vertices = Vec::new();
620
621 vertices.push(Point::new(-bf2, hh));
623 vertices.push(Point::new(bf2, hh));
624 vertices.push(Point::new(bf2, hh - tf));
625 vertices.push(Point::new(tw2, hh - tf));
626 vertices.push(Point::new(tw2, -hh + tf));
627 vertices.push(Point::new(bf2, -hh + tf));
628 vertices.push(Point::new(bf2, -hh));
629 vertices.push(Point::new(-bf2, -hh));
630 vertices.push(Point::new(-bf2, -hh + tf));
631 vertices.push(Point::new(-tw2, -hh + tf));
632 vertices.push(Point::new(-tw2, hh - tf));
633 vertices.push(Point::new(-bf2, hh - tf));
634
635 let mut clean = Vec::new();
636 for v in vertices {
637 if clean.last() != Some(&v) {
638 clean.push(v);
639 }
640 }
641 if clean.len() > 1 && clean[0] == clean[clean.len() - 1] {
642 clean.pop();
643 }
644
645 Section::new(Polygon::new(clean), Vec::new())
646 }
647
648 fn designation(&self) -> String {
649 format!(
650 "TIMBER I-JOIST {:.0}x{:.0}x{:.0}x{:.0}",
651 self.height * 1000.0,
652 self.flange_width * 1000.0,
653 self.flange_thickness * 1000.0,
654 self.web_thickness * 1000.0
655 )
656 }
657}
658
659#[derive(Debug, Clone, Copy, PartialEq)]
661pub struct TimberBoxBeam {
662 pub width: f64,
663 pub height: f64,
664 pub wall_thickness: f64,
665 pub web_spacing: f64, pub n_webs: usize,
667}
668
669impl TimberBoxBeam {
670 pub fn new(
671 width: f64,
672 height: f64,
673 wall_thickness: f64,
674 web_spacing: f64,
675 n_webs: usize,
676 ) -> Self {
677 assert!(width > 0.0 && height > 0.0);
678 assert!(wall_thickness > 0.0 && 2.0 * wall_thickness < width.min(height));
679 assert!(web_spacing > 0.0);
680 assert!(n_webs >= 1);
681 Self {
682 width,
683 height,
684 wall_thickness,
685 web_spacing,
686 n_webs,
687 }
688 }
689}
690
691impl ParametricSection for TimberBoxBeam {
692 fn build(&self) -> Section {
693 let w = self.width;
694 let h = self.height;
695 let t = self.wall_thickness;
696
697 let outer = rectangle_polygon(w, h);
699 let inner = rectangle_polygon(w - 2.0 * t, h - 2.0 * t);
701 Section::new(outer, vec![inner])
702 }
703
704 fn designation(&self) -> String {
705 format!(
706 "TIMBER BOX {:.0}x{:.0} t{:.0} w{}",
707 self.width * 1000.0,
708 self.height * 1000.0,
709 self.wall_thickness * 1000.0,
710 self.n_webs
711 )
712 }
713}
714
715#[cfg(test)]
716mod tests {
717 use super::*;
718 use crate::material::presets::TIMBER_GL24H;
719 use std::f64::consts::PI;
720
721 #[test]
722 fn solid_rectangular_timber() {
723 let t = SolidRectangularTimber::new(0.1, 0.2);
724 let sec = t.build();
725 assert!((sec.area() - 0.02).abs() < 1e-10);
726 }
727
728 #[test]
729 fn solid_rectangular_from_designation() {
730 let t = SolidRectangularTimber::from_designation("100X200").expect("Should exist");
731 assert!((t.width - 0.1).abs() < 1e-6);
732 assert!((t.height - 0.2).abs() < 1e-6);
733 }
734
735 #[test]
736 fn solid_circular_timber() {
737 let t = SolidCircularTimber::new(0.2);
738 let sec = t.build();
739 assert!((sec.area() - PI * 0.01).abs() < 1e-4);
740 }
741
742 #[test]
743 fn glulam_rectangular() {
744 let g = GlulamRectangular::new(0.115, 0.3, 0.033);
745 let sec = g.build();
746 assert!((sec.area() - 0.115 * 0.3).abs() < 1e-10);
747 assert_eq!(g.n_laminations, 9); }
749
750 #[test]
751 fn glulam_from_designation() {
752 let g = GlulamRectangular::from_designation("GL115x300").expect("Should exist");
753 assert!((g.width - 0.115).abs() < 1e-6);
754 assert!((g.height - 0.3).abs() < 1e-6);
755 }
756
757 #[test]
758 fn clt_three_layer() {
759 let clt = CLTPanel::three_layer(0.1, 0.033, 1.0);
760 assert_eq!(clt.layers.len(), 3);
761 assert!((clt.thickness - 0.1).abs() < 1e-6);
762 let sec = clt.build();
763 assert!((sec.area() - 1.0 * 0.1).abs() < 1e-10);
764 }
765
766 #[test]
767 fn clt_five_layer() {
768 let clt = CLTPanel::five_layer(0.17, 0.034, 1.0);
769 assert_eq!(clt.layers.len(), 5);
770 let ei = clt.effective_bending_stiffness(&TIMBER_GL24H);
771 assert!(ei > 0.0);
772 }
773
774 #[test]
775 fn clt_seven_layer() {
776 let clt = CLTPanel::seven_layer(0.24, 0.034, 1.0);
777 assert_eq!(clt.layers.len(), 7);
778 }
779
780 #[test]
781 fn built_up_timber() {
782 let bt = BuiltUpTimber::nail_laminated(0.2, 0.3, (0.038, 0.14), 0.002);
783 let sec = bt.build();
784 assert!(sec.area() > 0.0);
785 }
786
787 #[test]
788 fn timber_i_joist() {
789 let ij = TimberIJoist::new(
790 0.3,
791 0.038,
792 0.038,
793 0.0095,
794 TimberFlangeMaterial::SolidSawn,
795 TimberWebMaterial::OSB,
796 );
797 let sec = ij.build();
798 assert!(sec.area() > 0.0);
799 }
800
801 #[test]
802 fn timber_i_joist_area() {
803 let h = 0.3;
804 let bf = 0.038;
805 let tf = 0.038;
806 let tw = 0.0095;
807 let ij = TimberIJoist::new(
808 h,
809 bf,
810 tf,
811 tw,
812 TimberFlangeMaterial::SolidSawn,
813 TimberWebMaterial::OSB,
814 );
815 let sec = ij.build();
816 let area = sec.area();
817 let expected = 2.0 * bf * tf + tw * (h - 2.0 * tf);
818 assert!(
819 (area - expected).abs() / expected < 1e-6,
820 "TimberIJoist area: got {}, expected {}",
821 area,
822 expected
823 );
824 }
825
826 #[test]
827 fn timber_i_joist_from_series() {
828 let ij = TimberIJoist::from_series("TJI", 300.0).expect("TJI 300 should exist");
829 assert!((ij.height - 0.3).abs() < 0.01);
830 }
831
832 #[test]
833 fn timber_box_beam() {
834 let bb = TimberBoxBeam::new(0.3, 0.5, 0.038, 0.6, 1);
835 let sec = bb.build();
836 let expected = 0.3 * 0.5 - 0.224 * 0.424;
837 assert!((sec.area() - expected).abs() < 1e-6);
838 }
839}