Compare commits
3 Commits
pierremtb/
...
achalmers/
Author | SHA1 | Date | |
---|---|---|---|
7081566220 | |||
2b0113dc9e | |||
3cc15eb010 |
Binary file not shown.
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 45 KiB |
Binary file not shown.
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 39 KiB |
@ -14,7 +14,7 @@ use crate::{
|
|||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
executor::{
|
executor::{
|
||||||
BasePath, ExtrudeGroup, Face, GeoMeta, KclValue, Path, Plane, PlaneType, Point2d, Point3d, SketchGroup,
|
BasePath, ExtrudeGroup, Face, GeoMeta, KclValue, Path, Plane, PlaneType, Point2d, Point3d, SketchGroup,
|
||||||
SketchGroupSet, SketchSurface, SourceRange, TagEngineInfo, TagIdentifier, UserVal,
|
SketchGroupSet, SketchSurface, TagEngineInfo, TagIdentifier, UserVal,
|
||||||
},
|
},
|
||||||
std::{
|
std::{
|
||||||
utils::{
|
utils::{
|
||||||
@ -1634,8 +1634,6 @@ pub enum TangentialArcData {
|
|||||||
/// Offset of the arc, in degrees.
|
/// Offset of the arc, in degrees.
|
||||||
offset: f64,
|
offset: f64,
|
||||||
},
|
},
|
||||||
/// A point where the arc should end. Must lie in the same plane as the current path pen position. Must not be colinear with current path pen position.
|
|
||||||
Point([f64; 2]),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draw a tangential arc.
|
/// Draw a tangential arc.
|
||||||
@ -1728,13 +1726,6 @@ async fn inner_tangential_arc(
|
|||||||
.await?;
|
.await?;
|
||||||
(center, to.into(), ccw)
|
(center, to.into(), ccw)
|
||||||
}
|
}
|
||||||
TangentialArcData::Point(to) => {
|
|
||||||
args.batch_modeling_cmd(id, tan_arc_to(&sketch_group, &to)).await?;
|
|
||||||
// TODO: Figure out these calculations.
|
|
||||||
let ccw = false;
|
|
||||||
let center = Point2d { x: 0.0, y: 0.0 };
|
|
||||||
(center, to, ccw)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let current_path = Path::TangentialArc {
|
let current_path = Path::TangentialArc {
|
||||||
@ -1775,32 +1766,13 @@ fn tan_arc_to(sketch_group: &SketchGroup, to: &[f64; 2]) -> ModelingCmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn too_few_args(source_range: SourceRange) -> KclError {
|
|
||||||
KclError::Syntax(KclErrorDetails {
|
|
||||||
source_ranges: vec![source_range],
|
|
||||||
message: "too few arguments".to_owned(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_arg<I: Iterator>(it: &mut I, src: SourceRange) -> Result<I::Item, KclError> {
|
|
||||||
it.next().ok_or_else(|| too_few_args(src))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Draw a tangential arc to a specific point.
|
/// Draw a tangential arc to a specific point.
|
||||||
pub async fn tangential_arc_to(args: Args) -> Result<KclValue, KclError> {
|
pub async fn tangential_arc_to(args: Args) -> Result<KclValue, KclError> {
|
||||||
let src = args.source_range;
|
|
||||||
|
|
||||||
// Get arguments to function call
|
// Get arguments to function call
|
||||||
let mut it = args.args.iter();
|
let (to, relative, sketch_group, tag): ([f64; 2], bool, SketchGroup, Option<TagDeclarator>) =
|
||||||
let to: [f64; 2] = get_arg(&mut it, src)?.get_json()?;
|
super::args::FromArgs::from_args(&args, 0)?;
|
||||||
let sketch_group: SketchGroup = get_arg(&mut it, src)?.get_json()?;
|
|
||||||
let tag = if let Ok(memory_item) = get_arg(&mut it, src) {
|
|
||||||
memory_item.get_json_opt()?
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
let new_sketch_group = inner_tangential_arc_to(to, sketch_group, tag, args).await?;
|
let new_sketch_group = inner_tangential_arc_to(to, relative, sketch_group, tag, args).await?;
|
||||||
Ok(KclValue::new_user_val(new_sketch_group.meta.clone(), new_sketch_group))
|
Ok(KclValue::new_user_val(new_sketch_group.meta.clone(), new_sketch_group))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1826,6 +1798,7 @@ pub async fn tangential_arc_to(args: Args) -> Result<KclValue, KclError> {
|
|||||||
}]
|
}]
|
||||||
async fn inner_tangential_arc_to(
|
async fn inner_tangential_arc_to(
|
||||||
to: [f64; 2],
|
to: [f64; 2],
|
||||||
|
relative: bool,
|
||||||
sketch_group: SketchGroup,
|
sketch_group: SketchGroup,
|
||||||
tag: Option<TagDeclarator>,
|
tag: Option<TagDeclarator>,
|
||||||
args: Args,
|
args: Args,
|
||||||
@ -1845,9 +1818,13 @@ async fn inner_tangential_arc_to(
|
|||||||
obtuse: true,
|
obtuse: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
let delta = [to_x - from.x, to_y - from.y];
|
let to = if relative {
|
||||||
|
[to_x, to_y]
|
||||||
|
} else {
|
||||||
|
[to_x - from.x, to_y - from.y]
|
||||||
|
};
|
||||||
let id = uuid::Uuid::new_v4();
|
let id = uuid::Uuid::new_v4();
|
||||||
args.batch_modeling_cmd(id, tan_arc_to(&sketch_group, &delta)).await?;
|
args.batch_modeling_cmd(id, tan_arc_to(&sketch_group, &to)).await?;
|
||||||
|
|
||||||
let current_path = Path::TangentialArcTo {
|
let current_path = Path::TangentialArcTo {
|
||||||
base: BasePath {
|
base: BasePath {
|
||||||
|
Reference in New Issue
Block a user