pub fn collapse_edge(&mut self, halfedge_id: HalfEdgeID) -> VertexID
    {
        let mut walker = self.walker_from_halfedge(halfedge_id);
        let surviving_vertex_id = walker.vertex_id().unwrap();
        walker.as_twin();
        let dying_vertex_id = walker.vertex_id().unwrap();
        let new_position = 0.5 * (self.vertex_position(surviving_vertex_id) + self.vertex_position(dying_vertex_id));


        // Update halfedges pointing to dying vertex
        for halfedge_id in self.vertex_halfedge_iter(dying_vertex_id) {
            self.connectivity_info.set_halfedge_vertex(self.walker_from_halfedge(halfedge_id).twin_id().unwrap(), surviving_vertex_id);
        }

        // Remove first face + halfedges
        let mut he_id1 = walker.halfedge_id();
        if walker.face_id().is_some() {
            walker.as_previous();
            self.connectivity_info.set_vertex_halfedge( surviving_vertex_id, walker.twin_id());
            walker.as_next();
        }
        else {
            self.connectivity_info.remove_halfedge(he_id1.unwrap());
            he_id1 = None;
        }

        // Remove second face + halfedges
        walker.as_twin();
        let he_id2 = walker.halfedge_id().unwrap();
        if walker.face_id().is_some() {
            walker.as_previous();
            self.connectivity_info.set_vertex_halfedge( surviving_vertex_id, walker.twin_id());
            self.remove_one_face(he_id2);
        }
        else {
            self.connectivity_info.remove_halfedge(he_id2);
        }

        if let Some(he_id_to_remove) = he_id1 {
            self.remove_one_face(he_id_to_remove);
        }

        // Remove dying vertex
        self.connectivity_info.remove_vertex(dying_vertex_id);

        self.move_vertex_to(surviving_vertex_id, new_position);
        surviving_vertex_id
    }
///
/// Collapses the given edge. Consequently, the to adjacent faces are removed and
/// the two adjacent vertices are merged into one vertex
/// which position is the average of the original vertex positions.
/// Returns the merged vertex.
///
/// **Note:** This might make some faces degenerate.
///
Collapses the given edge. Consequently, the to adjacent faces are removed and
the two adjacent vertices are merged into one vertex
which position is the average of the original vertex positions.
Returns the merged vertex.

This might make some faces degenerate.
Collapses the given edge . Consequently the to adjacent faces are removed and the two adjacent vertices are merged into one vertex which position is the average of the original vertex positions . Returns the merged vertex . This might make some faces degenerate .
pub fn collapse_edge(&mut self, halfedge_id: HalfEdgeID) -> VertexID
    {
        let mut walker = self.walker_from_halfedge(halfedge_id);
        let surviving_vertex_id = walker.vertex_id().unwrap();
        walker.as_twin();
        let dying_vertex_id = walker.vertex_id().unwrap();
        let new_position = 0.5 * (self.vertex_position(surviving_vertex_id) + self.vertex_position(dying_vertex_id));
        // Update halfedges pointing to dying vertex
        for halfedge_id in self.vertex_halfedge_iter(dying_vertex_id) {
            self.connectivity_info.set_halfedge_vertex(self.walker_from_halfedge(halfedge_id).twin_id().unwrap(), surviving_vertex_id);
        }
        // Remove first face + halfedges
        let mut he_id1 = walker.halfedge_id();
        if walker.face_id().is_some() {
            walker.as_previous();
            self.connectivity_info.set_vertex_halfedge( surviving_vertex_id, walker.twin_id());
            walker.as_next();
        }
        else {
            self.connectivity_info.remove_halfedge(he_id1.unwrap());
            he_id1 = None;
        }
        // Remove second face + halfedges
        walker.as_twin();
        let he_id2 = walker.halfedge_id().unwrap();
        if walker.face_id().is_some() {
            walker.as_previous();
            self.connectivity_info.set_vertex_halfedge( surviving_vertex_id, walker.twin_id());
            self.remove_one_face(he_id2);
        }
        else {
            self.connectivity_info.remove_halfedge(he_id2);
        }
        if let Some(he_id_to_remove) = he_id1 {
            self.remove_one_face(he_id_to_remove);
        }
        // Remove dying vertex
        self.connectivity_info.remove_vertex(dying_vertex_id);
        self.move_vertex_to(surviving_vertex_id, new_position);
        surviving_vertex_id
    }
pub fn collapse_edge ( & mut self , halfedge_id : HalfEdgeID ) -> VertexID { let mut walker = self . walker_from_halfedge ( halfedge_id ) ; let surviving_vertex_id = walker . vertex_id ( ) . unwrap ( ) ; walker . as_twin ( ) ; let dying_vertex_id = walker . vertex_id ( ) . unwrap ( ) ; let new_position = 0.5 * ( self . vertex_position ( surviving_vertex_id ) + self . vertex_position ( dying_vertex_id ) ) ; // Update halfedges pointing to dying vertex for halfedge_id in self . vertex_halfedge_iter ( dying_vertex_id ) { self . connectivity_info . set_halfedge_vertex ( self . walker_from_halfedge ( halfedge_id ) . twin_id ( ) . unwrap ( ) , surviving_vertex_id ) ; } // Remove first face + halfedges let mut he_id1 = walker . halfedge_id ( ) ; if walker . face_id ( ) . is_some ( ) { walker . as_previous ( ) ; self . connectivity_info . set_vertex_halfedge ( surviving_vertex_id , walker . twin_id ( ) ) ; walker . as_next ( ) ; } else { self . connectivity_info . remove_halfedge ( he_id1 . unwrap ( ) ) ; he_id1 = None ; } // Remove second face + halfedges walker . as_twin ( ) ; let he_id2 = walker . halfedge_id ( ) . unwrap ( ) ; if walker . face_id ( ) . is_some ( ) { walker . as_previous ( ) ; self . connectivity_info . set_vertex_halfedge ( surviving_vertex_id , walker . twin_id ( ) ) ; self . remove_one_face ( he_id2 ) ; } else { self . connectivity_info . remove_halfedge ( he_id2 ) ; } if let Some ( he_id_to_remove ) = he_id1 { self . remove_one_face ( he_id_to_remove ) ; } // Remove dying vertex self . connectivity_info . remove_vertex ( dying_vertex_id ) ; self . move_vertex_to ( surviving_vertex_id , new_position ) ; surviving_vertex_id }
Collapses the given edge.
Collapses the given edge .
&mut self
halfedge_id
HalfEdgeID
&mut self
halfedge_id
HalfEdgeID