Skip to content

Commit

Permalink
Merge pull request #1846 from hannobraun/export-validator
Browse files Browse the repository at this point in the history
Re-enable `export-validator`
  • Loading branch information
hannobraun authored May 30, 2023
2 parents 08b6f32 + 678dcf5 commit 98de757
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
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

0 comments on commit 98de757

Please sign in to comment.