Skip to content

Commit

Permalink
Merge pull request #414 from hannobraun/store
Browse files Browse the repository at this point in the history
Simplify `Store`
  • Loading branch information
hannobraun authored Mar 31, 2022
2 parents 2e53afc + 30c9afe commit b3a7fec
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 218 deletions.
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

0 comments on commit b3a7fec

Please sign in to comment.