/// <summary> /// Pivots the edge forward around its near vertex, such that it targets the next far vertex along the next face. /// </summary> /// <param name="edge">The edge to be pivoted.</param> public void PivotEdgeForward(VertexEdge edge) { if (!CanPivotEdgeForward(edge)) { throw new InvalidOperationException("Cannot pivot a vertex edge forward when either its far vertex or next face has only two neighbors."); } PivotEdgeForwardUnchecked(edge); }
/// <summary> /// Spins the edge forward, such that it targets the next far vertex along the next face, and it /// comes from the next near vertex along the previous face. /// </summary> /// <param name="edge">The edge to spin.</param> /// <remarks><para>This is equivalent to pivoting both the specified edge and its twin.</para></remarks> public void SpinEdgeForward(VertexEdge edge) { if (!CanSpinEdgeForward(edge)) { throw new InvalidOperationException("Cannot spin a vertex edge forward when either its far vertex or near vertex has only two neighbors."); } PivotEdgeForwardUnchecked(edge); PivotEdgeForwardUnchecked(edge.twin); }
/// <summary> /// Checks if the local topology around the given edge allows it to spin forward one step. /// </summary> /// <param name="edge">The edge to spin.</param> /// <returns>True if the edge can spin forward one step, and false if it cannot.</returns> /// <remarks><para>Spinning a vertex edge forward will reduce the current near and far vertex neighbor counts /// by one. Neither of those neighbor counts are allowed to drop below two, so if either of them are already /// two or less, the spin should be disallowed. Additionally, if the previous or next face neighbor counts are /// two or less (that is, they are degenerate faces), then the spin modification would break down, so these /// neighbor counts must also be greater than two or else the spin is disallowed.</para></remarks> public bool CanSpinEdgeForward(VertexEdge edge) { // After spinning, the edge's old near and far vertices will both have their // neighbor counts reduced by one. Neither of these counts can fall below 2. // The previous and next faces must also have more than 2 neighbors, or else // things get really weird. // Note that all face neighbor counts will remain stable. return(edge.farVertex.neighborCount > 2 && edge.nearVertex.neighborCount > 2 && edge.prevFace.neighborCount > 2 && edge.nextFace.neighborCount > 2); }
private void PivotEdgeForwardUnchecked(VertexEdge edge) { int edgeIndex = edge.index; int twinEdgeIndex = edgeData[edgeIndex].twin; var outerEdgeIndex1 = edgeData[edgeIndex].fNext; var innerEdgeIndex1 = edgeData[outerEdgeIndex1].twin; PivotVertexEdgeForwardUnchecked(edgeIndex, twinEdgeIndex, outerEdgeIndex1, innerEdgeIndex1); }
private void PivotEdgeBackwardUnchecked(VertexEdge edge) { int edgeIndex = edge.index; var twinEdgeIndex = edgeData[edgeIndex].twin; var innerEdgeIndex1 = edgeData[twinEdgeIndex].vNext; var outerEdgeIndex1 = edgeData[innerEdgeIndex1].twin; PivotVertexEdgeBackwardUnchecked(edgeIndex, twinEdgeIndex, outerEdgeIndex1, innerEdgeIndex1); }
public VertexEdge(int index) : base(dataSize, index) { inst = this; }
/// <summary> /// Tries to find the outer edge around the current vertex that points to the given vertex. /// </summary> /// <param name="vertex">The vertex for which the corresponding edge is to be found.</param> /// <param name="edge">The outer edge whose vertex is the given vertex, or an empty edge if no matching edge is found.</param> /// <returns>True if the corresponding edge was found, and false if no matching edge is found.</returns> public bool TryFindOuterEdge(Vertex vertex, out VertexEdge edge) { return edge = FindOuterEdge(vertex); }
/// <summary> /// Tries to find the outer edge around the current vertex that corresponds to the given face. /// </summary> /// <param name="face">The face for which the corresponding edge is to be found.</param> /// <param name="edge">The outer edge whose face is the given face, or an empty edge if no matching edge is found.</param> /// <returns>True if the corresponding edge was found, and false if no matching edge is found.</returns> public bool TryFindOuterEdge(Face face, out VertexEdge edge) { return edge = FindOuterEdge(face); }
/// <summary> /// Checks if the local topology around the given edge allows it to be pivoted around its near vertex. /// </summary> /// <param name="edge">The edge to be pivoted.</param> /// <returns>True if the edge can be pivoted forward, and false if it cannot.</returns> /// <remarks><para>Pivoting a vertex edge forward will reduce the current far vertex neighbor count by /// one, and the next face neighbor count by one. Neither of those neighbor counts are allowed to drop /// below two, so if either of them are already two or less, the pivot should be disallowed.</para></remarks> public bool CanPivotEdgeForward(VertexEdge edge) { // After pivoting, the edge's old far vertex and next face will both have their // neighbor counts reduced by one. Neither of these counts can fall below 2. return(edge.farVertex.neighborCount > 2 && edge.nextFace.neighborCount > 2); }