Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable export-validator #1846

Merged
merged 6 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ jobs:
run: cargo build --all-features
- name: Run `cargo test`
run: cargo test --all-features
# - name: Run `export-validator`
# run: cargo run --package export-validator
- name: Run `export-validator`
run: cargo run --package export-validator
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export RUSTDOCFLAGS := "-D warnings"
# For a full build that mirrors the CI build, see `just ci`.
test:
cargo test --all-features
# cargo run --package export-validator
cargo run --package export-validator

# Run a full build that mirrors the CI build
#
Expand Down
7 changes: 7 additions & 0 deletions models/cuboid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ edition = "2021"
anyhow = "1.0.71"
itertools = "0.10.5"

[dependencies.clap]
version = "4.3.0"
features = ["derive"]

[dependencies.fj-export]
path = "../../crates/fj-export"

[dependencies.fj-kernel]
path = "../../crates/fj-kernel"

Expand Down
29 changes: 27 additions & 2 deletions models/cuboid/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
use std::ops::Deref;
use std::{ops::Deref, path::PathBuf};

use fj_kernel::algorithms::{approx::Tolerance, triangulate::Triangulate};

fn main() -> anyhow::Result<()> {
let args = Args::parse();

let cuboid = cuboid::cuboid(3., 2., 1.);

// The tolerance makes no difference for this model, as there aren't any
// curves.
let tolerance = Tolerance::from_scalar(1.)?;

let mesh = (cuboid.deref(), tolerance).triangulate();
fj_window::run(mesh, false)?;

if let Some(path) = args.export {
fj_export::export(&mesh, &path)?;
} else {
fj_window::run(mesh, false)?;
}

Ok(())
}

/// Standardized CLI for Fornjot models
#[derive(clap::Parser)]
pub struct Args {
/// Export model to this path
#[arg(short, long, value_name = "PATH")]
pub export: Option<PathBuf>,
}

impl Args {
/// Parse the command-line arguments
///
/// Convenience method that saves the caller from having to import the
/// `clap::Parser` trait.
pub fn parse() -> Self {
<Self as clap::Parser>::parse()
}
}
2 changes: 1 addition & 1 deletion tools/export-validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ fn handle_model(model: String) -> Result<(), anyhow::Error> {
let export_file_path_str = export_file_path.to_str().unwrap();
let exit_status = Command::new("cargo")
.arg("run")
.args(["-p", &model])
.arg("--")
.arg(&model)
.args(["--export", export_file_path_str])
.status()?;
if !exit_status.success() {
Expand Down