brep_construction/construction/
loft_guide_chain.rs1use crate::{join_curve_chain, loft_profile_brep_guided, loft_profile_brep_guided_frame, BrepSolid, JointContinuity, KernelRefusal, KernelStage, NurbsCurve, SweepPath};
13
14pub fn loft_profile_brep_guided_chain(sections: &[Vec<NurbsCurve>], guide: &[NurbsCurve], name: Option<&str>, rotate_to_frame: bool) -> Result<BrepSolid, KernelRefusal> {
25 let loft = |spine: &NurbsCurve| if rotate_to_frame { loft_profile_brep_guided_frame(sections, spine, name) } else { loft_profile_brep_guided(sections, spine, name) };
26 if let [spine] = guide {
27 return loft(spine);
28 }
29 let path = SweepPath::new(guide.to_vec(), Vec::new()).map_err(|error| error.with_message(|message| format!("guidedLoft: guide chain: {message}")))?;
30 if path.closed {
31 return Err(KernelRefusal::input(KernelStage::Classify, "guide_closed", "guidedLoft: the guide chain closes on itself; a guide runs from the first section to the last"));
32 }
33 for joint in &path.joints {
34 if joint.continuity == JointContinuity::G0 {
35 return Err(KernelRefusal::input(
36 KernelStage::Classify,
37 "guide_corner",
38 format!(
39 "guidedLoft: the guide turns {:.3}° where its curve {} follows curve {}; the curves of a guide chain must meet smoothly (a loft along a corner would round it off)",
40 joint.tangent_break.to_degrees(),
41 joint.after,
42 joint.before
43 ),
44 ));
45 }
46 }
47 let spine = join_curve_chain(&path.curves).map_err(|message| KernelRefusal::input(KernelStage::Collect, "guide_chain", format!("guidedLoft: guide chain: {message}")))?;
48 loft(&spine)
49}
50