mirror of https://github.com/hannobraun/Fornjot
Remove `PartialCurve::with_surface`
This commit is contained in:
parent
a1638400df
commit
8524c2f773
|
@ -199,8 +199,8 @@ mod tests {
|
||||||
algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint},
|
algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint},
|
||||||
builder::CurveBuilder,
|
builder::CurveBuilder,
|
||||||
insert::Insert,
|
insert::Insert,
|
||||||
objects::{Curve, Objects, Surface},
|
objects::{Objects, Surface},
|
||||||
partial::HasPartial,
|
partial::PartialCurve,
|
||||||
path::GlobalPath,
|
path::GlobalPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -213,8 +213,10 @@ mod tests {
|
||||||
let surface = objects
|
let surface = objects
|
||||||
.surfaces
|
.surfaces
|
||||||
.insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]))?;
|
.insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]))?;
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface))
|
surface: Some(surface),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_line_from_points([[1., 1.], [2., 1.]])
|
.update_as_line_from_points([[1., 1.], [2., 1.]])
|
||||||
.build(&objects)?
|
.build(&objects)?
|
||||||
.insert(&objects)?;
|
.insert(&objects)?;
|
||||||
|
@ -235,8 +237,10 @@ mod tests {
|
||||||
GlobalPath::circle_from_radius(1.),
|
GlobalPath::circle_from_radius(1.),
|
||||||
[0., 0., 1.],
|
[0., 0., 1.],
|
||||||
))?;
|
))?;
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface))
|
surface: Some(surface),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_line_from_points([[1., 1.], [1., 2.]])
|
.update_as_line_from_points([[1., 1.], [1., 2.]])
|
||||||
.build(&objects)?
|
.build(&objects)?
|
||||||
.insert(&objects)?;
|
.insert(&objects)?;
|
||||||
|
@ -255,8 +259,10 @@ mod tests {
|
||||||
let path = GlobalPath::circle_from_radius(1.);
|
let path = GlobalPath::circle_from_radius(1.);
|
||||||
let surface =
|
let surface =
|
||||||
objects.surfaces.insert(Surface::new(path, [0., 0., 1.]))?;
|
objects.surfaces.insert(Surface::new(path, [0., 0., 1.]))?;
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface.clone()))
|
surface: Some(surface.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_line_from_points([[0., 1.], [1., 1.]])
|
.update_as_line_from_points([[0., 1.], [1., 1.]])
|
||||||
.build(&objects)?
|
.build(&objects)?
|
||||||
.insert(&objects)?;
|
.insert(&objects)?;
|
||||||
|
@ -288,8 +294,10 @@ mod tests {
|
||||||
let surface = objects
|
let surface = objects
|
||||||
.surfaces
|
.surfaces
|
||||||
.insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]))?;
|
.insert(Surface::new(GlobalPath::x_axis(), [0., 0., 1.]))?;
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface))
|
surface: Some(surface),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_circle_from_radius(1.)
|
.update_as_circle_from_radius(1.)
|
||||||
.build(&objects)?
|
.build(&objects)?
|
||||||
.insert(&objects)?;
|
.insert(&objects)?;
|
||||||
|
|
|
@ -76,8 +76,8 @@ mod tests {
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
builder::{CurveBuilder, HalfEdgeBuilder},
|
builder::{CurveBuilder, HalfEdgeBuilder},
|
||||||
objects::{Curve, HalfEdge, Objects},
|
objects::{HalfEdge, Objects},
|
||||||
partial::HasPartial,
|
partial::{HasPartial, PartialCurve},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::CurveEdgeIntersection;
|
use super::CurveEdgeIntersection;
|
||||||
|
@ -87,8 +87,10 @@ mod tests {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.xy_plane();
|
let surface = objects.surfaces.xy_plane();
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface.clone()))
|
surface: Some(surface.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis()
|
.update_as_u_axis()
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
let half_edge = HalfEdge::partial()
|
let half_edge = HalfEdge::partial()
|
||||||
|
@ -111,8 +113,10 @@ mod tests {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.xy_plane();
|
let surface = objects.surfaces.xy_plane();
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface.clone()))
|
surface: Some(surface.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis()
|
.update_as_u_axis()
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
let half_edge = HalfEdge::partial()
|
let half_edge = HalfEdge::partial()
|
||||||
|
@ -138,8 +142,10 @@ mod tests {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.xy_plane();
|
let surface = objects.surfaces.xy_plane();
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface.clone()))
|
surface: Some(surface.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis()
|
.update_as_u_axis()
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
let half_edge = HalfEdge::partial()
|
let half_edge = HalfEdge::partial()
|
||||||
|
@ -160,8 +166,10 @@ mod tests {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.xy_plane();
|
let surface = objects.surfaces.xy_plane();
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface.clone()))
|
surface: Some(surface.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis()
|
.update_as_u_axis()
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
let half_edge = HalfEdge::partial()
|
let half_edge = HalfEdge::partial()
|
||||||
|
|
|
@ -151,8 +151,8 @@ where
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
builder::{CurveBuilder, FaceBuilder},
|
builder::{CurveBuilder, FaceBuilder},
|
||||||
objects::{Curve, Face, Objects},
|
objects::{Face, Objects},
|
||||||
partial::HasPartial,
|
partial::{HasPartial, PartialCurve},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::CurveFaceIntersection;
|
use super::CurveFaceIntersection;
|
||||||
|
@ -163,8 +163,10 @@ mod tests {
|
||||||
|
|
||||||
let surface = objects.surfaces.xy_plane();
|
let surface = objects.surfaces.xy_plane();
|
||||||
|
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface.clone()))
|
surface: Some(surface.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_line_from_points([[-3., 0.], [-2., 0.]])
|
.update_as_line_from_points([[-3., 0.], [-2., 0.]])
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,8 @@ mod tests {
|
||||||
algorithms::intersect::CurveFaceIntersection,
|
algorithms::intersect::CurveFaceIntersection,
|
||||||
builder::{CurveBuilder, FaceBuilder},
|
builder::{CurveBuilder, FaceBuilder},
|
||||||
insert::Insert,
|
insert::Insert,
|
||||||
objects::{Curve, Face, Objects},
|
objects::{Face, Objects},
|
||||||
partial::HasPartial,
|
partial::{HasPartial, PartialCurve},
|
||||||
validate::ValidationError,
|
validate::ValidationError,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -129,8 +129,10 @@ mod tests {
|
||||||
|
|
||||||
let expected_curves =
|
let expected_curves =
|
||||||
surfaces.try_map_ext(|surface| -> Result<_, ValidationError> {
|
surfaces.try_map_ext(|surface| -> Result<_, ValidationError> {
|
||||||
Ok(Curve::partial()
|
Ok(PartialCurve {
|
||||||
.with_surface(Some(surface))
|
surface: Some(surface),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_line_from_points([[0., 0.], [1., 0.]])
|
.update_as_line_from_points([[0., 0.], [1., 0.]])
|
||||||
.build(&objects)?
|
.build(&objects)?
|
||||||
.insert(&objects)?)
|
.insert(&objects)?)
|
||||||
|
|
|
@ -91,11 +91,8 @@ mod tests {
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::transform::TransformObject,
|
algorithms::transform::TransformObject, builder::CurveBuilder,
|
||||||
builder::CurveBuilder,
|
insert::Insert, objects::Objects, partial::PartialCurve,
|
||||||
insert::Insert,
|
|
||||||
objects::{Curve, Objects},
|
|
||||||
partial::HasPartial,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SurfaceSurfaceIntersection;
|
use super::SurfaceSurfaceIntersection;
|
||||||
|
@ -122,13 +119,17 @@ mod tests {
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
let expected_xy = Curve::partial()
|
let expected_xy = PartialCurve {
|
||||||
.with_surface(Some(xy.clone()))
|
surface: Some(xy.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis()
|
.update_as_u_axis()
|
||||||
.build(&objects)?
|
.build(&objects)?
|
||||||
.insert(&objects)?;
|
.insert(&objects)?;
|
||||||
let expected_xz = Curve::partial()
|
let expected_xz = PartialCurve {
|
||||||
.with_surface(Some(xz.clone()))
|
surface: Some(xz.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis()
|
.update_as_u_axis()
|
||||||
.build(&objects)?
|
.build(&objects)?
|
||||||
.insert(&objects)?;
|
.insert(&objects)?;
|
||||||
|
|
|
@ -170,8 +170,8 @@ mod tests {
|
||||||
algorithms::sweep::Sweep,
|
algorithms::sweep::Sweep,
|
||||||
builder::{CurveBuilder, HalfEdgeBuilder},
|
builder::{CurveBuilder, HalfEdgeBuilder},
|
||||||
insert::Insert,
|
insert::Insert,
|
||||||
objects::{Curve, HalfEdge, Objects, Vertex},
|
objects::{HalfEdge, Objects, Vertex},
|
||||||
partial::HasPartial,
|
partial::{HasPartial, PartialCurve},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -179,8 +179,10 @@ mod tests {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.xz_plane();
|
let surface = objects.surfaces.xz_plane();
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface.clone()))
|
surface: Some(surface.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis()
|
.update_as_u_axis()
|
||||||
.build(&objects)?
|
.build(&objects)?
|
||||||
.insert(&objects)?;
|
.insert(&objects)?;
|
||||||
|
|
|
@ -41,9 +41,9 @@ impl TransformObject for PartialCurve {
|
||||||
// coordinates, and thus transforming `surface` takes care of it.
|
// coordinates, and thus transforming `surface` takes care of it.
|
||||||
Ok(PartialCurve {
|
Ok(PartialCurve {
|
||||||
path: self.path,
|
path: self.path,
|
||||||
|
surface,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.with_surface(surface)
|
|
||||||
.with_global_form(global_form))
|
.with_global_form(global_form))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use fj_math::Point;
|
use fj_math::Point;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
objects::{Curve, HalfEdge, Surface, SurfaceVertex, Vertex},
|
objects::{HalfEdge, Surface, SurfaceVertex, Vertex},
|
||||||
partial::{HasPartial, MaybePartial, PartialCycle},
|
partial::{HasPartial, MaybePartial, PartialCurve, PartialCycle},
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,8 +64,10 @@ impl CycleBuilder for PartialCycle {
|
||||||
|
|
||||||
previous = Some(vertex_next.clone());
|
previous = Some(vertex_next.clone());
|
||||||
|
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface.clone()))
|
surface: Some(surface.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_line_from_points([position_prev, position_next]);
|
.update_as_line_from_points([position_prev, position_next]);
|
||||||
|
|
||||||
let vertices = [(0., vertex_prev), (1., vertex_next)].map(
|
let vertices = [(0., vertex_prev), (1., vertex_next)].map(
|
||||||
|
|
|
@ -7,7 +7,10 @@ use crate::{
|
||||||
Curve, GlobalVertex, Objects, Surface, SurfaceVertex, Vertex,
|
Curve, GlobalVertex, Objects, Surface, SurfaceVertex, Vertex,
|
||||||
VerticesInNormalizedOrder,
|
VerticesInNormalizedOrder,
|
||||||
},
|
},
|
||||||
partial::{HasPartial, MaybePartial, PartialGlobalEdge, PartialHalfEdge},
|
partial::{
|
||||||
|
HasPartial, MaybePartial, PartialCurve, PartialGlobalEdge,
|
||||||
|
PartialHalfEdge,
|
||||||
|
},
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
validate::ValidationError,
|
validate::ValidationError,
|
||||||
};
|
};
|
||||||
|
@ -138,9 +141,11 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
||||||
.expect("Can't infer line segment without surface position")
|
.expect("Can't infer line segment without surface position")
|
||||||
});
|
});
|
||||||
|
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
|
surface: Some(surface),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.with_global_form(Some(self.extract_global_curve()))
|
.with_global_form(Some(self.extract_global_curve()))
|
||||||
.with_surface(Some(surface))
|
|
||||||
.update_as_line_from_points(points);
|
.update_as_line_from_points(points);
|
||||||
|
|
||||||
let [back, front] = {
|
let [back, front] = {
|
||||||
|
|
|
@ -363,10 +363,10 @@ mod tests {
|
||||||
builder::{CurveBuilder, CycleBuilder, FaceBuilder, HalfEdgeBuilder},
|
builder::{CurveBuilder, CycleBuilder, FaceBuilder, HalfEdgeBuilder},
|
||||||
insert::Insert,
|
insert::Insert,
|
||||||
objects::{
|
objects::{
|
||||||
Curve, Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Objects,
|
Cycle, Face, GlobalCurve, GlobalVertex, HalfEdge, Objects, Shell,
|
||||||
Shell, Sketch, Solid, SurfaceVertex, Vertex,
|
Sketch, Solid, SurfaceVertex, Vertex,
|
||||||
},
|
},
|
||||||
partial::HasPartial,
|
partial::{HasPartial, PartialCurve},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::ObjectIters as _;
|
use super::ObjectIters as _;
|
||||||
|
@ -376,8 +376,10 @@ mod tests {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.xy_plane();
|
let surface = objects.surfaces.xy_plane();
|
||||||
let object = Curve::partial()
|
let object = PartialCurve {
|
||||||
.with_surface(Some(surface))
|
surface: Some(surface),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis()
|
.update_as_u_axis()
|
||||||
.build(&objects)?
|
.build(&objects)?
|
||||||
.insert(&objects)?;
|
.insert(&objects)?;
|
||||||
|
@ -616,8 +618,10 @@ mod tests {
|
||||||
let objects = Objects::new();
|
let objects = Objects::new();
|
||||||
|
|
||||||
let surface = objects.surfaces.xy_plane();
|
let surface = objects.surfaces.xy_plane();
|
||||||
let curve = Curve::partial()
|
let curve = PartialCurve {
|
||||||
.with_surface(Some(surface.clone()))
|
surface: Some(surface.clone()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis()
|
.update_as_u_axis()
|
||||||
.build(&objects)?
|
.build(&objects)?
|
||||||
.insert(&objects)?;
|
.insert(&objects)?;
|
||||||
|
|
|
@ -22,14 +22,6 @@ pub struct PartialCurve {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialCurve {
|
impl PartialCurve {
|
||||||
/// Provide a surface for the partial curve
|
|
||||||
pub fn with_surface(mut self, surface: Option<Handle<Surface>>) -> Self {
|
|
||||||
if let Some(surface) = surface {
|
|
||||||
self.surface = Some(surface);
|
|
||||||
}
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Provide a global form for the partial curve
|
/// Provide a global form for the partial curve
|
||||||
pub fn with_global_form(
|
pub fn with_global_form(
|
||||||
mut self,
|
mut self,
|
||||||
|
|
|
@ -48,9 +48,10 @@ impl PartialHalfEdge {
|
||||||
|
|
||||||
/// Update the partial half-edge with the given surface
|
/// Update the partial half-edge with the given surface
|
||||||
pub fn with_surface(mut self, surface: Handle<Surface>) -> Self {
|
pub fn with_surface(mut self, surface: Handle<Surface>) -> Self {
|
||||||
self.curve = self
|
self.curve = self.curve.update_partial(|mut curve| {
|
||||||
.curve
|
curve.surface = Some(surface.clone());
|
||||||
.update_partial(|curve| curve.with_surface(Some(surface.clone())));
|
curve
|
||||||
|
});
|
||||||
|
|
||||||
self.vertices = self.vertices.map(|vertex| {
|
self.vertices = self.vertices.map(|vertex| {
|
||||||
vertex.update_partial(|vertex| {
|
vertex.update_partial(|vertex| {
|
||||||
|
|
|
@ -181,8 +181,8 @@ mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
builder::{CurveBuilder, SurfaceVertexBuilder},
|
builder::{CurveBuilder, SurfaceVertexBuilder},
|
||||||
insert::Insert,
|
insert::Insert,
|
||||||
objects::{Curve, GlobalVertex, Objects, SurfaceVertex, Vertex},
|
objects::{GlobalVertex, Objects, SurfaceVertex, Vertex},
|
||||||
partial::HasPartial,
|
partial::{HasPartial, PartialCurve},
|
||||||
validate::Validate,
|
validate::Validate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -193,8 +193,10 @@ mod tests {
|
||||||
let valid = Vertex::partial()
|
let valid = Vertex::partial()
|
||||||
.with_position(Some([0.]))
|
.with_position(Some([0.]))
|
||||||
.with_curve(
|
.with_curve(
|
||||||
Curve::partial()
|
PartialCurve {
|
||||||
.with_surface(Some(objects.surfaces.xy_plane()))
|
surface: Some(objects.surfaces.xy_plane()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis(),
|
.update_as_u_axis(),
|
||||||
)
|
)
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
|
@ -222,8 +224,10 @@ mod tests {
|
||||||
let valid = Vertex::partial()
|
let valid = Vertex::partial()
|
||||||
.with_position(Some([0.]))
|
.with_position(Some([0.]))
|
||||||
.with_curve(
|
.with_curve(
|
||||||
Curve::partial()
|
PartialCurve {
|
||||||
.with_surface(Some(objects.surfaces.xy_plane()))
|
surface: Some(objects.surfaces.xy_plane()),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
.update_as_u_axis(),
|
.update_as_u_axis(),
|
||||||
)
|
)
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
|
|
Loading…
Reference in New Issue