-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add handling of z values for xy-duplicates
- Loading branch information
1 parent
f98d669
commit 5e9f626
Showing
2 changed files
with
91 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::startin::Triangulation; | ||
|
||
use startin; | ||
|
||
fn five_points() -> Triangulation { | ||
let mut pts: Vec<[f64; 3]> = Vec::new(); | ||
pts.push([0.0, 0.0, 1.0]); | ||
pts.push([10.0, 0.0, 2.0]); | ||
pts.push([10.0, 10.0, 3.0]); | ||
pts.push([0.0, 10.0, 4.0]); | ||
pts.push([5.0, 5.0, 10.0]); | ||
let mut dt = startin::Triangulation::new(); | ||
dt.insert(&pts, startin::InsertionStrategy::AsIs); | ||
dt | ||
} | ||
|
||
#[test] | ||
fn duplicate_alltests() { | ||
let mut dt = five_points(); | ||
|
||
dt.set_duplicates_handling(startin::DuplicateHandling::First); | ||
let re = dt.insert_one_pt(5.0, 5.0, 20.0); | ||
assert_eq!(Err(5), re); | ||
match re { | ||
Ok(_) => (), | ||
Err(i) => assert_eq!(dt.get_point(i).unwrap()[2], 10.0), | ||
} | ||
|
||
dt.set_duplicates_handling(startin::DuplicateHandling::Last); | ||
let re = dt.insert_one_pt(5.0, 5.0, 20.0); | ||
assert_eq!(Err(5), re); | ||
match re { | ||
Ok(_) => (), | ||
Err(i) => assert_eq!(dt.get_point(i).unwrap()[2], 20.0), | ||
} | ||
|
||
dt.set_duplicates_handling(startin::DuplicateHandling::Highest); | ||
let re = dt.insert_one_pt(5.0, 5.0, 20.0); | ||
assert_eq!(Err(5), re); | ||
match re { | ||
Ok(_) => (), | ||
Err(i) => assert_eq!(dt.get_point(i).unwrap()[2], 20.0), | ||
} | ||
|
||
dt.set_duplicates_handling(startin::DuplicateHandling::Lowest); | ||
let re = dt.insert_one_pt(5.0, 5.0, 5.0); | ||
assert_eq!(Err(5), re); | ||
match re { | ||
Ok(_) => (), | ||
Err(i) => assert_eq!(dt.get_point(i).unwrap()[2], 5.0), | ||
} | ||
} |