geop_core_topology/euler/
replace_pcurve.rs1use crate::{CoedgeId, Model, argument_validation::validate_pcurve_start_and_end};
2use geop_core_geometry::nurb_curve::NurbCurve2D;
3use geop_core_math::{
4 geop_error::{GeopError, GeopResult, WithContext},
5 scalars::Scalar,
6};
7
8impl<S: Scalar> Model<S> {
9 pub fn replace_pcurve(
16 self: &mut Model<S>,
17 coedge_id: CoedgeId,
18 pcurve: NurbCurve2D<S>,
19 ) -> GeopResult<()> {
20 let ctx = |e: GeopError| {
21 e.with_context(format!(
22 "Model::replace_pcurve(coedge_id={coedge_id}, pcurve={pcurve})"
23 ))
24 };
25
26 let coedge = self.get_coedge(coedge_id)?.clone();
27 let face = self.get_face(coedge.face)?.clone();
28 let start = self.coedge_start_vertex(coedge_id)?.clone();
29 let end = self.coedge_end_vertex(coedge_id)?.clone();
30 validate_pcurve_start_and_end(&face.surface, &pcurve, &start.point, &end.point)
31 .with_context(&ctx)?;
32
33 self.get_coedge_mut(coedge_id)?.pcurve = pcurve;
34 Ok(())
35 }
36}