Skip to content

Commit

Permalink
WIP Add union model
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed May 23, 2022
1 parent 2ad3293 commit 1573de5
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"models/group",
"models/spacer",
"models/star",
"models/union",

"tools/export-validator",
"tools/release-operator",
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/intersection/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use fj_math::Scalar;
use crate::{geometry::Curve, topology::Face};

/// Determine the intersection between a [`Curve`] and a [`Face`]
pub fn curve_face(curve: &Curve, face: &Face) -> Vec<[Scalar; 2]> {
pub fn curve_face(curve: &Curve<3>, face: &Face) -> Vec<[Scalar; 2]> {
let line = match curve {
Curve::Line(line) => line,
_ => todo!("Curve-face intersection only supports lines"),
Expand Down
10 changes: 10 additions & 0 deletions models/union/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "union"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies.fj]
path = "../../crates/fj"
11 changes: 11 additions & 0 deletions models/union/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Fornjot - Union

A model that demonstrates unions of bodies.

To display this model, run the following from the repository root:
``` sh
cargo run -- --model union
```

**TASK: Add screenshot.**o
![Screenshot of the union model](union.png)
21 changes: 21 additions & 0 deletions models/union/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use std::collections::HashMap;

use fj::syntax::*;

#[no_mangle]
pub extern "C" fn model(_: &HashMap<String, String>) -> fj::Shape {
#[rustfmt::skip]
let points = vec![
[-0.5, -0.5],
[ 0.5, -0.5],
[ 0.5, 0.5],
[-0.5, 0.5],
];

let a = fj::Sketch::from_points(points).sweep([0., 0., 1.]);
let b = a.clone().translate([0.5, 0.5, 0.5]);

let union = a.union(&b);

union.into()
}

0 comments on commit 1573de5

Please sign in to comment.