rust/integral-geometry/src/lib.rs
branchtransitional_engine
changeset 16081 6633961698ad
parent 16068 a236360669cc
child 16102 5d302b12d837
equal deleted inserted replaced
16080:a5eaeefa4ab3 16081:6633961698ad
   105         FPPoint::new(self.x.into(), self.y.into())
   105         FPPoint::new(self.x.into(), self.y.into())
   106     }
   106     }
   107 
   107 
   108     #[inline]
   108     #[inline]
   109     pub fn from_fppoint(p: &FPPoint) -> Self {
   109     pub fn from_fppoint(p: &FPPoint) -> Self {
   110         Self::new(p.x().round(), p.y().round())
   110         Self::new(p.x().round() as i32, p.y().round() as i32)
   111     }
   111     }
   112 }
   112 }
   113 
   113 
   114 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
   114 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
   115 pub struct Size {
   115 pub struct Size {
   612 
   612 
   613     pub fn split_edge(&mut self, edge_index: usize, vertex: Point) {
   613     pub fn split_edge(&mut self, edge_index: usize, vertex: Point) {
   614         self.vertices.insert(edge_index + 1, vertex);
   614         self.vertices.insert(edge_index + 1, vertex);
   615     }
   615     }
   616 
   616 
   617     pub fn iter<'a>(&'a self) -> impl Iterator<Item = &Point> + 'a {
   617     pub fn iter(&self) -> impl Iterator<Item = &Point> {
   618         (&self.vertices[..self.edges_count()]).iter()
   618         (&self.vertices[..self.edges_count()]).iter()
   619     }
   619     }
   620 
   620 
   621     pub fn iter_mut<'a>(&'a mut self) -> impl Iterator<Item = &mut Point> + 'a {
   621     pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Point> {
   622         let edges_count = self.edges_count();
   622         let edges_count = self.edges_count();
   623         let start = self.vertices.as_mut_ptr();
   623         let start = self.vertices.as_mut_ptr();
   624         let end = unsafe { start.add(edges_count) };
   624         let end = unsafe { start.add(edges_count) };
   625         PolygonPointsIteratorMut {
   625         PolygonPointsIteratorMut {
   626             source: self,
   626             source: self,