mirror of https://github.com/hannobraun/Fornjot
Don't use old validation infrastructure in `Shape`
It doesn't do anything useful anymore, and has been replaced by the new validation infrastructure, which validates automatically on insertion.
This commit is contained in:
parent
635c49035b
commit
ee266a7da2
|
@ -5,7 +5,7 @@ use fj_kernel::{
|
|||
algorithms::reverse::Reverse,
|
||||
iter::ObjectIters,
|
||||
objects::{Face, Objects, Sketch},
|
||||
validate::{Validate, Validated, ValidationConfig, ValidationError},
|
||||
validate::{ValidationConfig, ValidationError},
|
||||
};
|
||||
use fj_math::Aabb;
|
||||
|
||||
|
@ -19,7 +19,7 @@ impl Shape for fj::Difference2d {
|
|||
config: &ValidationConfig,
|
||||
objects: &Objects,
|
||||
debug_info: &mut DebugInfo,
|
||||
) -> Result<Validated<Self::Brep>, ValidationError> {
|
||||
) -> Result<Self::Brep, ValidationError> {
|
||||
// This method assumes that `b` is fully contained within `a`:
|
||||
// https://github.com/hannobraun/Fornjot/issues/92
|
||||
|
||||
|
@ -87,7 +87,7 @@ impl Shape for fj::Difference2d {
|
|||
}
|
||||
|
||||
let difference = Sketch::builder(objects).with_faces(faces).build();
|
||||
difference.deref().clone().validate_with_config(config)
|
||||
Ok(difference.deref().clone())
|
||||
}
|
||||
|
||||
fn bounding_volume(&self) -> Aabb<3> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use fj_interop::debug::DebugInfo;
|
||||
use fj_kernel::{
|
||||
objects::{FaceSet, Objects},
|
||||
validate::{Validate, Validated, ValidationConfig, ValidationError},
|
||||
validate::{ValidationConfig, ValidationError},
|
||||
};
|
||||
use fj_math::Aabb;
|
||||
|
||||
|
@ -15,16 +15,16 @@ impl Shape for fj::Group {
|
|||
config: &ValidationConfig,
|
||||
objects: &Objects,
|
||||
debug_info: &mut DebugInfo,
|
||||
) -> Result<Validated<Self::Brep>, ValidationError> {
|
||||
) -> Result<Self::Brep, ValidationError> {
|
||||
let mut faces = FaceSet::new();
|
||||
|
||||
let a = self.a.compute_brep(config, objects, debug_info)?;
|
||||
let b = self.b.compute_brep(config, objects, debug_info)?;
|
||||
|
||||
faces.extend(a.into_inner());
|
||||
faces.extend(b.into_inner());
|
||||
faces.extend(a);
|
||||
faces.extend(b);
|
||||
|
||||
faces.validate_with_config(config)
|
||||
Ok(faces)
|
||||
}
|
||||
|
||||
fn bounding_volume(&self) -> Aabb<3> {
|
||||
|
|
|
@ -27,7 +27,7 @@ mod transform;
|
|||
use fj_interop::debug::DebugInfo;
|
||||
use fj_kernel::{
|
||||
objects::{FaceSet, Objects, Sketch},
|
||||
validate::{Validate, Validated, ValidationConfig, ValidationError},
|
||||
validate::{ValidationConfig, ValidationError},
|
||||
};
|
||||
use fj_math::Aabb;
|
||||
|
||||
|
@ -42,7 +42,7 @@ pub trait Shape {
|
|||
config: &ValidationConfig,
|
||||
objects: &Objects,
|
||||
debug_info: &mut DebugInfo,
|
||||
) -> Result<Validated<Self::Brep>, ValidationError>;
|
||||
) -> Result<Self::Brep, ValidationError>;
|
||||
|
||||
/// Access the axis-aligned bounding box of a shape
|
||||
///
|
||||
|
@ -59,28 +59,24 @@ impl Shape for fj::Shape {
|
|||
config: &ValidationConfig,
|
||||
objects: &Objects,
|
||||
debug_info: &mut DebugInfo,
|
||||
) -> Result<Validated<Self::Brep>, ValidationError> {
|
||||
) -> Result<Self::Brep, ValidationError> {
|
||||
match self {
|
||||
Self::Shape2d(shape) => shape
|
||||
Self::Shape2d(shape) => Ok(shape
|
||||
.compute_brep(config, objects, debug_info)?
|
||||
.into_inner()
|
||||
.faces()
|
||||
.clone()
|
||||
.validate_with_config(config),
|
||||
.clone()),
|
||||
Self::Group(shape) => {
|
||||
shape.compute_brep(config, objects, debug_info)
|
||||
}
|
||||
Self::Sweep(shape) => shape
|
||||
Self::Sweep(shape) => Ok(shape
|
||||
.compute_brep(config, objects, debug_info)?
|
||||
.into_inner()
|
||||
.shells()
|
||||
.map(|shell| shell.faces().clone())
|
||||
.reduce(|mut a, b| {
|
||||
a.extend(b);
|
||||
a
|
||||
})
|
||||
.unwrap_or_default()
|
||||
.validate_with_config(config),
|
||||
.unwrap_or_default()),
|
||||
Self::Transform(shape) => {
|
||||
shape.compute_brep(config, objects, debug_info)
|
||||
}
|
||||
|
@ -105,7 +101,7 @@ impl Shape for fj::Shape2d {
|
|||
config: &ValidationConfig,
|
||||
objects: &Objects,
|
||||
debug_info: &mut DebugInfo,
|
||||
) -> Result<Validated<Self::Brep>, ValidationError> {
|
||||
) -> Result<Self::Brep, ValidationError> {
|
||||
match self {
|
||||
Self::Difference(shape) => {
|
||||
shape.compute_brep(config, objects, debug_info)
|
||||
|
|
|
@ -46,7 +46,7 @@ impl ShapeProcessor {
|
|||
let objects = Objects::new();
|
||||
let mut debug_info = DebugInfo::new();
|
||||
let shape = shape.compute_brep(&config, &objects, &mut debug_info)?;
|
||||
let mesh = (&shape.into_inner(), tolerance).triangulate();
|
||||
let mesh = (&shape, tolerance).triangulate();
|
||||
|
||||
Ok(ProcessedShape {
|
||||
aabb,
|
||||
|
|
|
@ -5,7 +5,7 @@ use fj_kernel::{
|
|||
builder::HalfEdgeBuilder,
|
||||
objects::{Cycle, Face, HalfEdge, Objects, Sketch},
|
||||
partial::HasPartial,
|
||||
validate::{Validate, Validated, ValidationConfig, ValidationError},
|
||||
validate::{ValidationConfig, ValidationError},
|
||||
};
|
||||
use fj_math::{Aabb, Point};
|
||||
|
||||
|
@ -16,10 +16,10 @@ impl Shape for fj::Sketch {
|
|||
|
||||
fn compute_brep(
|
||||
&self,
|
||||
config: &ValidationConfig,
|
||||
_: &ValidationConfig,
|
||||
objects: &Objects,
|
||||
_: &mut DebugInfo,
|
||||
) -> Result<Validated<Self::Brep>, ValidationError> {
|
||||
) -> Result<Self::Brep, ValidationError> {
|
||||
let surface = objects.surfaces.xy_plane();
|
||||
|
||||
let face = match self.chain() {
|
||||
|
@ -51,7 +51,7 @@ impl Shape for fj::Sketch {
|
|||
};
|
||||
|
||||
let sketch = Sketch::builder(objects).with_faces([face]).build();
|
||||
sketch.deref().clone().validate_with_config(config)
|
||||
Ok(sketch.deref().clone())
|
||||
}
|
||||
|
||||
fn bounding_volume(&self) -> Aabb<3> {
|
||||
|
|
|
@ -4,7 +4,7 @@ use fj_interop::debug::DebugInfo;
|
|||
use fj_kernel::{
|
||||
algorithms::sweep::Sweep,
|
||||
objects::{Objects, Solid},
|
||||
validate::{Validate, Validated, ValidationConfig, ValidationError},
|
||||
validate::{ValidationConfig, ValidationError},
|
||||
};
|
||||
use fj_math::{Aabb, Vector};
|
||||
|
||||
|
@ -18,14 +18,14 @@ impl Shape for fj::Sweep {
|
|||
config: &ValidationConfig,
|
||||
objects: &Objects,
|
||||
debug_info: &mut DebugInfo,
|
||||
) -> Result<Validated<Self::Brep>, ValidationError> {
|
||||
) -> Result<Self::Brep, ValidationError> {
|
||||
let sketch = self.shape().compute_brep(config, objects, debug_info)?;
|
||||
let sketch = objects.sketches.insert(sketch.into_inner())?;
|
||||
let sketch = objects.sketches.insert(sketch)?;
|
||||
|
||||
let path = Vector::from(self.path());
|
||||
|
||||
let solid = sketch.sweep(path, objects)?;
|
||||
solid.deref().clone().validate_with_config(config)
|
||||
Ok(solid.deref().clone())
|
||||
}
|
||||
|
||||
fn bounding_volume(&self) -> Aabb<3> {
|
||||
|
|
|
@ -2,7 +2,7 @@ use fj_interop::debug::DebugInfo;
|
|||
use fj_kernel::{
|
||||
algorithms::transform::TransformObject,
|
||||
objects::{FaceSet, Objects},
|
||||
validate::{Validate, Validated, ValidationConfig, ValidationError},
|
||||
validate::{ValidationConfig, ValidationError},
|
||||
};
|
||||
use fj_math::{Aabb, Transform, Vector};
|
||||
|
||||
|
@ -16,14 +16,13 @@ impl Shape for fj::Transform {
|
|||
config: &ValidationConfig,
|
||||
objects: &Objects,
|
||||
debug_info: &mut DebugInfo,
|
||||
) -> Result<Validated<Self::Brep>, ValidationError> {
|
||||
) -> Result<Self::Brep, ValidationError> {
|
||||
let faces = self
|
||||
.shape
|
||||
.compute_brep(config, objects, debug_info)?
|
||||
.into_inner()
|
||||
.transform(&make_transform(self), objects)?;
|
||||
|
||||
faces.validate_with_config(config)
|
||||
Ok(faces)
|
||||
}
|
||||
|
||||
fn bounding_volume(&self) -> Aabb<3> {
|
||||
|
|
Loading…
Reference in New Issue