mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-31 04:15:54 +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 std::ops::Deref;
|
||||||
|
|
||||||
use fj_core::algorithms::{
|
use fj_core::{
|
||||||
approx::{InvalidTolerance, Tolerance},
|
algorithms::{
|
||||||
bounding_volume::BoundingVolume,
|
approx::{InvalidTolerance, Tolerance},
|
||||||
triangulate::Triangulate,
|
bounding_volume::BoundingVolume,
|
||||||
|
triangulate::Triangulate,
|
||||||
|
},
|
||||||
|
services::Services,
|
||||||
};
|
};
|
||||||
use fj_interop::model::Model;
|
use fj_interop::model::Model;
|
||||||
use fj_math::{Aabb, Point, Scalar};
|
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
|
/// This function is used by Fornjot's own testing infrastructure, but is useful
|
||||||
/// beyond that, when using Fornjot directly to define a model.
|
/// 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
|
where
|
||||||
for<'r> (&'r M, Tolerance): Triangulate,
|
for<'r> (&'r M, Tolerance): Triangulate,
|
||||||
M: BoundingVolume<3>,
|
M: BoundingVolume<3>,
|
||||||
{
|
{
|
||||||
let args = Args::parse();
|
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 {
|
let aabb = model.aabb().unwrap_or(Aabb {
|
||||||
min: Point::origin(),
|
min: Point::origin(),
|
||||||
max: Point::origin(),
|
max: Point::origin(),
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use fj::{core::services::Services, handle_model};
|
use fj::{core::services::Services, handle_model};
|
||||||
|
|
||||||
fn main() -> fj::Result {
|
fn main() -> fj::Result {
|
||||||
let model = all::model(&mut Services::new());
|
let mut services = Services::new();
|
||||||
handle_model(model)?;
|
let model = all::model(&mut services);
|
||||||
|
handle_model(model, services)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use fj::{core::services::Services, handle_model};
|
use fj::{core::services::Services, handle_model};
|
||||||
|
|
||||||
fn main() -> fj::Result {
|
fn main() -> fj::Result {
|
||||||
let model = cuboid::model(3., 2., 1., &mut Services::new());
|
let mut services = Services::new();
|
||||||
handle_model(model)?;
|
let model = cuboid::model(3., 2., 1., &mut services);
|
||||||
|
handle_model(model, services)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use fj::{core::services::Services, handle_model};
|
use fj::{core::services::Services, handle_model};
|
||||||
|
|
||||||
fn main() -> fj::Result {
|
fn main() -> fj::Result {
|
||||||
let model = spacer::model(1., 0.5, 1., &mut Services::new());
|
let mut services = Services::new();
|
||||||
handle_model(model)?;
|
let model = spacer::model(1., 0.5, 1., &mut services);
|
||||||
|
handle_model(model, services)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use fj::{core::services::Services, handle_model};
|
use fj::{core::services::Services, handle_model};
|
||||||
|
|
||||||
fn main() -> fj::Result {
|
fn main() -> fj::Result {
|
||||||
let model = star::model(5, 1., 2., 1., &mut Services::new());
|
let mut services = Services::new();
|
||||||
handle_model(model)?;
|
let model = star::model(5, 1., 2., 1., &mut services);
|
||||||
|
handle_model(model, services)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user