Skip to content

Commit

Permalink
Return 3D points in Approx
Browse files Browse the repository at this point in the history
This follows the insights gained in #78. Please check the discussion
there for details.
  • Loading branch information
hannobraun committed Feb 4, 2022
1 parent 034da34 commit 61c7604
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
10 changes: 1 addition & 9 deletions src/kernel/topology/edges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ impl Edges {
let mut segments = Vec::new();
self.approx_segments(tolerance, &mut segments);

let vertices = vertices
.into_iter()
.map(|vertex| {
// Can't panic, unless the approximation wrongfully generates
// points that are not in the surface.
surface.point_model_to_surface(vertex).unwrap()
})
.collect();
let segments = segments
.into_iter()
.map(|Segment3 { a, b }| {
Expand Down Expand Up @@ -263,6 +255,6 @@ impl Edge {

/// An approximation of one or more edges
pub struct Approx {
pub vertices: Vec<Point<2>>,
pub vertices: Vec<Point<3>>,
pub segments: Vec<Segment2>,
}
15 changes: 13 additions & 2 deletions src/kernel/topology/faces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,22 @@ impl Face {
match self {
Self::Face { edges, surface } => {
let approx = edges.approx(tolerance, surface);
let mut triangles = triangulate(&approx.vertices);

let vertices: Vec<_> = approx
.vertices
.into_iter()
.map(|vertex| {
// Can't panic, unless the approximation wrongfully
// generates points that are not in the surface.
surface.point_model_to_surface(vertex).unwrap()
})
.collect();

let mut triangles = triangulate(&vertices);
let face_as_polygon = approx.segments;

// We're also going to need a point outside of the polygon.
let aabb = AABB::from_points(&approx.vertices);
let aabb = AABB::from_points(&vertices);
let outside = aabb.maxs * 2.;

triangles.retain(|triangle| {
Expand Down

0 comments on commit 61c7604

Please sign in to comment.