added Ellipse and EllipticalArc to kcl
This commit is contained in:
@ -661,8 +661,21 @@ impl SketchSurface {
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) enum GetTangentialInfoFromPathsResult {
|
||||
PreviousPoint([f64; 2]),
|
||||
Arc { center: [f64; 2], ccw: bool },
|
||||
Circle { center: [f64; 2], ccw: bool, radius: f64 },
|
||||
Arc {
|
||||
center: [f64; 2],
|
||||
ccw: bool,
|
||||
},
|
||||
Circle {
|
||||
center: [f64; 2],
|
||||
ccw: bool,
|
||||
radius: f64,
|
||||
},
|
||||
Ellipse {
|
||||
center: [f64; 2],
|
||||
ccw: bool,
|
||||
major_radius: f64,
|
||||
_minor_radius: f64,
|
||||
},
|
||||
}
|
||||
|
||||
impl GetTangentialInfoFromPathsResult {
|
||||
@ -677,6 +690,12 @@ impl GetTangentialInfoFromPathsResult {
|
||||
GetTangentialInfoFromPathsResult::Circle {
|
||||
center, radius, ccw, ..
|
||||
} => [center[0] + radius, center[1] + if *ccw { -1.0 } else { 1.0 }],
|
||||
GetTangentialInfoFromPathsResult::Ellipse {
|
||||
center,
|
||||
major_radius,
|
||||
ccw,
|
||||
..
|
||||
} => [center[0] + major_radius, center[1] + if *ccw { -1.0 } else { 1.0 }],
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1125,6 +1144,14 @@ pub enum Path {
|
||||
/// True if the arc is counterclockwise.
|
||||
ccw: bool,
|
||||
},
|
||||
Ellipse {
|
||||
#[serde(flatten)]
|
||||
base: BasePath,
|
||||
center: [f64; 2],
|
||||
major_radius: f64,
|
||||
minor_radius: f64,
|
||||
ccw: bool,
|
||||
},
|
||||
}
|
||||
|
||||
/// What kind of path is this?
|
||||
@ -1139,6 +1166,7 @@ enum PathType {
|
||||
Horizontal,
|
||||
AngledLineTo,
|
||||
Arc,
|
||||
Ellipse,
|
||||
}
|
||||
|
||||
impl From<&Path> for PathType {
|
||||
@ -1154,6 +1182,7 @@ impl From<&Path> for PathType {
|
||||
Path::Base { .. } => Self::Base,
|
||||
Path::Arc { .. } => Self::Arc,
|
||||
Path::ArcThreePoint { .. } => Self::Arc,
|
||||
Path::Ellipse { .. } => Self::Ellipse,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1171,6 +1200,7 @@ impl Path {
|
||||
Path::CircleThreePoint { base, .. } => base.geo_meta.id,
|
||||
Path::Arc { base, .. } => base.geo_meta.id,
|
||||
Path::ArcThreePoint { base, .. } => base.geo_meta.id,
|
||||
Path::Ellipse { base, .. } => base.geo_meta.id,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1186,6 +1216,7 @@ impl Path {
|
||||
Path::CircleThreePoint { base, .. } => base.geo_meta.id = id,
|
||||
Path::Arc { base, .. } => base.geo_meta.id = id,
|
||||
Path::ArcThreePoint { base, .. } => base.geo_meta.id = id,
|
||||
Path::Ellipse { base, .. } => base.geo_meta.id = id,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1201,6 +1232,7 @@ impl Path {
|
||||
Path::CircleThreePoint { base, .. } => base.tag.clone(),
|
||||
Path::Arc { base, .. } => base.tag.clone(),
|
||||
Path::ArcThreePoint { base, .. } => base.tag.clone(),
|
||||
Path::Ellipse { base, .. } => base.tag.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1216,6 +1248,7 @@ impl Path {
|
||||
Path::CircleThreePoint { base, .. } => base,
|
||||
Path::Arc { base, .. } => base,
|
||||
Path::ArcThreePoint { base, .. } => base,
|
||||
Path::Ellipse { base, .. } => base,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1291,6 +1324,10 @@ impl Path {
|
||||
// TODO: Call engine utils to figure this out.
|
||||
linear_distance(&self.get_base().from, &self.get_base().to)
|
||||
}
|
||||
Self::Ellipse { .. } => {
|
||||
//TODO: fix me
|
||||
10.0
|
||||
}
|
||||
};
|
||||
TyF64::new(n, self.get_base().units.into())
|
||||
}
|
||||
@ -1307,6 +1344,7 @@ impl Path {
|
||||
Path::CircleThreePoint { base, .. } => Some(base),
|
||||
Path::Arc { base, .. } => Some(base),
|
||||
Path::ArcThreePoint { base, .. } => Some(base),
|
||||
Path::Ellipse { base, .. } => Some(base),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1342,6 +1380,18 @@ impl Path {
|
||||
radius: circle.radius,
|
||||
}
|
||||
}
|
||||
Path::Ellipse {
|
||||
center,
|
||||
major_radius,
|
||||
minor_radius,
|
||||
ccw,
|
||||
..
|
||||
} => GetTangentialInfoFromPathsResult::Ellipse {
|
||||
center: *center,
|
||||
major_radius: *major_radius,
|
||||
_minor_radius: *minor_radius,
|
||||
ccw: *ccw,
|
||||
},
|
||||
Path::ToPoint { .. } | Path::Horizontal { .. } | Path::AngledLineTo { .. } | Path::Base { .. } => {
|
||||
let base = self.get_base();
|
||||
GetTangentialInfoFromPathsResult::PreviousPoint(base.from)
|
||||
|
Reference in New Issue
Block a user