-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2042 from hannobraun/approx
Keep boundary and points separately in `CurveApprox`
- Loading branch information
Showing
5 changed files
with
98 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use fj_math::Point; | ||
|
||
use crate::{algorithms::approx::ApproxPoint, geometry::CurveBoundary}; | ||
|
||
/// Points of a curve approximation | ||
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, Ord, PartialOrd)] | ||
pub struct CurveApproxPoints { | ||
/// Points of a curve approximation | ||
pub inner: Vec<ApproxPoint<1>>, | ||
} | ||
|
||
impl CurveApproxPoints { | ||
/// Indicate whether there are any points | ||
pub fn is_empty(&self) -> bool { | ||
self.inner.is_empty() | ||
} | ||
|
||
/// Reverse the orientation of the approximation | ||
pub fn reverse(&mut self) -> &mut Self { | ||
self.inner.reverse(); | ||
self | ||
} | ||
|
||
/// Reduce the approximation to the subset defined by the provided boundary | ||
pub fn make_subset(&mut self, boundary: CurveBoundary<Point<1>>) { | ||
self.inner | ||
.retain(|point| boundary.contains(point.local_form)); | ||
} | ||
|
||
/// Merge the provided points | ||
/// | ||
/// If there is a true overlap between these points and the other points | ||
/// then the overlapping part is taken from the other points. | ||
pub fn merge( | ||
&mut self, | ||
other: &Self, | ||
other_boundary: CurveBoundary<Point<1>>, | ||
) { | ||
self.inner.retain(|point| { | ||
// Only retain points that don't overlap with the other points, or | ||
// we might end up with duplicates. | ||
!other_boundary.contains(point.local_form) | ||
}); | ||
self.inner.extend(&other.inner); | ||
self.inner.sort(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters