extracted selig parser to file
This commit is contained in:
parent
13ab421df4
commit
9996a34cae
2 changed files with 19 additions and 18 deletions
|
@ -1,14 +1,13 @@
|
|||
use nalgebra::Vector2;
|
||||
use scad::*;
|
||||
mod selig;
|
||||
|
||||
fn main() {
|
||||
let e393 = parse_selig(&String::from(include_str!("../../e393.selig")));
|
||||
let e393 = selig::parse(include_str!("../../e393.selig"));
|
||||
let mut scad_file = ScadFile::new();
|
||||
scad_file.set_detail(50);
|
||||
|
||||
|
||||
let aerofoil = scad::PolygonParameters::new(e393);
|
||||
//Create an scad object
|
||||
let strut = scad!(Translate(vec3(2.0, 2.0, 3.0)); {
|
||||
scad!(Polygon(aerofoil))
|
||||
});
|
||||
|
@ -17,18 +16,3 @@ fn main() {
|
|||
|
||||
scad_file.write_to_file(String::from("out.scad"));
|
||||
}
|
||||
|
||||
type Point = Vector2<f32>;
|
||||
type Airfoil = Vec<Point>;
|
||||
|
||||
fn parse_selig(file: &String) -> Airfoil {
|
||||
let mut points = Vec::new();
|
||||
|
||||
for line in file.lines().skip(1) {
|
||||
let mut numbers =line.split(" ").filter(|n| !n.trim().is_empty());
|
||||
let x = numbers.next().unwrap().parse().unwrap();
|
||||
let y = numbers.next().unwrap().parse().unwrap();
|
||||
points.push(Point::new(x,y))
|
||||
}
|
||||
points
|
||||
}
|
||||
|
|
17
glider/src/selig.rs
Normal file
17
glider/src/selig.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
use nalgebra::Vector2;
|
||||
|
||||
pub type Point = Vector2<f32>;
|
||||
|
||||
pub type Airfoil = Vec<Point>;
|
||||
|
||||
pub fn parse(file: &str) -> Airfoil {
|
||||
let mut points = Vec::new();
|
||||
|
||||
for line in file.lines().skip(1) {
|
||||
let mut numbers =line.split(" ").filter(|n| !n.trim().is_empty());
|
||||
let x = numbers.next().unwrap().parse().unwrap();
|
||||
let y = numbers.next().unwrap().parse().unwrap();
|
||||
points.push(Point::new(x,y))
|
||||
}
|
||||
points
|
||||
}
|
Loading…
Reference in a new issue