Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Store #414

Merged
merged 12 commits into from
Mar 31, 2022
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions fj-kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ nalgebra = "0.30.0"
parking_lot = "0.12.0"
parry2d-f64 = "0.8.0"
parry3d-f64 = "0.8.0"
slotmap = "1.0.6"
spade = "2.0.0"
thiserror = "1.0.30"

Expand Down
28 changes: 12 additions & 16 deletions fj-kernel/src/shape/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use crate::{
};

use super::{
handle::Handle,
stores::{Curves, Faces, Points, Surfaces},
Iter,
Handle, Iter,
};

/// API to access a shape's geometry
Expand Down Expand Up @@ -62,46 +61,43 @@ impl Geometry<'_> {
/// Since the topological types refer to geometry, and don't contain any
/// geometry themselves, this transforms the whole shape.
pub fn transform(&mut self, transform: &Transform) {
for mut point in self.points.iter_mut() {
*point = transform.transform_point(&point);
}
for mut curve in self.curves.iter_mut() {
*curve = curve.transform(transform);
}
for mut surface in self.surfaces.iter_mut() {
*surface = surface.transform(transform);
}
self.points
.update(|point| *point = transform.transform_point(point));
self.curves
.update(|curve| *curve = curve.transform(transform));
self.surfaces
.update(|surface| *surface = surface.transform(transform));

// While some faces use triangle representation, we need this weird
// workaround here.
for mut face in self.faces.iter_mut() {
self.faces.update(|mut face| {
use std::ops::DerefMut as _;
if let Face::Triangles(triangles) = face.deref_mut() {
for triangle in triangles {
*triangle = transform.transform_triangle(triangle);
}
}
}
});
}

/// Access an iterator over all points
///
/// The caller must not make any assumptions about the order of points.
pub fn points(&self) -> Iter<Point<3>> {
Iter::new(self.points)
self.points.iter()
}

/// Access an iterator over all curves
///
/// The caller must not make any assumptions about the order of curves.
pub fn curves(&self) -> Iter<Curve> {
Iter::new(self.curves)
self.curves.iter()
}

/// Access an iterator over all surfaces
///
/// The caller must not make any assumptions about the order of surfaces.
pub fn surfaces(&self) -> Iter<Surface> {
Iter::new(self.surfaces)
self.surfaces.iter()
}
}
134 changes: 0 additions & 134 deletions fj-kernel/src/shape/handle.rs

This file was deleted.

37 changes: 0 additions & 37 deletions fj-kernel/src/shape/iter.rs

This file was deleted.

5 changes: 1 addition & 4 deletions fj-kernel/src/shape/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@

mod api;
mod geometry;
mod handle;
mod iter;
mod stores;
mod topology;
mod validate;

pub use self::{
api::Shape,
geometry::Geometry,
handle::Handle,
iter::Iter,
stores::{Handle, Iter},
topology::Topology,
validate::{StructuralIssues, ValidationError, ValidationResult},
};
Loading