mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-18 22:26:09 +00:00
Make sure validation errors are triggered
This commit is contained in:
parent
ca96963468
commit
84cfff6d32
@ -1,9 +1,12 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use fj_core::algorithms::{
|
||||
approx::{InvalidTolerance, Tolerance},
|
||||
bounding_volume::BoundingVolume,
|
||||
triangulate::Triangulate,
|
||||
use fj_core::{
|
||||
algorithms::{
|
||||
approx::{InvalidTolerance, Tolerance},
|
||||
bounding_volume::BoundingVolume,
|
||||
triangulate::Triangulate,
|
||||
},
|
||||
services::Services,
|
||||
};
|
||||
use fj_interop::model::Model;
|
||||
use fj_math::{Aabb, Point, Scalar};
|
||||
@ -18,13 +21,21 @@ use crate::Args;
|
||||
///
|
||||
/// This function is used by Fornjot's own testing infrastructure, but is useful
|
||||
/// beyond that, when using Fornjot directly to define a model.
|
||||
pub fn handle_model<M>(model: impl Deref<Target = M>) -> Result
|
||||
pub fn handle_model<M>(
|
||||
model: impl Deref<Target = M>,
|
||||
services: Services,
|
||||
) -> Result
|
||||
where
|
||||
for<'r> (&'r M, Tolerance): Triangulate,
|
||||
M: BoundingVolume<3>,
|
||||
{
|
||||
let args = Args::parse();
|
||||
|
||||
// Dropping `Services` will cause a panic, if there are any unhandled
|
||||
// validation errors. It would be better to return an error, but this will
|
||||
// do for now.
|
||||
drop(services);
|
||||
|
||||
let aabb = model.aabb().unwrap_or(Aabb {
|
||||
min: Point::origin(),
|
||||
max: Point::origin(),
|
||||
|
@ -1,7 +1,8 @@
|
||||
use fj::{core::services::Services, handle_model};
|
||||
|
||||
fn main() -> fj::Result {
|
||||
let model = all::model(&mut Services::new());
|
||||
handle_model(model)?;
|
||||
let mut services = Services::new();
|
||||
let model = all::model(&mut services);
|
||||
handle_model(model, services)?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
use fj::{core::services::Services, handle_model};
|
||||
|
||||
fn main() -> fj::Result {
|
||||
let model = cuboid::model(3., 2., 1., &mut Services::new());
|
||||
handle_model(model)?;
|
||||
let mut services = Services::new();
|
||||
let model = cuboid::model(3., 2., 1., &mut services);
|
||||
handle_model(model, services)?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
use fj::{core::services::Services, handle_model};
|
||||
|
||||
fn main() -> fj::Result {
|
||||
let model = spacer::model(1., 0.5, 1., &mut Services::new());
|
||||
handle_model(model)?;
|
||||
let mut services = Services::new();
|
||||
let model = spacer::model(1., 0.5, 1., &mut services);
|
||||
handle_model(model, services)?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
use fj::{core::services::Services, handle_model};
|
||||
|
||||
fn main() -> fj::Result {
|
||||
let model = star::model(5, 1., 2., 1., &mut Services::new());
|
||||
handle_model(model)?;
|
||||
let mut services = Services::new();
|
||||
let model = star::model(5, 1., 2., 1., &mut services);
|
||||
handle_model(model, services)?;
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user