From edc19b7e86afa599240ef64b6beefd5d7460386d Mon Sep 17 00:00:00 2001 From: Andy Killorin <37423245+Speedy6451@users.noreply.github.com> Date: Wed, 1 Nov 2023 13:14:15 -0500 Subject: [PATCH] description --- src/main.rs | 3 ++- src/selig.rs | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index fc7e8cf..0da1b90 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,8 @@ fn main() { // cambered airfoil, used in the wing let wing_airfoil: Airfoil = Airfoil::parse(include_str!("../ag24.dat")); - println!("perim {}, name {}", wing_airfoil.get_name(), wing_airfoil.perimiter()); + println!("name {}, perim {}", wing_airfoil.get_name(), wing_airfoil.perimiter()); + println!("desc {}", wing_airfoil.get_description().clone().unwrap_or("no desc".to_string())); // symetric airfoil, used in the control surfaces let control_airfoil: Airfoil = Airfoil::parse(include_str!("../edgevertical.dat")); diff --git a/src/selig.rs b/src/selig.rs index ddebac6..d3fc896 100644 --- a/src/selig.rs +++ b/src/selig.rs @@ -4,6 +4,7 @@ pub type Point = Vector2; pub struct Airfoil { name: String, + description: Option, data: Vec, } @@ -12,7 +13,9 @@ impl Airfoil { let mut points = Vec::new(); let mut lines = file.lines(); - let name = lines.next().expect("selig .dat is empty").to_string(); + let mut header = lines.next().expect("selig .dat is empty").split(" | ").map(|x| x.trim()); + let name = header.next().unwrap().to_string(); + let description = header.next().map(|d| d.to_string()); for line in lines { let mut numbers =line.split(" ").filter(|n| !n.trim().is_empty()); @@ -22,6 +25,7 @@ impl Airfoil { } Airfoil { name, + description, data: points } } @@ -34,6 +38,10 @@ impl Airfoil { &self.name } + pub fn get_description(&self) -> &Option { + &self.description + } + pub fn perimiter(&self) -> f32 { let mut last_point: Option = None; let mut distance: f32 = 0.0;