Skip to content

Commit

Permalink
wax on/wax off
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Dec 28, 2024
1 parent 91f077a commit 1b6bf6a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@

public abstract class OrientedFace implements Iterable<Vertex> {

private volatile V adjacentVertexOrdinal;

void clear() {
adjacentVertexOrdinal = null;
}

/**
* Perform a flip for deletion of the vertex from the tetrahedralization. The incident and adjacent tetrahedra form
* an ear of the star set of tetrahedra adjacent to v.
Expand Down Expand Up @@ -287,23 +293,25 @@ public Tetrahedron[] flip3to2(int reflexEdge) {
* @return
*/
public Vertex getAdjacentVertex() {
if (getAdjacentVertexOrdinal() == null) {
var current = getAdjacentVertexOrdinal();
if (current == null) {
return null;
}
return getAdjacent().getVertex(getAdjacentVertexOrdinal());
return getAdjacent().getVertex(current);
}

/**
* The vertex in the adjacent tetrahedron opposite of this face
*/
/**
* Answer the canonical ordinal of the vertex in the adjacent tetrahedron which is opposite of this face.
*
* @return
*/
public V getAdjacentVertexOrdinal() {
Tetrahedron adjacent = getAdjacent();
return adjacent == null ? null : adjacent.ordinalOf(getIncident());
var current = adjacentVertexOrdinal;
if (current == null) {
Tetrahedron adjacent = getAdjacent();
current = adjacentVertexOrdinal = adjacent == null ? null : adjacent.ordinalOf(getIncident());
}
return current;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ boolean isDeleted() {
* @return
*/
V ordinalOf(Tetrahedron neighbor) {
clear();
if (nA == neighbor) {
return A;
}
Expand All @@ -569,6 +570,13 @@ V ordinalOf(Tetrahedron neighbor) {
throw new IllegalArgumentException("Not a neighbor: " + neighbor);
}

private void clear() {
faceADB.clear();
faceBCA.clear();
faceCBD.clear();
faceDAC.clear();
}

/**
* Patch the new tetrahedron created by a flip of the receiver by seting the neighbor to the value in the receiver
* <p>
Expand Down Expand Up @@ -633,6 +641,7 @@ void removeAnyDegenerateTetrahedronPair() {
}

void setNeighbor(V v, Tetrahedron n) {
clear();
if (v == A) {
nA = n;
return;
Expand All @@ -645,25 +654,26 @@ void setNeighbor(V v, Tetrahedron n) {
nC = n;
return;
}
if (v == D) {
nD = n;
return;
}
nD = n;
}

void setNeighborA(Tetrahedron t) {
clear();
nA = t;
}

void setNeighborB(Tetrahedron t) {
clear();
nB = t;
}

void setNeighborC(Tetrahedron t) {
clear();
nC = t;
}

void setNeighborD(Tetrahedron t) {
clear();
nD = t;
}

Expand Down

0 comments on commit 1b6bf6a

Please sign in to comment.