mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-19 05:35:55 +00:00
Remove Surface
ref from Curve
/PartialCurve
This commit is contained in:
parent
936c520874
commit
252d439592
@ -219,7 +219,7 @@ mod tests {
|
||||
builder::{CurveBuilder, SurfaceBuilder},
|
||||
geometry::path::GlobalPath,
|
||||
insert::Insert,
|
||||
partial::{Partial, PartialCurve, PartialObject, PartialSurface},
|
||||
partial::{PartialCurve, PartialObject, PartialSurface},
|
||||
services::Services,
|
||||
};
|
||||
|
||||
@ -231,7 +231,6 @@ mod tests {
|
||||
|
||||
let surface = services.objects.surfaces.xz_plane();
|
||||
let mut curve = PartialCurve {
|
||||
surface: Partial::from(surface.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
curve.update_as_line_from_points([[1., 1.], [2., 1.]]);
|
||||
@ -256,7 +255,6 @@ mod tests {
|
||||
.build(&mut services.objects)
|
||||
.insert(&mut services.objects);
|
||||
let mut curve = PartialCurve {
|
||||
surface: Partial::from(surface.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
curve.update_as_line_from_points([[1., 1.], [1., 2.]]);
|
||||
@ -279,7 +277,6 @@ mod tests {
|
||||
.build(&mut services.objects)
|
||||
.insert(&mut services.objects);
|
||||
let mut curve = PartialCurve {
|
||||
surface: Partial::from(surface.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
curve.update_as_line_from_points([[0., 1.], [1., 1.]]);
|
||||
@ -312,7 +309,6 @@ mod tests {
|
||||
|
||||
let surface = services.objects.surfaces.xz_plane();
|
||||
let mut curve = PartialCurve {
|
||||
surface: Partial::from(surface.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
curve.update_as_circle_from_radius(1.);
|
||||
|
@ -88,7 +88,6 @@ mod tests {
|
||||
|
||||
let surface = Partial::from(services.objects.surfaces.xy_plane());
|
||||
let mut curve = PartialCurve {
|
||||
surface: surface.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
curve.update_as_u_axis();
|
||||
@ -119,7 +118,6 @@ mod tests {
|
||||
|
||||
let surface = Partial::from(services.objects.surfaces.xy_plane());
|
||||
let mut curve = PartialCurve {
|
||||
surface: surface.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
curve.update_as_u_axis();
|
||||
@ -150,7 +148,6 @@ mod tests {
|
||||
|
||||
let surface = Partial::from(services.objects.surfaces.xy_plane());
|
||||
let mut curve = PartialCurve {
|
||||
surface: surface.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
curve.update_as_u_axis();
|
||||
@ -176,7 +173,6 @@ mod tests {
|
||||
|
||||
let surface = Partial::from(services.objects.surfaces.xy_plane());
|
||||
let mut curve = PartialCurve {
|
||||
surface: surface.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
curve.update_as_u_axis();
|
||||
|
@ -164,7 +164,6 @@ mod tests {
|
||||
let surface = Partial::from(services.objects.surfaces.xy_plane());
|
||||
|
||||
let mut curve = PartialCurve {
|
||||
surface: surface.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
curve.update_as_line_from_points([[-3., 0.], [-2., 0.]]);
|
||||
|
@ -132,9 +132,8 @@ mod tests {
|
||||
let intersection =
|
||||
FaceFaceIntersection::compute([&a, &b], &mut services.objects);
|
||||
|
||||
let expected_curves = surfaces.map(|surface| {
|
||||
let expected_curves = surfaces.map(|_| {
|
||||
let mut curve = PartialCurve {
|
||||
surface: Partial::from(surface),
|
||||
..Default::default()
|
||||
};
|
||||
curve.update_as_line_from_points([[0., 0.], [1., 0.]]);
|
||||
|
@ -57,11 +57,11 @@ impl SurfaceSurfaceIntersection {
|
||||
|
||||
let line = Line::from_origin_and_direction(origin, direction);
|
||||
|
||||
let curves = surfaces_and_planes.map(|(surface, plane)| {
|
||||
let curves = surfaces_and_planes.map(|(_, plane)| {
|
||||
let path = SurfacePath::Line(plane.project_line(&line));
|
||||
let global_form = GlobalCurve.insert(objects);
|
||||
|
||||
Curve::new(surface, path, global_form).insert(objects)
|
||||
Curve::new(path, global_form).insert(objects)
|
||||
});
|
||||
|
||||
Some(Self {
|
||||
@ -92,7 +92,7 @@ mod tests {
|
||||
algorithms::transform::TransformObject,
|
||||
builder::CurveBuilder,
|
||||
insert::Insert,
|
||||
partial::{Partial, PartialCurve, PartialObject},
|
||||
partial::{PartialCurve, PartialObject},
|
||||
services::Services,
|
||||
};
|
||||
|
||||
@ -121,7 +121,6 @@ mod tests {
|
||||
);
|
||||
|
||||
let mut expected_xy = PartialCurve {
|
||||
surface: Partial::from(xy.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
expected_xy.update_as_u_axis();
|
||||
@ -129,7 +128,6 @@ mod tests {
|
||||
.build(&mut services.objects)
|
||||
.insert(&mut services.objects);
|
||||
let mut expected_xz = PartialCurve {
|
||||
surface: Partial::from(xz.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
expected_xz.update_as_u_axis();
|
||||
|
@ -18,16 +18,12 @@ impl TransformObject for Curve {
|
||||
// coordinates, and thus transforming `surface` takes care of it.
|
||||
let path = self.path();
|
||||
|
||||
let surface = self
|
||||
.surface()
|
||||
.clone()
|
||||
.transform_with_cache(transform, objects, cache);
|
||||
let global_form = self
|
||||
.global_form()
|
||||
.clone()
|
||||
.transform_with_cache(transform, objects, cache);
|
||||
|
||||
Self::new(surface, path, global_form)
|
||||
Self::new(path, global_form)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,6 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
||||
|
||||
self.surface = surface.clone();
|
||||
|
||||
self.curve.write().surface = surface.clone();
|
||||
|
||||
for vertex in &mut self.vertices {
|
||||
vertex.1.write().surface = surface.clone();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
geometry::path::SurfacePath,
|
||||
objects::Surface,
|
||||
storage::{Handle, HandleWrapper},
|
||||
};
|
||||
|
||||
@ -8,19 +7,16 @@ use crate::{
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
pub struct Curve {
|
||||
path: SurfacePath,
|
||||
surface: Handle<Surface>,
|
||||
global_form: HandleWrapper<GlobalCurve>,
|
||||
}
|
||||
|
||||
impl Curve {
|
||||
/// Construct a new instance of `Curve`
|
||||
pub fn new(
|
||||
surface: Handle<Surface>,
|
||||
path: SurfacePath,
|
||||
global_form: impl Into<HandleWrapper<GlobalCurve>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
surface,
|
||||
path,
|
||||
global_form: global_form.into(),
|
||||
}
|
||||
@ -31,11 +27,6 @@ impl Curve {
|
||||
self.path
|
||||
}
|
||||
|
||||
/// Access the surface that the curve is defined in
|
||||
pub fn surface(&self) -> &Handle<Surface> {
|
||||
&self.surface
|
||||
}
|
||||
|
||||
/// Access the global form of the curve
|
||||
pub fn global_form(&self) -> &Handle<GlobalCurve> {
|
||||
&self.global_form
|
||||
|
@ -2,7 +2,7 @@ use fj_math::Scalar;
|
||||
|
||||
use crate::{
|
||||
geometry::path::SurfacePath,
|
||||
objects::{Curve, GlobalCurve, Objects, Surface},
|
||||
objects::{Curve, GlobalCurve, Objects},
|
||||
partial::{FullToPartialCache, Partial, PartialObject},
|
||||
services::Service,
|
||||
};
|
||||
@ -13,9 +13,6 @@ pub struct PartialCurve {
|
||||
/// The path that defines the curve
|
||||
pub path: Option<MaybeSurfacePath>,
|
||||
|
||||
/// The surface the curve is defined in
|
||||
pub surface: Partial<Surface>,
|
||||
|
||||
/// The global form of the curve
|
||||
pub global_form: Partial<GlobalCurve>,
|
||||
}
|
||||
@ -26,7 +23,6 @@ impl PartialObject for PartialCurve {
|
||||
fn from_full(curve: &Self::Full, cache: &mut FullToPartialCache) -> Self {
|
||||
Self {
|
||||
path: Some(curve.path().into()),
|
||||
surface: Partial::from_full(curve.surface().clone(), cache),
|
||||
global_form: Partial::from_full(curve.global_form().clone(), cache),
|
||||
}
|
||||
}
|
||||
@ -40,10 +36,9 @@ impl PartialObject for PartialCurve {
|
||||
)
|
||||
}
|
||||
};
|
||||
let surface = self.surface.build(objects);
|
||||
let global_form = self.global_form.build(objects);
|
||||
|
||||
Curve::new(surface, path, global_form)
|
||||
Curve::new(path, global_form)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,16 +166,12 @@ impl HalfEdgeValidationError {
|
||||
errors: &mut Vec<ValidationError>,
|
||||
) {
|
||||
let surface = half_edge.surface();
|
||||
|
||||
let curve_surface = half_edge.curve().surface();
|
||||
let surface_form_surface = half_edge.start_vertex().surface();
|
||||
|
||||
if surface.id() != curve_surface.id()
|
||||
|| surface.id() != surface_form_surface.id()
|
||||
{
|
||||
if surface.id() != surface_form_surface.id() {
|
||||
errors.push(
|
||||
Box::new(Self::SurfaceMismatch {
|
||||
curve_surface: curve_surface.clone(),
|
||||
curve_surface: surface.clone(),
|
||||
surface_form_surface: surface_form_surface.clone(),
|
||||
})
|
||||
.into(),
|
||||
|
Loading…
Reference in New Issue
Block a user