Remove unused argument from trait method

This commit is contained in:
Hanno Braun 2022-11-09 12:03:24 +01:00
parent ee266a7da2
commit 66fb1934e3
7 changed files with 23 additions and 40 deletions

View File

@ -5,7 +5,7 @@ use fj_kernel::{
algorithms::reverse::Reverse, algorithms::reverse::Reverse,
iter::ObjectIters, iter::ObjectIters,
objects::{Face, Objects, Sketch}, objects::{Face, Objects, Sketch},
validate::{ValidationConfig, ValidationError}, validate::ValidationError,
}; };
use fj_math::Aabb; use fj_math::Aabb;
@ -16,7 +16,6 @@ impl Shape for fj::Difference2d {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig,
objects: &Objects, objects: &Objects,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Self::Brep, ValidationError> { ) -> Result<Self::Brep, ValidationError> {
@ -28,9 +27,10 @@ impl Shape for fj::Difference2d {
let mut exteriors = Vec::new(); let mut exteriors = Vec::new();
let mut interiors = Vec::new(); let mut interiors = Vec::new();
let [a, b] = self.shapes().each_ref_ext().try_map_ext(|shape| { let [a, b] = self
shape.compute_brep(config, objects, debug_info) .shapes()
})?; .each_ref_ext()
.try_map_ext(|shape| shape.compute_brep(objects, debug_info))?;
if let Some(face) = a.face_iter().next() { if let Some(face) = a.face_iter().next() {
// If there's at least one face to subtract from, we can proceed. // If there's at least one face to subtract from, we can proceed.

View File

@ -1,7 +1,7 @@
use fj_interop::debug::DebugInfo; use fj_interop::debug::DebugInfo;
use fj_kernel::{ use fj_kernel::{
objects::{FaceSet, Objects}, objects::{FaceSet, Objects},
validate::{ValidationConfig, ValidationError}, validate::ValidationError,
}; };
use fj_math::Aabb; use fj_math::Aabb;
@ -12,14 +12,13 @@ impl Shape for fj::Group {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig,
objects: &Objects, objects: &Objects,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Self::Brep, ValidationError> { ) -> Result<Self::Brep, ValidationError> {
let mut faces = FaceSet::new(); let mut faces = FaceSet::new();
let a = self.a.compute_brep(config, objects, debug_info)?; let a = self.a.compute_brep(objects, debug_info)?;
let b = self.b.compute_brep(config, objects, debug_info)?; let b = self.b.compute_brep(objects, debug_info)?;
faces.extend(a); faces.extend(a);
faces.extend(b); faces.extend(b);

View File

@ -27,7 +27,7 @@ mod transform;
use fj_interop::debug::DebugInfo; use fj_interop::debug::DebugInfo;
use fj_kernel::{ use fj_kernel::{
objects::{FaceSet, Objects, Sketch}, objects::{FaceSet, Objects, Sketch},
validate::{ValidationConfig, ValidationError}, validate::ValidationError,
}; };
use fj_math::Aabb; use fj_math::Aabb;
@ -39,7 +39,6 @@ pub trait Shape {
/// Compute the boundary representation of the shape /// Compute the boundary representation of the shape
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig,
objects: &Objects, objects: &Objects,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Self::Brep, ValidationError>; ) -> Result<Self::Brep, ValidationError>;
@ -56,20 +55,16 @@ impl Shape for fj::Shape {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig,
objects: &Objects, objects: &Objects,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Self::Brep, ValidationError> { ) -> Result<Self::Brep, ValidationError> {
match self { match self {
Self::Shape2d(shape) => Ok(shape Self::Shape2d(shape) => {
.compute_brep(config, objects, debug_info)? Ok(shape.compute_brep(objects, debug_info)?.faces().clone())
.faces()
.clone()),
Self::Group(shape) => {
shape.compute_brep(config, objects, debug_info)
} }
Self::Group(shape) => shape.compute_brep(objects, debug_info),
Self::Sweep(shape) => Ok(shape Self::Sweep(shape) => Ok(shape
.compute_brep(config, objects, debug_info)? .compute_brep(objects, debug_info)?
.shells() .shells()
.map(|shell| shell.faces().clone()) .map(|shell| shell.faces().clone())
.reduce(|mut a, b| { .reduce(|mut a, b| {
@ -77,9 +72,7 @@ impl Shape for fj::Shape {
a a
}) })
.unwrap_or_default()), .unwrap_or_default()),
Self::Transform(shape) => { Self::Transform(shape) => shape.compute_brep(objects, debug_info),
shape.compute_brep(config, objects, debug_info)
}
} }
} }
@ -98,17 +91,12 @@ impl Shape for fj::Shape2d {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig,
objects: &Objects, objects: &Objects,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Self::Brep, ValidationError> { ) -> Result<Self::Brep, ValidationError> {
match self { match self {
Self::Difference(shape) => { Self::Difference(shape) => shape.compute_brep(objects, debug_info),
shape.compute_brep(config, objects, debug_info) Self::Sketch(shape) => shape.compute_brep(objects, debug_info),
}
Self::Sketch(shape) => {
shape.compute_brep(config, objects, debug_info)
}
} }
} }

View File

@ -7,7 +7,7 @@ use fj_kernel::{
triangulate::Triangulate, triangulate::Triangulate,
}, },
objects::Objects, objects::Objects,
validate::{ValidationConfig, ValidationError}, validate::ValidationError,
}; };
use fj_math::Scalar; use fj_math::Scalar;
@ -42,10 +42,9 @@ impl ShapeProcessor {
Some(user_defined_tolerance) => user_defined_tolerance, Some(user_defined_tolerance) => user_defined_tolerance,
}; };
let config = ValidationConfig::default();
let objects = Objects::new(); let objects = Objects::new();
let mut debug_info = DebugInfo::new(); let mut debug_info = DebugInfo::new();
let shape = shape.compute_brep(&config, &objects, &mut debug_info)?; let shape = shape.compute_brep(&objects, &mut debug_info)?;
let mesh = (&shape, tolerance).triangulate(); let mesh = (&shape, tolerance).triangulate();
Ok(ProcessedShape { Ok(ProcessedShape {

View File

@ -5,7 +5,7 @@ use fj_kernel::{
builder::HalfEdgeBuilder, builder::HalfEdgeBuilder,
objects::{Cycle, Face, HalfEdge, Objects, Sketch}, objects::{Cycle, Face, HalfEdge, Objects, Sketch},
partial::HasPartial, partial::HasPartial,
validate::{ValidationConfig, ValidationError}, validate::ValidationError,
}; };
use fj_math::{Aabb, Point}; use fj_math::{Aabb, Point};
@ -16,7 +16,6 @@ impl Shape for fj::Sketch {
fn compute_brep( fn compute_brep(
&self, &self,
_: &ValidationConfig,
objects: &Objects, objects: &Objects,
_: &mut DebugInfo, _: &mut DebugInfo,
) -> Result<Self::Brep, ValidationError> { ) -> Result<Self::Brep, ValidationError> {

View File

@ -4,7 +4,7 @@ use fj_interop::debug::DebugInfo;
use fj_kernel::{ use fj_kernel::{
algorithms::sweep::Sweep, algorithms::sweep::Sweep,
objects::{Objects, Solid}, objects::{Objects, Solid},
validate::{ValidationConfig, ValidationError}, validate::ValidationError,
}; };
use fj_math::{Aabb, Vector}; use fj_math::{Aabb, Vector};
@ -15,11 +15,10 @@ impl Shape for fj::Sweep {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig,
objects: &Objects, objects: &Objects,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Self::Brep, ValidationError> { ) -> Result<Self::Brep, ValidationError> {
let sketch = self.shape().compute_brep(config, objects, debug_info)?; let sketch = self.shape().compute_brep(objects, debug_info)?;
let sketch = objects.sketches.insert(sketch)?; let sketch = objects.sketches.insert(sketch)?;
let path = Vector::from(self.path()); let path = Vector::from(self.path());

View File

@ -2,7 +2,7 @@ use fj_interop::debug::DebugInfo;
use fj_kernel::{ use fj_kernel::{
algorithms::transform::TransformObject, algorithms::transform::TransformObject,
objects::{FaceSet, Objects}, objects::{FaceSet, Objects},
validate::{ValidationConfig, ValidationError}, validate::ValidationError,
}; };
use fj_math::{Aabb, Transform, Vector}; use fj_math::{Aabb, Transform, Vector};
@ -13,13 +13,12 @@ impl Shape for fj::Transform {
fn compute_brep( fn compute_brep(
&self, &self,
config: &ValidationConfig,
objects: &Objects, objects: &Objects,
debug_info: &mut DebugInfo, debug_info: &mut DebugInfo,
) -> Result<Self::Brep, ValidationError> { ) -> Result<Self::Brep, ValidationError> {
let faces = self let faces = self
.shape .shape
.compute_brep(config, objects, debug_info)? .compute_brep(objects, debug_info)?
.transform(&make_transform(self), objects)?; .transform(&make_transform(self), objects)?;
Ok(faces) Ok(faces)