1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
use crate::errors::Error;
use crate::wire::EdgeIter;
use crate::*;
use rustc_hash::FxHashMap as HashMap;
impl<P, C, S> Face<P, C, S> {
/// Creates a new face by a wire.
/// # Failure
/// All wires in `boundaries` must be non-empty, simple and closed. If not, returns the following errors:
/// * If a wire is empty, then returns [`Error::EmptyWire`].
/// * If a wire is not closed, then returns [`Error::NotClosedWire`].
/// * If a wire is closed but not simple, then returns [`Error::NotSimpleWire`].
///
/// [`Error::EmptyWire`]: errors/enum.Error.html#variant.EmptyWire
/// [`Error::NotClosedWire`]: errors/enum.Error.html#variant.NotClosedWire
/// [`Error::NotSimpleWire`]: errors/enum.Error.html#variant.NotSimpleWire
/// # Examples
/// ```
/// # use truck_topology::*;
/// # use errors::Error;
/// let v = Vertex::news(&[(); 4]);
/// let mut wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[3], ()),
/// Edge::new(&v[3], &v[0], ()),
/// ]);
/// assert!(Face::try_new(vec![wire], ()).is_ok());
/// ```
#[inline(always)]
pub fn try_new(boundaries: Vec<Wire<P, C>>, surface: S) -> Result<Face<P, C, S>> {
for wire in &boundaries {
if wire.is_empty() {
return Err(Error::EmptyWire);
} else if !wire.is_closed() {
return Err(Error::NotClosedWire);
} else if !wire.is_simple() {
return Err(Error::NotSimpleWire);
}
}
if !Wire::disjoint_wires(&boundaries) {
Err(Error::NotSimpleWire)
} else {
Ok(Face::new_unchecked(boundaries, surface))
}
}
/// Creates a new face by a wire.
/// # Panic
/// All wires in `boundaries` must be non-empty, simple and closed.
#[inline(always)]
pub fn new(boundaries: Vec<Wire<P, C>>, surface: S) -> Face<P, C, S> {
Face::try_new(boundaries, surface).remove_try()
}
/// Creates a new face by a wire.
/// # Remarks
/// This method is prepared only for performance-critical development and is not recommended.
/// This method does NOT check the regularity conditions of `Face::try_new()`.
/// The programmer must guarantee this condition before using this method.
#[inline(always)]
pub fn new_unchecked(boundaries: Vec<Wire<P, C>>, surface: S) -> Face<P, C, S> {
Face {
boundaries,
orientation: true,
surface: Arc::new(Mutex::new(surface)),
}
}
/// Creates a new face by a wire.
/// # Remarks
/// This method check the regularity conditions of `Face::try_new()` in the debug mode.
/// The programmer must guarantee this condition before using this method.
#[inline(always)]
pub fn debug_new(boundaries: Vec<Wire<P, C>>, surface: S) -> Face<P, C, S> {
match cfg!(debug_assertions) {
true => Face::new(boundaries, surface),
false => Face::new_unchecked(boundaries, surface),
}
}
/// Returns the boundaries of the face.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(); 3]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let mut face = Face::new(vec![wire], ());
/// let boundaries = face.boundaries();
/// for (i, vert) in boundaries[0].vertex_iter().enumerate() {
/// assert_eq!(vert, v[i]);
/// }
///
/// // If invert the face, the boundaries is also inverted.
/// face.invert();
/// assert_eq!(boundaries[0].inverse(), face.boundaries()[0]);
/// ```
#[inline(always)]
pub fn boundaries(&self) -> Vec<Wire<P, C>> {
match self.orientation {
true => self.boundaries.clone(),
false => self.boundaries.iter().map(|wire| wire.inverse()).collect(),
}
}
/// Consumes `self` and returns the entity of its boundaries.
/// ```
/// # use truck_topology::*;
/// let v = Vertex::news(&[(), (), ()]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let mut face = Face::new(vec![wire], ());
/// let boundaries = face.clone().into_boundaries();
/// for (i, vert) in boundaries[0].vertex_iter().enumerate() {
/// assert_eq!(vert, v[i]);
/// }
///
/// // If invert the face, the boundaries is also inverted.
/// face.invert();
/// assert_eq!(boundaries[0].inverse(), face.into_boundaries()[0]);
/// ```
#[inline(always)]
pub fn into_boundaries(self) -> Vec<Wire<P, C>> {
match self.orientation {
true => self.boundaries,
false => self.boundaries(),
}
}
/// Returns the reference of the boundaries wire which is generated by constructor.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), ()]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let mut face = Face::new(vec![wire], ());
/// let boundaries = face.boundaries();
/// face.invert();
///
/// // The result of face.boundary() is already inversed.
/// assert_eq!(face.boundaries()[0], boundaries[0].inverse());
///
/// // The absolute boundaries does never change.
/// assert_eq!(face.absolute_boundaries(), &boundaries);
/// ```
#[inline(always)]
pub const fn absolute_boundaries(&self) -> &Vec<Wire<P, C>> { &self.boundaries }
/// Returns a clone of the face without inversion.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), ()]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let face0 = Face::new(vec![wire], ());
/// let face1 = face0.inverse();
/// let face2 = face1.absolute_clone();
/// assert_eq!(face0, face2);
/// assert_ne!(face1, face2);
/// assert!(face1.is_same(&face2));
/// ```
#[inline(always)]
pub fn absolute_clone(&self) -> Self {
Self {
boundaries: self.boundaries.clone(),
surface: Arc::clone(&self.surface),
orientation: true,
}
}
/// Returns an iterator over all edges in the boundaries.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), ()]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let mut face = Face::new(vec![wire], ());
/// face.invert();
/// let boundaries = face.boundaries().clone();
/// let edge_iter0 = boundaries.iter().flat_map(Wire::edge_iter);
/// let edge_iter1 = face.boundary_iters().into_iter().flatten();
/// for (edge0, edge1) in edge_iter0.zip(edge_iter1) {
/// assert_eq!(edge0, &edge1);
/// }
/// ```
#[inline(always)]
pub fn boundary_iters(&self) -> Vec<BoundaryIter<'_, P, C>> {
self.boundaries
.iter()
.map(|wire| BoundaryIter {
edge_iter: wire.edge_iter(),
orientation: self.orientation,
})
.collect()
}
#[inline(always)]
fn renew_pointer(&mut self)
where S: Clone {
let surface = self.get_surface();
self.surface = Arc::new(Mutex::new(surface));
}
/// Returns an iterator over the edges.
#[inline(always)]
pub fn edge_iter(&self) -> impl Iterator<Item = Edge<P, C>> + '_ {
self.boundary_iters().into_iter().flatten()
}
/// Returns an iterator over the vertices.
#[inline(always)]
pub fn vertex_iter(&self) -> impl Iterator<Item = Vertex<P>> + '_ {
self.edge_iter().map(|e| e.front().clone())
}
/// Adds a boundary to the face.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), (), (), (), ()]);
/// let wire0 = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let wire1 = Wire::from(vec![
/// Edge::new(&v[3], &v[4], ()),
/// Edge::new(&v[4], &v[5], ()),
/// Edge::new(&v[5], &v[3], ()),
/// ]);
/// let mut face0 = Face::new(vec![wire0.clone()], ());
/// face0.try_add_boundary(wire1.clone()).unwrap();
/// let face1 = Face::new(vec![wire0, wire1], ());
/// assert_eq!(face0.boundaries(), face1.boundaries());
/// ```
/// # Remarks
/// 1. If the face is inverted, then the added wire is inverted as absolute boundary.
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), (), (), (), ()]);
/// let wire0 = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let wire1 = Wire::from(vec![
/// Edge::new(&v[3], &v[4], ()),
/// Edge::new(&v[5], &v[4], ()).inverse(),
/// Edge::new(&v[5], &v[3], ()),
/// ]);
/// let mut face = Face::new(vec![wire0], ());
/// face.invert();
/// face.try_add_boundary(wire1.clone()).unwrap();
///
/// // The boundary is added in compatible with the face orientation.
/// assert_eq!(face.boundaries()[1], wire1);
///
/// // The absolute boundary is inverted!
/// let iter0 = face.absolute_boundaries()[1].edge_iter();
/// let iter1 = wire1.edge_iter().rev();
/// for (edge0, edge1) in iter0.zip(iter1) {
/// assert_eq!(edge0.id(), edge1.id());
/// assert_eq!(edge0.orientation(), !edge1.orientation());
/// }
/// ```
/// 2. This method renew the face id.
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), (), (), (), ()]);
/// let wire0 = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let wire1 = Wire::from(vec![
/// Edge::new(&v[3], &v[4], ()),
/// Edge::new(&v[5], &v[4], ()).inverse(),
/// Edge::new(&v[5], &v[3], ()),
/// ]);
/// let mut face0 = Face::new(vec![wire0], ());
/// let face1 = face0.clone();
/// assert_eq!(face0.id(), face1.id());
/// face0.try_add_boundary(wire1).unwrap();
/// assert_ne!(face0.id(), face1.id());
/// ```
#[inline(always)]
pub fn try_add_boundary(&mut self, mut wire: Wire<P, C>) -> Result<()>
where S: Clone {
if wire.is_empty() {
return Err(Error::EmptyWire);
} else if !wire.is_closed() {
return Err(Error::NotClosedWire);
} else if !wire.is_simple() {
return Err(Error::NotSimpleWire);
}
if !self.orientation {
wire.invert();
}
self.boundaries.push(wire);
self.renew_pointer();
if !Wire::disjoint_wires(&self.boundaries) {
self.boundaries.pop();
return Err(Error::NotDisjointWires);
}
Ok(())
}
/// Adds a boundary to the face.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), (), (), (), ()]);
/// let wire0 = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let wire1 = Wire::from(vec![
/// Edge::new(&v[3], &v[4], ()),
/// Edge::new(&v[4], &v[5], ()),
/// Edge::new(&v[5], &v[3], ()),
/// ]);
/// let mut face0 = Face::new(vec![wire0.clone()], ());
/// face0.add_boundary(wire1.clone());
/// let face1 = Face::new(vec![wire0, wire1], ());
/// assert_eq!(face0.boundaries(), face1.boundaries());
/// ```
/// # Remarks
/// 1. If the face is inverted, then the added wire is inverted as absolute boundary.
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), (), (), (), ()]);
/// let wire0 = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let wire1 = Wire::from(vec![
/// Edge::new(&v[3], &v[4], ()),
/// Edge::new(&v[5], &v[4], ()).inverse(),
/// Edge::new(&v[5], &v[3], ()),
/// ]);
/// let mut face = Face::new(vec![wire0], ());
/// face.invert();
/// face.add_boundary(wire1.clone());
///
/// // The boundary is added in compatible with the face orientation.
/// assert_eq!(face.boundaries()[1], wire1);
///
/// // The absolute boundary is inverted!
/// let iter0 = face.absolute_boundaries()[1].edge_iter();
/// let iter1 = wire1.edge_iter().rev();
/// for (edge0, edge1) in iter0.zip(iter1) {
/// assert_eq!(edge0.id(), edge1.id());
/// assert_eq!(edge0.orientation(), !edge1.orientation());
/// }
/// ```
/// 2. This method renew the face id.
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), (), (), (), ()]);
/// let wire0 = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let wire1 = Wire::from(vec![
/// Edge::new(&v[3], &v[4], ()),
/// Edge::new(&v[5], &v[4], ()).inverse(),
/// Edge::new(&v[5], &v[3], ()),
/// ]);
/// let mut face0 = Face::new(vec![wire0], ());
/// let face1 = face0.clone();
/// assert_eq!(face0.id(), face1.id());
/// face0.add_boundary(wire1);
/// assert_ne!(face0.id(), face1.id());
/// ```
#[inline(always)]
pub fn add_boundary(&mut self, wire: Wire<P, C>)
where S: Clone {
self.try_add_boundary(wire).remove_try()
}
/// Returns a new face whose surface is mapped by `surface_mapping`,
/// curves are mapped by `curve_mapping` and points are mapped by `point_mapping`.
/// # Remarks
/// Accessing geometry elements directly in the closure will result in a deadlock.
/// So, this method does not appear to the document.
#[doc(hidden)]
pub fn try_mapped<Q, D, T>(
&self,
mut point_mapping: impl FnMut(&P) -> Option<Q>,
mut curve_mapping: impl FnMut(&C) -> Option<D>,
mut surface_mapping: impl FnMut(&S) -> Option<T>,
) -> Option<Face<Q, D, T>> {
let wires = self
.absolute_boundaries()
.iter()
.map(|wire| wire.try_mapped(&mut point_mapping, &mut curve_mapping))
.collect::<Option<Vec<_>>>()?;
let surface = surface_mapping(&*self.surface.lock().unwrap())?;
let mut face = Face::debug_new(wires, surface);
if !self.orientation() {
face.invert();
}
Some(face)
}
/// Returns a new face whose surface is mapped by `surface_mapping`,
/// curves are mapped by `curve_mapping` and points are mapped by `point_mapping`.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[0, 1, 2, 3, 4, 5, 6]);
/// let wire0 = Wire::from(vec![
/// Edge::new(&v[0], &v[1], 100),
/// Edge::new(&v[1], &v[2], 200),
/// Edge::new(&v[2], &v[3], 300),
/// Edge::new(&v[3], &v[0], 400),
/// ]);
/// let wire1 = Wire::from(vec![
/// Edge::new(&v[4], &v[5], 500),
/// Edge::new(&v[6], &v[5], 600).inverse(),
/// Edge::new(&v[6], &v[4], 700),
/// ]);
/// let face0 = Face::new(vec![wire0, wire1], 10000);
/// let face1 = face0.mapped(
/// &move |i: &usize| *i + 10,
/// &move |j: &usize| *j + 1000,
/// &move |k: &usize| *k + 100000,
/// );
/// # for wire in face1.boundaries() {
/// # assert!(wire.is_closed());
/// # assert!(wire.is_simple());
/// # }
///
/// assert_eq!(
/// face0.get_surface() + 100000,
/// face1.get_surface(),
/// );
/// let biters0 = face0.boundary_iters();
/// let biters1 = face1.boundary_iters();
/// for (biter0, biter1) in biters0.into_iter().zip(biters1) {
/// for (edge0, edge1) in biter0.zip(biter1) {
/// assert_eq!(
/// edge0.front().get_point() + 10,
/// edge1.front().get_point(),
/// );
/// assert_eq!(
/// edge0.back().get_point() + 10,
/// edge1.back().get_point(),
/// );
/// assert_eq!(edge0.orientation(), edge1.orientation());
/// assert_eq!(
/// edge0.get_curve() + 1000,
/// edge1.get_curve(),
/// );
/// }
/// }
/// ```
/// # Remarks
/// Accessing geometry elements directly in the closure will result in a deadlock.
/// So, this method does not appear to the document.
#[doc(hidden)]
pub fn mapped<Q, D, T>(
&self,
mut point_mapping: impl FnMut(&P) -> Q,
mut curve_mapping: impl FnMut(&C) -> D,
mut surface_mapping: impl FnMut(&S) -> T,
) -> Face<Q, D, T> {
let wires: Vec<_> = self
.absolute_boundaries()
.iter()
.map(|wire| wire.mapped(&mut point_mapping, &mut curve_mapping))
.collect();
let surface = surface_mapping(&*self.surface.lock().unwrap());
let mut face = Face::debug_new(wires, surface);
if !self.orientation() {
face.invert();
}
face
}
/// Returns the orientation of face.
///
/// The result of this method is the same with `self.boundaries() == self.absolute_boundaries().clone()`.
/// Moreover, if this method returns false, `self.boundaries() == self.absolute_boundaries().inverse()`.
#[inline(always)]
pub fn orientation(&self) -> bool { self.orientation }
/// Returns the clone of surface of face.
#[inline(always)]
pub fn get_surface(&self) -> S
where S: Clone {
self.surface.lock().unwrap().clone()
}
/// Sets the surface of face.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), ()]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let face0 = Face::new(vec![wire], 0);
/// let face1 = face0.clone();
///
/// // Two faces have the same content.
/// assert_eq!(face0.get_surface(), 0);
/// assert_eq!(face1.get_surface(), 0);
///
/// // Set surface
/// face0.set_surface(1);
///
/// // The contents of two vertices are synchronized.
/// assert_eq!(face0.get_surface(), 1);
/// assert_eq!(face1.get_surface(), 1);
/// ```
#[inline(always)]
pub fn set_surface(&self, surface: S) { *self.surface.lock().unwrap() = surface; }
/// Inverts the direction of the face.
/// # Examples
/// ```
/// use truck_topology::*;
/// use truck_topology::errors::Error;
/// let v = Vertex::news(&[(), (), ()]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let mut face = Face::new(vec![wire], ());
/// let org_face = face.clone();
/// let org_bdry = face.boundaries();
/// face.invert();
///
/// // Two faces are the same face.
/// face.is_same(&org_face);
///
/// // The boundaries is inverted.
/// let inversed_edge_iter = org_bdry[0].inverse().edge_into_iter();
/// let face_edge_iter = &mut face.boundary_iters()[0];
/// for (edge0, edge1) in inversed_edge_iter.zip(face_edge_iter) {
/// assert_eq!(edge0, edge1);
/// }
/// ```
#[inline(always)]
pub fn invert(&mut self) -> &mut Self {
self.orientation = !self.orientation;
self
}
/// Returns whether two faces are the same. Returns `true` even if the orientaions are different.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(); 3]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let face0 = Face::new(vec![wire], ());
/// let face1 = face0.inverse();
/// assert_ne!(face0, face1);
/// assert!(face0.is_same(&face1));
/// ```
#[inline(always)]
pub fn is_same(&self, other: &Self) -> bool {
std::ptr::eq(Arc::as_ptr(&self.surface), Arc::as_ptr(&other.surface))
}
/// Returns the id that does not depend on the direction of the face.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(); 3]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let face0 = Face::new(vec![wire.clone()], ());
/// let face1 = face0.inverse();
/// let face2 = Face::new(vec![wire], ());
/// assert_ne!(face0, face1);
/// assert_ne!(face0, face2);
/// assert_eq!(face0.id(), face1.id());
/// assert_ne!(face0.id(), face2.id());
/// ```
#[inline(always)]
pub fn id(&self) -> FaceID<S> { ID::new(Arc::as_ptr(&self.surface)) }
/// Returns how many same faces.
///
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(); 3]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
///
/// // Create one face
/// let face0 = Face::new(vec![wire.clone()], ());
/// assert_eq!(face0.count(), 1);
/// // Create another face, independent from face0
/// let face1 = Face::new(vec![wire.clone()], ());
/// assert_eq!(face0.count(), 1);
/// // Clone face0, the result will be 2.
/// let face2 = face0.clone();
/// assert_eq!(face0.count(), 2);
/// assert_eq!(face2.count(), 2);
/// // drop face2, the result will be 1.
/// drop(face2);
/// assert_eq!(face0.count(), 1);
/// ```
#[inline(always)]
pub fn count(&self) -> usize { Arc::strong_count(&self.surface) }
/// Returns the inverse face.
/// # Examples
/// ```
/// use truck_topology::*;
/// use truck_topology::errors::Error;
/// let v = Vertex::news(&[(), (), ()]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let mut face = Face::new(vec![wire], ());
/// let inverted = face.inverse();
///
/// // Two faces are the same face.
/// assert!(face.is_same(&inverted));
///
/// // Two faces has the same id.
/// assert_eq!(face.id(), inverted.id());
///
/// // The boundaries is inverted.
/// let mut inversed_edge_iter = face.boundaries()[0].inverse().edge_into_iter();
/// let face_edge_iter = &mut inverted.boundary_iters()[0];
/// for (edge0, edge1) in inversed_edge_iter.zip(face_edge_iter) {
/// assert_eq!(edge0, edge1);
/// }
/// ```
#[inline(always)]
pub fn inverse(&self) -> Face<P, C, S> {
let mut face = self.clone();
face.invert();
face
}
/// Returns whether two faces `self` and `other` have a shared edge.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(); 4]);
/// let shared_edge = Edge::new(&v[0], &v[1], ());
/// let another_edge = Edge::new(&v[0], &v[1], ());
/// let inversed_edge = shared_edge.inverse();
/// let wire = vec![
/// Wire::from_iter(vec![&Edge::new(&v[2], &v[0], ()), &shared_edge, &Edge::new(&v[1], &v[2], ())]),
/// Wire::from_iter(vec![&Edge::new(&v[2], &v[0], ()), &another_edge, &Edge::new(&v[1], &v[2], ())]),
/// Wire::from_iter(vec![&Edge::new(&v[3], &v[0], ()), &shared_edge, &Edge::new(&v[1], &v[3], ())]),
/// Wire::from_iter(vec![&Edge::new(&v[3], &v[1], ()), &inversed_edge, &Edge::new(&v[0], &v[3], ())]),
/// ];
/// let face: Vec<_> = wire.into_iter().map(|w| Face::new(vec![w], ())).collect();
/// assert!(face[0].border_on(&face[2]));
/// assert!(!face[1].border_on(&face[2]));
/// assert!(face[0].border_on(&face[3]));
/// ```
pub fn border_on(&self, other: &Face<P, C, S>) -> bool {
let mut hashmap = HashMap::default();
let edge_iter = self.boundary_iters().into_iter().flatten();
edge_iter.for_each(|edge| {
hashmap.insert(edge.id(), edge);
});
let mut edge_iter = other.boundary_iters().into_iter().flatten();
edge_iter.any(|edge| hashmap.insert(edge.id(), edge).is_some())
}
/// Cuts a face with only one boundary by an edge.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), (), ()]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[3], ()),
/// Edge::new(&v[3], &v[0], ()),
/// ]);
/// let face = Face::new(vec![wire], ());
/// let (face0, face1) = face.cut_by_edge(Edge::new(&v[1], &v[3], ())).unwrap();
///
/// // The front vertex of face0's boundary becomes the back of cutting edge.
/// let v0: Vec<Vertex<()>> = face0.boundaries()[0].vertex_iter().collect();
/// assert_eq!(v0, vec![v[3].clone(), v[0].clone(), v[1].clone()]);
///
/// let v1: Vec<Vertex<()>> = face1.boundaries()[0].vertex_iter().collect();
/// assert_eq!(v1, vec![v[1].clone(), v[2].clone(), v[3].clone()]);
/// ```
/// # Failures
/// Returns `None` if:
/// - `self` has several boundaries, or
/// - `self` does not include vertices of the end vertices of `edge`.
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(); 6]);
/// let wire0 = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// ]);
/// let wire1 = Wire::from(vec![
/// Edge::new(&v[3], &v[4], ()),
/// Edge::new(&v[4], &v[5], ()),
/// Edge::new(&v[5], &v[3], ()),
/// ]);
/// let face = Face::new(vec![wire0, wire1], ());
/// assert!(face.cut_by_edge(Edge::new(&v[1], &v[2], ())).is_none());
/// ```
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(), (), (), (), ()]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[3], ()),
/// Edge::new(&v[3], &v[0], ()),
/// ]);
/// let face = Face::new(vec![wire], ());
/// assert!(face.cut_by_edge(Edge::new(&v[1], &v[4], ())).is_none());
pub fn cut_by_edge(&self, edge: Edge<P, C>) -> Option<(Self, Self)>
where S: Clone {
if self.boundaries.len() != 1 {
return None;
}
let mut face0 = Face {
boundaries: self.boundaries.clone(),
orientation: self.orientation,
surface: Arc::new(Mutex::new(self.get_surface())),
};
let wire = &mut face0.boundaries[0];
let i = wire
.edge_iter()
.enumerate()
.find(|(_, e)| e.front() == edge.back())
.map(|(i, _)| i)?;
let j = wire
.edge_iter()
.enumerate()
.find(|(_, e)| e.back() == edge.front())
.map(|(i, _)| i)?;
wire.rotate_left(i);
let j = (j + wire.len() - i) % wire.len();
let mut new_wire = wire.split_off(j + 1);
wire.push_back(edge.clone());
new_wire.push_back(edge.inverse());
debug_assert!(Face::try_new(self.boundaries.clone(), ()).is_ok());
debug_assert!(Face::try_new(vec![new_wire.clone()], ()).is_ok());
let face1 = Face {
boundaries: vec![new_wire],
orientation: self.orientation,
surface: Arc::new(Mutex::new(self.get_surface())),
};
Some((face0, face1))
}
/// Glue two faces at boundaries.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(); 8]);
/// let edge = vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// Edge::new(&v[3], &v[4], ()),
/// Edge::new(&v[4], &v[5], ()),
/// Edge::new(&v[5], &v[3], ()),
/// Edge::new(&v[6], &v[2], ()),
/// Edge::new(&v[1], &v[6], ()),
/// Edge::new(&v[7], &v[5], ()),
/// Edge::new(&v[4], &v[7], ()),
/// ];
/// let wire0 = Wire::from(vec![
/// edge[0].clone(),
/// edge[1].clone(),
/// edge[2].clone(),
/// ]);
/// let wire1 = Wire::from(vec![
/// edge[3].clone(),
/// edge[4].clone(),
/// edge[5].clone(),
/// ]);
/// let wire2 = Wire::from(vec![
/// edge[6].clone(),
/// edge[1].inverse(),
/// edge[7].clone(),
/// ]);
/// let wire3 = Wire::from(vec![
/// edge[8].clone(),
/// edge[4].inverse(),
/// edge[9].clone(),
/// ]);
/// let face0 = Face::new(vec![wire0, wire1], ());
/// let face1 = Face::new(vec![wire2, wire3], ());
/// let face = face0.glue_at_boundaries(&face1).unwrap();
/// let boundaries = face.boundary_iters();
/// assert_eq!(boundaries.len(), 2);
/// assert_eq!(boundaries[0].len(), 4);
/// assert_eq!(boundaries[1].len(), 4);
/// ```
pub fn glue_at_boundaries(&self, other: &Self) -> Option<Self>
where
S: Clone + PartialEq,
Wire<P, C>: Debug, {
let surface = self.get_surface();
if surface != other.get_surface() || self.orientation() != other.orientation() {
return None;
}
let mut vemap: HashMap<VertexID<P>, &Edge<P, C>> = self
.absolute_boundaries()
.iter()
.flatten()
.map(|edge| (edge.front().id(), edge))
.collect();
other
.absolute_boundaries()
.iter()
.flatten()
.try_for_each(|edge| {
if let Some(edge0) = vemap.get(&edge.back().id()) {
if edge.front() == edge0.back() {
if edge.is_same(edge0) {
vemap.remove(&edge.back().id());
return Some(());
} else {
return None;
}
}
}
vemap.insert(edge.front().id(), edge);
Some(())
})?;
if vemap.is_empty() {
return None;
}
let mut boundaries = Vec::new();
while !vemap.is_empty() {
let mut wire = Wire::new();
let v = *vemap.iter().next().unwrap().0;
let mut edge = vemap.remove(&v).unwrap();
wire.push_back(edge.clone());
while let Some(edge0) = vemap.remove(&edge.back().id()) {
wire.push_back(edge0.clone());
edge = edge0;
}
boundaries.push(wire);
}
debug_assert!(Face::try_new(boundaries.clone(), ()).is_ok());
Some(Face {
boundaries,
orientation: self.orientation(),
surface: Arc::new(Mutex::new(surface)),
})
}
/// Creates display struct for debugging the face.
///
/// # Examples
/// ```
/// use truck_topology::*;
/// use FaceDisplayFormat as FDF;
/// let v = Vertex::news(&[0, 1, 2, 3, 4, 5]);
/// let edge = vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[0], ()),
/// Edge::new(&v[3], &v[4], ()),
/// Edge::new(&v[4], &v[5], ()),
/// Edge::new(&v[5], &v[3], ()),
/// ];
/// let wire0 = Wire::from(vec![
/// edge[0].clone(),
/// edge[1].clone(),
/// edge[2].clone(),
/// ]);
/// let wire1 = Wire::from(vec![
/// edge[3].clone(),
/// edge[4].clone(),
/// edge[5].clone(),
/// ]);
/// let face = Face::new(vec![wire0, wire1], 120);
///
/// let vertex_format = VertexDisplayFormat::AsPoint;
/// let edge_format = EdgeDisplayFormat::VerticesTuple { vertex_format };
/// let wire_format = WireDisplayFormat::EdgesList { edge_format };
///
/// assert_eq!(
/// format!("{:?}", face.display(FDF::Full { wire_format })),
/// format!("Face {{ id: {:?}, boundaries: [[(0, 1), (1, 2), (2, 0)], [(3, 4), (4, 5), (5, 3)]], entity: 120 }}", face.id()),
/// );
/// assert_eq!(
/// format!("{:?}", face.display(FDF::BoundariesAndID { wire_format })),
/// format!("Face {{ id: {:?}, boundaries: [[(0, 1), (1, 2), (2, 0)], [(3, 4), (4, 5), (5, 3)]] }}", face.id()),
/// );
/// assert_eq!(
/// &format!("{:?}", face.display(FDF::BoundariesAndSurface { wire_format })),
/// "Face { boundaries: [[(0, 1), (1, 2), (2, 0)], [(3, 4), (4, 5), (5, 3)]], entity: 120 }",
/// );
/// assert_eq!(
/// &format!("{:?}", face.display(FDF::LoopsListTuple { wire_format })),
/// "Face([[(0, 1), (1, 2), (2, 0)], [(3, 4), (4, 5), (5, 3)]])",
/// );
/// assert_eq!(
/// &format!("{:?}", face.display(FDF::LoopsList { wire_format })),
/// "[[(0, 1), (1, 2), (2, 0)], [(3, 4), (4, 5), (5, 3)]]",
/// );
/// assert_eq!(
/// &format!("{:?}", face.display(FDF::AsSurface)),
/// "120",
/// );
/// ```
#[inline(always)]
pub fn display(&self, format: FaceDisplayFormat) -> DebugDisplay<'_, Self, FaceDisplayFormat> {
DebugDisplay {
entity: self,
format,
}
}
}
impl<P, C, S: Clone + Invertible> Face<P, C, S> {
/// Returns the cloned surface in face.
/// If face is inverted, then the returned surface is also inverted.
#[inline(always)]
pub fn oriented_surface(&self) -> S {
match self.orientation {
true => self.surface.lock().unwrap().clone(),
false => self.surface.lock().unwrap().inverse(),
}
}
}
impl<P, C, S> Face<P, C, S>
where
P: Tolerance,
C: BoundedCurve<Point = P>,
S: IncludeCurve<C>,
{
/// Returns the consistence of the geometry of end vertices
/// and the geometry of edge.
#[inline(always)]
pub fn is_geometric_consistent(&self) -> bool {
let surface = &*self.surface.lock().unwrap();
self.boundary_iters().into_iter().flatten().all(|edge| {
let edge_consist = edge.is_geometric_consistent();
let curve = &*edge.curve.lock().unwrap();
let curve_consist = surface.include(curve);
edge_consist && curve_consist
})
}
}
impl<P, C, S> Clone for Face<P, C, S> {
#[inline(always)]
fn clone(&self) -> Face<P, C, S> {
Face {
boundaries: self.boundaries.clone(),
orientation: self.orientation,
surface: Arc::clone(&self.surface),
}
}
}
impl<P, C, S> PartialEq for Face<P, C, S> {
#[inline(always)]
fn eq(&self, other: &Self) -> bool {
std::ptr::eq(Arc::as_ptr(&self.surface), Arc::as_ptr(&other.surface))
&& self.orientation == other.orientation
}
}
impl<P, C, S> Eq for Face<P, C, S> {}
impl<P, C, S> Hash for Face<P, C, S> {
#[inline(always)]
fn hash<H: Hasher>(&self, state: &mut H) {
std::ptr::hash(Arc::as_ptr(&self.surface), state);
self.orientation.hash(state);
}
}
/// An iterator over the edges in the boundaries of a face.
/// # Examples
/// ```
/// use truck_topology::*;
/// let v = Vertex::news(&[(); 4]);
/// let wire = Wire::from(vec![
/// Edge::new(&v[0], &v[1], ()),
/// Edge::new(&v[1], &v[2], ()),
/// Edge::new(&v[2], &v[3], ()),
/// Edge::new(&v[3], &v[0], ()),
/// ]);
/// let face = Face::new(vec![wire.clone()], ());
///
/// let iter = &mut face.boundary_iters()[0];
/// assert_eq!(iter.next().as_ref(), Some(&wire[0]));
/// assert_eq!(iter.next_back().as_ref(), Some(&wire[3])); // double ended
/// assert_eq!(iter.next().as_ref(), Some(&wire[1]));
/// assert_eq!(iter.next().as_ref(), Some(&wire[2]));
/// assert_eq!(iter.next_back().as_ref(), None);
/// assert_eq!(iter.next().as_ref(), None); // fused
/// ```
#[derive(Clone, Debug)]
pub struct BoundaryIter<'a, P, C> {
edge_iter: EdgeIter<'a, P, C>,
orientation: bool,
}
impl<'a, P, C> Iterator for BoundaryIter<'a, P, C> {
type Item = Edge<P, C>;
#[inline(always)]
fn next(&mut self) -> Option<Edge<P, C>> {
match self.orientation {
true => self.edge_iter.next().cloned(),
false => self.edge_iter.next_back().map(|edge| edge.inverse()),
}
}
#[inline(always)]
fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
#[inline(always)]
fn last(mut self) -> Option<Edge<P, C>> { self.next_back() }
}
impl<'a, P, C> DoubleEndedIterator for BoundaryIter<'a, P, C> {
#[inline(always)]
fn next_back(&mut self) -> Option<Edge<P, C>> {
match self.orientation {
true => self.edge_iter.next_back().cloned(),
false => self.edge_iter.next().map(|edge| edge.inverse()),
}
}
}
impl<'a, P, C> ExactSizeIterator for BoundaryIter<'a, P, C> {
#[inline(always)]
fn len(&self) -> usize { self.edge_iter.len() }
}
impl<'a, P, C> std::iter::FusedIterator for BoundaryIter<'a, P, C> {}
impl<'a, P: Debug, C: Debug, S: Debug> Debug
for DebugDisplay<'a, Face<P, C, S>, FaceDisplayFormat>
{
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self.format {
FaceDisplayFormat::Full { wire_format } => f
.debug_struct("Face")
.field("id", &self.entity.id())
.field(
"boundaries",
&self
.entity
.boundaries()
.iter()
.map(|wire| wire.display(wire_format))
.collect::<Vec<_>>(),
)
.field("entity", &MutexFmt(&self.entity.surface))
.finish(),
FaceDisplayFormat::BoundariesAndID { wire_format } => f
.debug_struct("Face")
.field("id", &self.entity.id())
.field(
"boundaries",
&self
.entity
.boundaries()
.iter()
.map(|wire| wire.display(wire_format))
.collect::<Vec<_>>(),
)
.finish(),
FaceDisplayFormat::BoundariesAndSurface { wire_format } => f
.debug_struct("Face")
.field(
"boundaries",
&self
.entity
.boundaries()
.iter()
.map(|wire| wire.display(wire_format))
.collect::<Vec<_>>(),
)
.field("entity", &MutexFmt(&self.entity.surface))
.finish(),
FaceDisplayFormat::LoopsListTuple { wire_format } => f
.debug_tuple("Face")
.field(
&self
.entity
.boundaries()
.iter()
.map(|wire| wire.display(wire_format))
.collect::<Vec<_>>(),
)
.finish(),
FaceDisplayFormat::LoopsList { wire_format } => f
.debug_list()
.entries(
self.entity
.boundaries()
.iter()
.map(|wire| wire.display(wire_format)),
)
.finish(),
FaceDisplayFormat::AsSurface => {
f.write_fmt(format_args!("{:?}", &MutexFmt(&self.entity.surface)))
}
}
}
}
#[test]
fn invert_mapped_face() {
let v = Vertex::news(&[0, 1, 2, 3, 4, 5, 6]);
let wire0 = Wire::from(vec![
Edge::new(&v[0], &v[1], 100),
Edge::new(&v[1], &v[2], 200),
Edge::new(&v[2], &v[3], 300),
Edge::new(&v[3], &v[0], 400),
]);
let wire1 = Wire::from(vec![
Edge::new(&v[4], &v[5], 500),
Edge::new(&v[6], &v[5], 600).inverse(),
Edge::new(&v[6], &v[4], 700),
]);
let face0 = Face::new(vec![wire0, wire1], 10000).inverse();
let face1 = face0.mapped(
&move |i: &usize| *i + 10,
&move |j: &usize| *j + 1000,
&move |k: &usize| *k + 100000,
);
assert_eq!(face0.get_surface() + 100000, face1.get_surface(),);
assert_eq!(face0.orientation(), face1.orientation());
let biters0 = face0.boundary_iters();
let biters1 = face1.boundary_iters();
for (biter0, biter1) in biters0.into_iter().zip(biters1) {
for (edge0, edge1) in biter0.zip(biter1) {
assert_eq!(edge0.front().get_point() + 10, edge1.front().get_point(),);
assert_eq!(edge0.back().get_point() + 10, edge1.back().get_point(),);
assert_eq!(edge0.get_curve() + 1000, edge1.get_curve(),);
}
}
}