mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-20 14:15: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)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
builder::CurveBuilder,
|
||||
builder::{CurveBuilder, FaceBuilder},
|
||||
objects::{Curve, Face, Objects},
|
||||
partial::HasPartial,
|
||||
};
|
||||
|
@ -67,7 +67,7 @@ mod tests {
|
||||
|
||||
use crate::{
|
||||
algorithms::intersect::CurveFaceIntersection,
|
||||
builder::CurveBuilder,
|
||||
builder::{CurveBuilder, FaceBuilder},
|
||||
objects::{Curve, Face, Objects},
|
||||
partial::HasPartial,
|
||||
};
|
||||
|
@ -136,6 +136,7 @@ mod tests {
|
||||
|
||||
use crate::{
|
||||
algorithms::intersect::{face_point::FacePointIntersection, Intersect},
|
||||
builder::FaceBuilder,
|
||||
iter::ObjectIters,
|
||||
objects::{Face, Objects},
|
||||
partial::HasPartial,
|
||||
|
@ -152,6 +152,7 @@ mod tests {
|
||||
},
|
||||
transform::TransformObject,
|
||||
},
|
||||
builder::FaceBuilder,
|
||||
iter::ObjectIters,
|
||||
objects::{Face, Objects},
|
||||
partial::HasPartial,
|
||||
|
@ -84,7 +84,7 @@ mod tests {
|
||||
|
||||
use crate::{
|
||||
algorithms::{reverse::Reverse, transform::TransformObject},
|
||||
builder::HalfEdgeBuilder,
|
||||
builder::{FaceBuilder, HalfEdgeBuilder},
|
||||
objects::{Face, HalfEdge, Objects, Sketch},
|
||||
partial::HasPartial,
|
||||
};
|
||||
|
@ -84,6 +84,7 @@ mod tests {
|
||||
|
||||
use crate::{
|
||||
algorithms::approx::{Approx, Tolerance},
|
||||
builder::FaceBuilder,
|
||||
objects::{Face, Objects},
|
||||
partial::HasPartial,
|
||||
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 cycle;
|
||||
mod edge;
|
||||
mod face;
|
||||
mod vertex;
|
||||
|
||||
pub use self::{
|
||||
curve::CurveBuilder,
|
||||
cycle::CycleBuilder,
|
||||
edge::{GlobalEdgeBuilder, HalfEdgeBuilder},
|
||||
face::FaceBuilder,
|
||||
shell::ShellBuilder,
|
||||
sketch::SketchBuilder,
|
||||
solid::SolidBuilder,
|
||||
|
@ -5,7 +5,7 @@ use fj_math::Scalar;
|
||||
|
||||
use crate::{
|
||||
algorithms::transform::TransformObject,
|
||||
builder::HalfEdgeBuilder,
|
||||
builder::{FaceBuilder, HalfEdgeBuilder},
|
||||
objects::{
|
||||
Curve, Cycle, Face, FaceSet, HalfEdge, Objects, Shell, Surface,
|
||||
SurfaceVertex, Vertex,
|
||||
|
@ -6,6 +6,8 @@ use crate::{
|
||||
storage::Handle,
|
||||
};
|
||||
|
||||
use super::FaceBuilder;
|
||||
|
||||
/// API for building a [`Sketch`]
|
||||
///
|
||||
/// Also see [`Sketch::builder`].
|
||||
|
@ -360,7 +360,7 @@ impl<T> Iterator for Iter<T> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
builder::{CurveBuilder, CycleBuilder, HalfEdgeBuilder},
|
||||
builder::{CurveBuilder, CycleBuilder, FaceBuilder, HalfEdgeBuilder},
|
||||
objects::{
|
||||
Curve, Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Objects,
|
||||
Shell, Sketch, Solid, SurfaceVertex, Vertex,
|
||||
|
@ -1,10 +1,8 @@
|
||||
use fj_interop::mesh::Color;
|
||||
use fj_math::Point;
|
||||
|
||||
use crate::{
|
||||
builder::CycleBuilder,
|
||||
objects::{Cycle, Face, Objects, Surface},
|
||||
partial::{util::merge_options, HasPartial, MaybePartial},
|
||||
partial::{util::merge_options, MaybePartial},
|
||||
storage::Handle,
|
||||
validate::ValidationError,
|
||||
};
|
||||
@ -56,20 +54,6 @@ impl PartialFace {
|
||||
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
|
||||
pub fn with_interiors(
|
||||
mut self,
|
||||
@ -80,18 +64,6 @@ impl PartialFace {
|
||||
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
|
||||
pub fn with_color(mut self, color: Color) -> Self {
|
||||
self.color = Some(color);
|
||||
|
@ -105,7 +105,7 @@ impl FaceValidationError {
|
||||
mod tests {
|
||||
use crate::{
|
||||
algorithms::reverse::Reverse,
|
||||
builder::CycleBuilder,
|
||||
builder::{CycleBuilder, FaceBuilder},
|
||||
objects::{Cycle, Face, Objects},
|
||||
partial::HasPartial,
|
||||
validate::Validate,
|
||||
|
@ -2,7 +2,7 @@ use std::ops::Deref;
|
||||
|
||||
use fj_interop::{debug::DebugInfo, mesh::Color};
|
||||
use fj_kernel::{
|
||||
builder::HalfEdgeBuilder,
|
||||
builder::{FaceBuilder, HalfEdgeBuilder},
|
||||
objects::{Cycle, Face, HalfEdge, Objects, Sketch},
|
||||
partial::HasPartial,
|
||||
validate::ValidationError,
|
||||
|
Loading…
Reference in New Issue
Block a user