mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-21 14:45:51 +00:00
Extract non-essential methods from PartialFace
This commit is contained in:
parent
2dd5f6d68d
commit
e8e74cf295
@ -150,7 +150,7 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
builder::CurveBuilder,
|
builder::{CurveBuilder, FaceBuilder},
|
||||||
objects::{Curve, Face, Objects},
|
objects::{Curve, Face, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::intersect::CurveFaceIntersection,
|
algorithms::intersect::CurveFaceIntersection,
|
||||||
builder::CurveBuilder,
|
builder::{CurveBuilder, FaceBuilder},
|
||||||
objects::{Curve, Face, Objects},
|
objects::{Curve, Face, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
};
|
};
|
||||||
|
@ -136,6 +136,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::intersect::{face_point::FacePointIntersection, Intersect},
|
algorithms::intersect::{face_point::FacePointIntersection, Intersect},
|
||||||
|
builder::FaceBuilder,
|
||||||
iter::ObjectIters,
|
iter::ObjectIters,
|
||||||
objects::{Face, Objects},
|
objects::{Face, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
|
@ -152,6 +152,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
transform::TransformObject,
|
transform::TransformObject,
|
||||||
},
|
},
|
||||||
|
builder::FaceBuilder,
|
||||||
iter::ObjectIters,
|
iter::ObjectIters,
|
||||||
objects::{Face, Objects},
|
objects::{Face, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
|
@ -84,7 +84,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::{reverse::Reverse, transform::TransformObject},
|
algorithms::{reverse::Reverse, transform::TransformObject},
|
||||||
builder::HalfEdgeBuilder,
|
builder::{FaceBuilder, HalfEdgeBuilder},
|
||||||
objects::{Face, HalfEdge, Objects, Sketch},
|
objects::{Face, HalfEdge, Objects, Sketch},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
};
|
};
|
||||||
|
@ -84,6 +84,7 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::approx::{Approx, Tolerance},
|
algorithms::approx::{Approx, Tolerance},
|
||||||
|
builder::FaceBuilder,
|
||||||
objects::{Face, Objects},
|
objects::{Face, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
|
49
crates/fj-kernel/src/builder/face.rs
Normal file
49
crates/fj-kernel/src/builder/face.rs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
use fj_math::Point;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
objects::Cycle,
|
||||||
|
partial::{HasPartial, PartialFace},
|
||||||
|
};
|
||||||
|
|
||||||
|
use super::CycleBuilder;
|
||||||
|
|
||||||
|
/// Builder API for [`PartialFace`]
|
||||||
|
pub trait FaceBuilder {
|
||||||
|
/// Update the [`PartialFace`] with an exterior polygon
|
||||||
|
fn with_exterior_polygon_from_points(
|
||||||
|
self,
|
||||||
|
points: impl IntoIterator<Item = impl Into<Point<2>>>,
|
||||||
|
) -> Self;
|
||||||
|
|
||||||
|
/// Update the [`PartialFace`] with an interior polygon
|
||||||
|
fn with_interior_polygon_from_points(
|
||||||
|
self,
|
||||||
|
points: impl IntoIterator<Item = impl Into<Point<2>>>,
|
||||||
|
) -> Self;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FaceBuilder for PartialFace {
|
||||||
|
fn with_exterior_polygon_from_points(
|
||||||
|
self,
|
||||||
|
points: impl IntoIterator<Item = impl Into<Point<2>>>,
|
||||||
|
) -> Self {
|
||||||
|
let surface = self.surface().expect("Need surface to create polygon");
|
||||||
|
|
||||||
|
self.with_exterior(
|
||||||
|
Cycle::partial()
|
||||||
|
.with_poly_chain_from_points(surface, points)
|
||||||
|
.close_with_line_segment(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn with_interior_polygon_from_points(
|
||||||
|
self,
|
||||||
|
points: impl IntoIterator<Item = impl Into<Point<2>>>,
|
||||||
|
) -> Self {
|
||||||
|
let surface = self.surface().expect("Need surface to build polygon.");
|
||||||
|
|
||||||
|
self.with_interiors([Cycle::partial()
|
||||||
|
.with_poly_chain_from_points(surface, points)
|
||||||
|
.close_with_line_segment()])
|
||||||
|
}
|
||||||
|
}
|
@ -11,12 +11,14 @@ mod solid;
|
|||||||
mod curve;
|
mod curve;
|
||||||
mod cycle;
|
mod cycle;
|
||||||
mod edge;
|
mod edge;
|
||||||
|
mod face;
|
||||||
mod vertex;
|
mod vertex;
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
curve::CurveBuilder,
|
curve::CurveBuilder,
|
||||||
cycle::CycleBuilder,
|
cycle::CycleBuilder,
|
||||||
edge::{GlobalEdgeBuilder, HalfEdgeBuilder},
|
edge::{GlobalEdgeBuilder, HalfEdgeBuilder},
|
||||||
|
face::FaceBuilder,
|
||||||
shell::ShellBuilder,
|
shell::ShellBuilder,
|
||||||
sketch::SketchBuilder,
|
sketch::SketchBuilder,
|
||||||
solid::SolidBuilder,
|
solid::SolidBuilder,
|
||||||
|
@ -5,7 +5,7 @@ use fj_math::Scalar;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::transform::TransformObject,
|
algorithms::transform::TransformObject,
|
||||||
builder::HalfEdgeBuilder,
|
builder::{FaceBuilder, HalfEdgeBuilder},
|
||||||
objects::{
|
objects::{
|
||||||
Curve, Cycle, Face, FaceSet, HalfEdge, Objects, Shell, Surface,
|
Curve, Cycle, Face, FaceSet, HalfEdge, Objects, Shell, Surface,
|
||||||
SurfaceVertex, Vertex,
|
SurfaceVertex, Vertex,
|
||||||
|
@ -6,6 +6,8 @@ use crate::{
|
|||||||
storage::Handle,
|
storage::Handle,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::FaceBuilder;
|
||||||
|
|
||||||
/// API for building a [`Sketch`]
|
/// API for building a [`Sketch`]
|
||||||
///
|
///
|
||||||
/// Also see [`Sketch::builder`].
|
/// Also see [`Sketch::builder`].
|
||||||
|
@ -360,7 +360,7 @@ impl<T> Iterator for Iter<T> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
builder::{CurveBuilder, CycleBuilder, HalfEdgeBuilder},
|
builder::{CurveBuilder, CycleBuilder, FaceBuilder, HalfEdgeBuilder},
|
||||||
objects::{
|
objects::{
|
||||||
Curve, Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Objects,
|
Curve, Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Objects,
|
||||||
Shell, Sketch, Solid, SurfaceVertex, Vertex,
|
Shell, Sketch, Solid, SurfaceVertex, Vertex,
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
use fj_interop::mesh::Color;
|
use fj_interop::mesh::Color;
|
||||||
use fj_math::Point;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
builder::CycleBuilder,
|
|
||||||
objects::{Cycle, Face, Objects, Surface},
|
objects::{Cycle, Face, Objects, Surface},
|
||||||
partial::{util::merge_options, HasPartial, MaybePartial},
|
partial::{util::merge_options, MaybePartial},
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
validate::ValidationError,
|
validate::ValidationError,
|
||||||
};
|
};
|
||||||
@ -56,20 +54,6 @@ impl PartialFace {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build the [`Face`] with an exterior polygon from the provided points
|
|
||||||
pub fn with_exterior_polygon_from_points(
|
|
||||||
self,
|
|
||||||
points: impl IntoIterator<Item = impl Into<Point<2>>>,
|
|
||||||
) -> Self {
|
|
||||||
let surface = self.surface().expect("Need surface to create polygon");
|
|
||||||
|
|
||||||
self.with_exterior(
|
|
||||||
Cycle::partial()
|
|
||||||
.with_poly_chain_from_points(surface, points)
|
|
||||||
.close_with_line_segment(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Build the [`Face`] with the provided interior polygons
|
/// Build the [`Face`] with the provided interior polygons
|
||||||
pub fn with_interiors(
|
pub fn with_interiors(
|
||||||
mut self,
|
mut self,
|
||||||
@ -80,18 +64,6 @@ impl PartialFace {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build the [`Face`] with an interior polygon from the provided points
|
|
||||||
pub fn with_interior_polygon_from_points(
|
|
||||||
self,
|
|
||||||
points: impl IntoIterator<Item = impl Into<Point<2>>>,
|
|
||||||
) -> Self {
|
|
||||||
let surface = self.surface().expect("Need surface to build polygon.");
|
|
||||||
|
|
||||||
self.with_interiors([Cycle::partial()
|
|
||||||
.with_poly_chain_from_points(surface, points)
|
|
||||||
.close_with_line_segment()])
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Build the [`Face`] with the provided color
|
/// Build the [`Face`] with the provided color
|
||||||
pub fn with_color(mut self, color: Color) -> Self {
|
pub fn with_color(mut self, color: Color) -> Self {
|
||||||
self.color = Some(color);
|
self.color = Some(color);
|
||||||
|
@ -105,7 +105,7 @@ impl FaceValidationError {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::reverse::Reverse,
|
algorithms::reverse::Reverse,
|
||||||
builder::CycleBuilder,
|
builder::{CycleBuilder, FaceBuilder},
|
||||||
objects::{Cycle, Face, Objects},
|
objects::{Cycle, Face, Objects},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
validate::Validate,
|
validate::Validate,
|
||||||
|
@ -2,7 +2,7 @@ use std::ops::Deref;
|
|||||||
|
|
||||||
use fj_interop::{debug::DebugInfo, mesh::Color};
|
use fj_interop::{debug::DebugInfo, mesh::Color};
|
||||||
use fj_kernel::{
|
use fj_kernel::{
|
||||||
builder::HalfEdgeBuilder,
|
builder::{FaceBuilder, HalfEdgeBuilder},
|
||||||
objects::{Cycle, Face, HalfEdge, Objects, Sketch},
|
objects::{Cycle, Face, HalfEdge, Objects, Sketch},
|
||||||
partial::HasPartial,
|
partial::HasPartial,
|
||||||
validate::ValidationError,
|
validate::ValidationError,
|
||||||
|
Loading…
Reference in New Issue
Block a user