Skip to content

Commit

Permalink
put JointType::Tangent out of scope for now
Browse files Browse the repository at this point in the history
  • Loading branch information
mkovaxx committed Nov 25, 2023
1 parent 8f380ff commit dd39fdd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
7 changes: 4 additions & 3 deletions crates/opencascade/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,16 @@ pub fn approximate_function<F: FnMut(f64) -> f64>(
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum JoinType {
Arc,
Tangent,
// TODO(mkovaxx): Figure out how to make tangent joints work without segfaults
//Tangent,
Intersection,
}

impl From<ffi::GeomAbs_JoinType> for JoinType {
fn from(value: ffi::GeomAbs_JoinType) -> Self {
match value {
ffi::GeomAbs_JoinType::GeomAbs_Arc => Self::Arc,
ffi::GeomAbs_JoinType::GeomAbs_Tangent => Self::Tangent,
//ffi::GeomAbs_JoinType::GeomAbs_Tangent => Self::Tangent,
ffi::GeomAbs_JoinType::GeomAbs_Intersection => Self::Intersection,
ffi::GeomAbs_JoinType { repr } => panic!("Unexpected join type: {repr}"),
}
Expand All @@ -241,7 +242,7 @@ impl From<JoinType> for ffi::GeomAbs_JoinType {
fn from(value: JoinType) -> Self {
match value {
JoinType::Arc => ffi::GeomAbs_JoinType::GeomAbs_Arc,
JoinType::Tangent => ffi::GeomAbs_JoinType::GeomAbs_Tangent,
//JoinType::Tangent => ffi::GeomAbs_JoinType::GeomAbs_Tangent,
JoinType::Intersection => ffi::GeomAbs_JoinType::GeomAbs_Intersection,
}
}
Expand Down
29 changes: 12 additions & 17 deletions examples/src/offset_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,23 @@ use opencascade::{
pub fn shape() -> Shape {
let mut shapes = vec![];

for (i, join_type) in
[JoinType::Arc, JoinType::Tangent, JoinType::Intersection].into_iter().enumerate()
{
let solid_1 = Workplane::xy()
for (i, join_type) in [JoinType::Arc, JoinType::Intersection].into_iter().enumerate() {
let solid = Workplane::xy()
.translated(DVec3::new(32.0 * i as f64, 0.0, 0.0))
.rect(16.0, 10.0)
.offset(4.0, join_type) // offset a wire
.sketch()
.move_to(0.0, 10.0)
.line_to(5.0, 5.0)
.line_to(5.0, -5.0)
.line_to(0.0, 0.0)
.line_to(-5.0, -5.0)
.line_to(-5.0, 5.0)
.close()
.offset(1.0, join_type) // offset a wire
.to_face()
.extrude(DVec3::new(0.0, 0.0, 8.0))
.into_shape();

shapes.push(solid_1);

let solid_2 = Workplane::xy()
.translated(DVec3::new(32.0 * i as f64, 24.0, 0.0))
.rect(16.0, 10.0)
.to_face()
.offset(4.0, join_type) // offset a face
.extrude(DVec3::new(0.0, 0.0, 8.0))
.into_shape();

shapes.push(solid_2);
shapes.push(solid);
}

shapes.into_iter().reduce(|acc, item| acc.union(&item).shape).unwrap()
Expand Down

0 comments on commit dd39fdd

Please sign in to comment.