Return Option from Geometry::of_curve

This makes the method more flexible and error messages about missing
curve geometry more targetted.
This commit is contained in:
Hanno Braun 2024-04-30 12:36:33 +02:00
parent b5bcd2cf99
commit 3f4a92e6c9
3 changed files with 7 additions and 4 deletions

View File

@ -108,10 +108,8 @@ impl Geometry {
/// ## Panics
///
/// Panics, if the geometry of the curve is not defined.
pub fn of_curve(&self, curve: &Handle<Curve>) -> &CurveGeom {
self.curve
.get(curve)
.expect("Expected geometry of half-edge to be defined")
pub fn of_curve(&self, curve: &Handle<Curve>) -> Option<&CurveGeom> {
self.curve.get(curve)
}
/// # Access the geometry of the provided half-edge

View File

@ -133,6 +133,7 @@ pub trait BuildHalfEdge {
.layers
.geometry
.of_curve(half_edge.curve())
.expect("Curve geometry was just defined in same function")
.local_on(&surface)
.path,
boundary: boundary.unwrap_or_default(),

View File

@ -107,6 +107,10 @@ pub trait BuildShell {
.layers
.geometry
.of_curve(&curve)
.expect(
"Curve geometry was just \
defined in same function",
)
.local_on(&surface)
.path,
boundary,