1
Fork 0

added selig parser

This commit is contained in:
Andy Killorin 2023-10-26 15:07:26 -05:00
commit bec6d83b9b
Signed by: ank
GPG key ID: B6241CA3B552BCA4
5 changed files with 241 additions and 0 deletions

2
Makefile Normal file
View file

@ -0,0 +1,2 @@
e393.selig:
curl http://airfoiltools.com/airfoil/seligdatfile?airfoil=e393-il > e393.selig

1
glider/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

194
glider/Cargo.lock generated Normal file
View file

@ -0,0 +1,194 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "alga"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24bb00eeca59f2986c747b8c2f271d52310ce446be27428fc34705138b155778"
dependencies = [
"approx",
"libm",
"num-complex",
"num-traits",
]
[[package]]
name = "approx"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3"
dependencies = [
"num-traits",
]
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cloudabi"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
dependencies = [
"bitflags",
]
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
name = "generic-array"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "667f6ea017b297ec65b8a108c6e9ad6879460721fb3b6b23abf690970147fc28"
dependencies = [
"typenum",
]
[[package]]
name = "glider"
version = "0.1.0"
dependencies = [
"scad",
]
[[package]]
name = "libc"
version = "0.2.149"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
[[package]]
name = "libm"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
[[package]]
name = "matrixmultiply"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcad67dcec2d58ff56f6292582377e6921afdf3bfbd533e26fb8900ae575e002"
dependencies = [
"rawpointer",
]
[[package]]
name = "nalgebra"
version = "0.16.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccb86df349ecf5f549f6e12f6de4972cdd912d0bc290c1ca4d34d4b4b21a6f98"
dependencies = [
"alga",
"approx",
"generic-array",
"matrixmultiply",
"num-complex",
"num-traits",
"rand",
"typenum",
]
[[package]]
name = "num-complex"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
dependencies = [
"autocfg",
]
[[package]]
name = "rand"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
dependencies = [
"cloudabi",
"fuchsia-cprng",
"libc",
"rand_core 0.3.1",
"winapi",
]
[[package]]
name = "rand_core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
dependencies = [
"rand_core 0.4.2",
]
[[package]]
name = "rand_core"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rawpointer"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebac11a9d2e11f2af219b8b8d833b76b1ea0e054aa0e8d8e9e4cbde353bdf019"
[[package]]
name = "scad"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6e76df4b25586c7635852210c20a22cb5e983b2e554ee6330229fe6263b7efb"
dependencies = [
"nalgebra",
]
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

9
glider/Cargo.toml Normal file
View file

@ -0,0 +1,9 @@
[package]
name = "glider"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
scad = "1.2.2"

35
glider/src/main.rs Normal file
View file

@ -0,0 +1,35 @@
#[macro_use]
extern crate scad;
use scad::*;
fn main() {
println!("{:?}", parse_selig(&String::from(include_str!("../../e393.selig"))));
let mut scad_file = ScadFile::new();
scad_file.set_detail(50);
//Save the scad code to a file
scad_file.write_to_file(String::from("out.scad"));
}
#[derive(Debug)]
struct Point {
x: f64,
y: f64,
}
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: f64 = numbers.next().unwrap().parse().unwrap();
let y: f64 = numbers.next().unwrap().parse().unwrap();
points.push(Point { x, y })
}
points
}