Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Feb 11, 2022
1 parent 4655c70 commit d311a2e
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/kernel/geometry/surfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use parry3d_f64::math::Isometry;

use crate::math::{Point, Vector};

use super::points::SurfacePoint;
use super::{points::SurfacePoint, Curve};

/// A two-dimensional shape
#[derive(Clone, Debug, PartialEq)]
Expand All @@ -22,6 +22,12 @@ impl Surface {
})
}

// TASK: Document.
pub fn sweep_from(_curve: Curve, _path: Vector<1>) -> Self {
// TASK: Implement.
todo!()
}

/// Transform the surface
#[must_use]
pub fn transform(self, transform: &Isometry<f64>) -> Self {
Expand Down
74 changes: 72 additions & 2 deletions src/kernel/shapes/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use crate::{
debug::DebugInfo,
kernel::{
approximation::Approximation,
geometry::Surface,
topology::{
edges::Edges,
edges::{self, Edge, Edges},
faces::{Face, Faces},
vertices::Vertices,
},
Expand Down Expand Up @@ -36,7 +37,76 @@ impl Shape for fj::Sweep {
self.length,
));

// TASK: Make the rest of this triangle-less too.
let mut side_faces = Vec::new();
for cycle in self.shape.edges().cycles {
for edge in cycle.edges {
let top_edge = edge.clone().transform(&Isometry::translation(
0.0,
0.0,
self.length,
));

let path = vector![self.length];

// TASK: If we can sweep lines into planes, then `Plane` becomes
// redundant.
// TASK: I think we need `Face::sweep_edge` here and call that.
let surface = Surface::sweep_from(edge.curve.clone(), path);

// TASK: This is problematic. The `Edge::sweep_vertex` calls
// create new vertices (using `Vertex::create_at`)
// internally. This is not good, as these edges share
// vertices, which means we're creating the same vertices
// multiple times. This is _forbidden_.
let edges = match edge.vertices {
Some([a, b]) => {
let a = Edge::sweep_vertex(a.to_canonical(), path);
let b = Edge::sweep_vertex(b.to_canonical(), path);

Edges::single_cycle([edge, a, top_edge, b])
}
None => Edges {
// TASK: What we have here is a continuous edge that is
// connected to itself. Hence the side wall that
// it forms is itself continuous and connected to
// itself.
//
// Such a construct is not supported by by the
// triangulation algorithm. I believe the usual
// way to address this is to disallow these kinds
// of constructs and always require at least one
// vertex/edge that marks the start/end.
//
// Maybe this is hubris, but I think it would be
// better to not require such a fake vertex/edge,
// as that would be confusing and might have other
// unforeseen consequences down the line.
//
// Instead, the approximation logic can handle
// this. Continuous edges are already tracked (via
// their `vertices` field), and are trivial to
// handle anyway. Faces would need equivalent
// tracking as well.
//
// Face approximation logic could then easily
// generate the fake edge required to make the
// triangulation work. The existing infrastructure
// to convert surface points back to 3D points
// would neatly make sure that anything that's
// supposed to be connected in 3D ends up being
// connected.
cycles: vec![
edges::Cycle { edges: vec![edge] },
edges::Cycle {
edges: vec![top_edge],
},
],
},
};

side_faces.push(Face::Face { edges, surface });
}
}

// This will only work correctly, if the original shape consists of one
// edge. If there are more, this will create some kind of weird face
Expand Down

0 comments on commit d311a2e

Please sign in to comment.