pub fn flip_edge(&mut self, halfedge_id: HalfEdgeID) -> Result<(), Error>
    {
        let mut walker = self.walker_from_halfedge(halfedge_id);
        let face_id = walker.face_id().ok_or(Error::ActionWillResultInInvalidMesh {message: format!("Trying to flip edge on boundary")})?;
        let next_id = walker.next_id().unwrap();
        let previous_id = walker.previous_id().unwrap();
        let v0 = walker.vertex_id().unwrap();
        walker.as_next();
        let v3 = walker.vertex_id().unwrap();
        walker.as_previous();

        walker.as_twin();
        let twin_id = walker.halfedge_id().unwrap();
        let twin_face_id = walker.face_id().ok_or(Error::ActionWillResultInInvalidMesh {message: format!("Trying to flip edge on boundary")})?;
        let twin_next_id = walker.next_id().unwrap();
        let twin_previous_id = walker.previous_id().unwrap();
        let v1 = walker.vertex_id().unwrap();
        let v2 = walker.as_next().vertex_id().unwrap();

        if self.connecting_edge(v2, v3).is_some() { return Err(Error::ActionWillResultInInvalidMesh {message: format!("Trying to flip edge which will connect two vertices that are already connected by another edge")}) }

        self.connectivity_info.set_face_halfedge(face_id, previous_id);
        self.connectivity_info.set_face_halfedge(twin_face_id, twin_previous_id);

        self.connectivity_info.set_vertex_halfedge(v0, Some(next_id));
        self.connectivity_info.set_vertex_halfedge(v1, Some(twin_next_id));

        self.connectivity_info.set_halfedge_next(halfedge_id, Some(previous_id));
        self.connectivity_info.set_halfedge_next(next_id, Some(twin_id));
        self.connectivity_info.set_halfedge_next(previous_id, Some(twin_next_id));
        self.connectivity_info.set_halfedge_next(twin_id, Some(twin_previous_id));
        self.connectivity_info.set_halfedge_next(twin_next_id, Some(halfedge_id));
        self.connectivity_info.set_halfedge_next(twin_previous_id, Some(next_id));

        self.connectivity_info.set_halfedge_vertex(halfedge_id, v3);
        self.connectivity_info.set_halfedge_vertex(twin_id, v2);

        self.connectivity_info.set_halfedge_face(next_id, Some(twin_face_id));
        self.connectivity_info.set_halfedge_face(twin_next_id, Some(face_id));

        Ok(())
    }
/// Flip the given edge such that the edge after the flip is connected to the
/// other pair of the four vertices connected to the two adjacent faces.
///
/// ```text
///   /\          /|\
///  /  \        / | \
/// /____\  --> /  |  \
/// \    /      \  |  /
///  \  /        \ | /
///   \/          \|/
/// ```
///
/// # Error
///
/// Returns an error if trying to flip an edge on the boundary or the flip will connect two vertices that are already connected by another edge.
///
Flip the given edge such that the edge after the flip is connected to the
other pair of the four vertices connected to the two adjacent faces.


Flip the given edge such that the edge after the flip is connected to the other pair of the four vertices connected to the two adjacent faces .
pub fn flip_edge(&mut self, halfedge_id: HalfEdgeID) -> Result<(), Error>
    {
        let mut walker = self.walker_from_halfedge(halfedge_id);
        let face_id = walker.face_id().ok_or(Error::ActionWillResultInInvalidMesh {message: format!("Trying to flip edge on boundary")})?;
        let next_id = walker.next_id().unwrap();
        let previous_id = walker.previous_id().unwrap();
        let v0 = walker.vertex_id().unwrap();
        walker.as_next();
        let v3 = walker.vertex_id().unwrap();
        walker.as_previous();
        walker.as_twin();
        let twin_id = walker.halfedge_id().unwrap();
        let twin_face_id = walker.face_id().ok_or(Error::ActionWillResultInInvalidMesh {message: format!("Trying to flip edge on boundary")})?;
        let twin_next_id = walker.next_id().unwrap();
        let twin_previous_id = walker.previous_id().unwrap();
        let v1 = walker.vertex_id().unwrap();
        let v2 = walker.as_next().vertex_id().unwrap();
        if self.connecting_edge(v2, v3).is_some() { return Err(Error::ActionWillResultInInvalidMesh {message: format!("Trying to flip edge which will connect two vertices that are already connected by another edge")}) }
        self.connectivity_info.set_face_halfedge(face_id, previous_id);
        self.connectivity_info.set_face_halfedge(twin_face_id, twin_previous_id);
        self.connectivity_info.set_vertex_halfedge(v0, Some(next_id));
        self.connectivity_info.set_vertex_halfedge(v1, Some(twin_next_id));
        self.connectivity_info.set_halfedge_next(halfedge_id, Some(previous_id));
        self.connectivity_info.set_halfedge_next(next_id, Some(twin_id));
        self.connectivity_info.set_halfedge_next(previous_id, Some(twin_next_id));
        self.connectivity_info.set_halfedge_next(twin_id, Some(twin_previous_id));
        self.connectivity_info.set_halfedge_next(twin_next_id, Some(halfedge_id));
        self.connectivity_info.set_halfedge_next(twin_previous_id, Some(next_id));
        self.connectivity_info.set_halfedge_vertex(halfedge_id, v3);
        self.connectivity_info.set_halfedge_vertex(twin_id, v2);
        self.connectivity_info.set_halfedge_face(next_id, Some(twin_face_id));
        self.connectivity_info.set_halfedge_face(twin_next_id, Some(face_id));
        Ok(())
    }
pub fn flip_edge ( & mut self , halfedge_id : HalfEdgeID ) -> Result < ( ) , Error > { let mut walker = self . walker_from_halfedge ( halfedge_id ) ; let face_id = walker . face_id ( ) . ok_or ( Error :: ActionWillResultInInvalidMesh { message : format ! ( " " ) } ) ? ; let next_id = walker . next_id ( ) . unwrap ( ) ; let previous_id = walker . previous_id ( ) . unwrap ( ) ; let v0 = walker . vertex_id ( ) . unwrap ( ) ; walker . as_next ( ) ; let v3 = walker . vertex_id ( ) . unwrap ( ) ; walker . as_previous ( ) ; walker . as_twin ( ) ; let twin_id = walker . halfedge_id ( ) . unwrap ( ) ; let twin_face_id = walker . face_id ( ) . ok_or ( Error :: ActionWillResultInInvalidMesh { message : format ! ( " " ) } ) ? ; let twin_next_id = walker . next_id ( ) . unwrap ( ) ; let twin_previous_id = walker . previous_id ( ) . unwrap ( ) ; let v1 = walker . vertex_id ( ) . unwrap ( ) ; let v2 = walker . as_next ( ) . vertex_id ( ) . unwrap ( ) ; if self . connecting_edge ( v2 , v3 ) . is_some ( ) { return Err ( Error :: ActionWillResultInInvalidMesh { message : format ! ( " " ) } ) } self . connectivity_info . set_face_halfedge ( face_id , previous_id ) ; self . connectivity_info . set_face_halfedge ( twin_face_id , twin_previous_id ) ; self . connectivity_info . set_vertex_halfedge ( v0 , Some ( next_id ) ) ; self . connectivity_info . set_vertex_halfedge ( v1 , Some ( twin_next_id ) ) ; self . connectivity_info . set_halfedge_next ( halfedge_id , Some ( previous_id ) ) ; self . connectivity_info . set_halfedge_next ( next_id , Some ( twin_id ) ) ; self . connectivity_info . set_halfedge_next ( previous_id , Some ( twin_next_id ) ) ; self . connectivity_info . set_halfedge_next ( twin_id , Some ( twin_previous_id ) ) ; self . connectivity_info . set_halfedge_next ( twin_next_id , Some ( halfedge_id ) ) ; self . connectivity_info . set_halfedge_next ( twin_previous_id , Some ( next_id ) ) ; self . connectivity_info . set_halfedge_vertex ( halfedge_id , v3 ) ; self . connectivity_info . set_halfedge_vertex ( twin_id , v2 ) ; self . connectivity_info . set_halfedge_face ( next_id , Some ( twin_face_id ) ) ; self . connectivity_info . set_halfedge_face ( twin_next_id , Some ( face_id ) ) ; Ok ( ( ) ) }
Flip the given edge such that the edge after the flip is connected to the
other pair of the four vertices connected to the two adjacent faces.
Flip the given edge such that the edge after the flip is connected to the other pair of the four vertices connected to the two adjacent faces .
&mut self
halfedge_id
HalfEdgeID
&mut self
halfedge_id
HalfEdgeID
error
Returns an error if trying to flip an edge on the boundary or the flip will connect two vertices that are already connected by another edge.
Returns an error if trying to flip an edge on the boundary or the flip will connect two vertices that are already connected by another edge .