Skip to content

Commit

Permalink
VON work and perfing.
Browse files Browse the repository at this point in the history
Perfing is maxed out
  • Loading branch information
Hellblazer committed Dec 29, 2024
1 parent 6799552 commit 07d8cf8
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 188 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package com.hellblazer.luciferase.lucien.grid;

import javax.vecmath.Point3d;
import javax.vecmath.Point3f;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
Expand All @@ -30,7 +29,6 @@
* The dynamic, mutable version of the Grid
*
* @author <a href="mailto:[email protected]">Hal Hildebrand</a>
*
*/

public class MutableGrid extends Grid {
Expand All @@ -43,7 +41,6 @@ public MutableGrid() {

/**
* Construct a Sentinel using the supplied random number generator
*
*/
public MutableGrid(Vertex[] fourCorners) {
super(fourCorners);
Expand All @@ -68,8 +65,8 @@ public void rebuild(Random entropy) {
}

/**
* Track the point into the tetrahedralization. See "Computing the 3D Voronoi
* Diagram Robustly: An Easy Explanation", by Hugo Ledoux
* Track the point into the tetrahedralization. See "Computing the 3D Voronoi Diagram Robustly: An Easy
* Explanation", by Hugo Ledoux
* <p>
*
* @param p - the point to be inserted
Expand All @@ -78,13 +75,17 @@ public void rebuild(Random entropy) {
public Vertex track(Point3d p, Random entropy) {
assert p != null;
final var v = new Vertex(p);
add(v, locate(p, last, entropy));
add(v, locate(p, entropy));
return v;
}

public Tetrahedron locate(Point3d p, Random entropy) {
return locate(p, last, entropy);
}

/**
* Track the point into the tetrahedralization. See "Computing the 3D Voronoi
* Diagram Robustly: An Easy Explanation", by Hugo Ledoux
* Track the point into the tetrahedralization. See "Computing the 3D Voronoi Diagram Robustly: An Easy
* Explanation", by Hugo Ledoux
* <p>
*
* @param p - the point to be inserted
Expand All @@ -109,7 +110,6 @@ public void untrack(Vertex v) {
* Perform the 4->1 bistellar flip. This flip is the inverse of the 1->4 flip.
*
* @param n - the vertex who's star defines the 4 tetrahedron
*
* @return the tetrahedron created from the flip
*/
protected Tetrahedron flip4to1(Vertex n) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@

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 @@ -119,7 +113,7 @@ public Tetrahedron flip(Vertex n, List<OrientedFace> ears) {
Tetrahedron returned = null;
if (reflexEdges == 0 && !isRegular()) {
// Only one face of the opposing tetrahedron is visible
for (Tetrahedron t : flip2to3()) {
for (var t : flip2to3()) {
var f = t.getFace(n);
if (f.hasAdjacent()) {
ears.add(f);
Expand All @@ -132,7 +126,7 @@ public Tetrahedron flip(Vertex n, List<OrientedFace> ears) {
var t1 = getIncident().getNeighbor(opposingVertex);
var t2 = getAdjacent().getNeighbor(opposingVertex);
if (t1 != null && t1 == t2) {
for (Tetrahedron t : flip3to2(reflexEdge)) {
for (var t : flip3to2(reflexEdge)) {
OrientedFace f = t.getFace(n);
if (f.hasAdjacent()) {
ears.add(f);
Expand All @@ -152,14 +146,18 @@ public Tetrahedron flip(Vertex n, List<OrientedFace> ears) {
* @return the three created tetrahedron
*/
public Tetrahedron[] flip2to3() {
assert getAdjacentVertexOrdinal() != null;
var incident = getIncident();

var opposingVertex = getAdjacentVertex();
var incidentVertex = getIncidentVertex();
var t0 = new Tetrahedron(getVertex(0), incidentVertex, getVertex(1), opposingVertex);
var t1 = new Tetrahedron(getVertex(1), incidentVertex, getVertex(2), opposingVertex);
var t2 = new Tetrahedron(getVertex(0), getVertex(2), incidentVertex, opposingVertex);

var vertex0 = getVertex(0);
var vertex1 = getVertex(1);
var vertex2 = getVertex(2);

var t0 = new Tetrahedron(vertex0, incidentVertex, vertex1, opposingVertex);
var t1 = new Tetrahedron(vertex1, incidentVertex, vertex2, opposingVertex);
var t2 = new Tetrahedron(vertex0, vertex2, incidentVertex, opposingVertex);

t0.setNeighborA(t1);
t0.setNeighborC(t2);
Expand All @@ -170,15 +168,15 @@ public Tetrahedron[] flip2to3() {
t2.setNeighborA(t1);
t2.setNeighborB(t0);

incident.patch(getVertex(2), t0, D);
incident.patch(getVertex(0), t1, D);
incident.patch(getVertex(1), t2, D);
incident.patch(vertex2, t0, D);
incident.patch(vertex0, t1, D);
incident.patch(vertex1, t2, D);

var adjacent = getAdjacent();

adjacent.patch(getVertex(0), t1, B);
adjacent.patch(getVertex(1), t2, C);
adjacent.patch(getVertex(2), t0, B);
adjacent.patch(vertex0, t1, B);
adjacent.patch(vertex1, t2, C);
adjacent.patch(vertex2, t0, B);

incident.delete();
adjacent.delete();
Expand Down Expand Up @@ -221,7 +219,6 @@ public Tetrahedron[] flip2to3() {
* @return the two created tetrahedron
*/
public Tetrahedron[] flip3to2(int reflexEdge) {
assert getAdjacentVertexOrdinal() != null;
var incident = getIncident();
var o2 = getIncident().getNeighbor(getVertex(reflexEdge));

Expand Down Expand Up @@ -293,11 +290,12 @@ public Tetrahedron[] flip3to2(int reflexEdge) {
* @return
*/
public Vertex getAdjacentVertex() {
var current = getAdjacentVertexOrdinal();
Tetrahedron adjacent = getAdjacent();
var current = adjacent == null ? null : adjacent.ordinalOf(getIncident());
if (current == null) {
return null;
}
return getAdjacent().getVertex(current);
return adjacent.getVertex(current);
}

/**
Expand All @@ -306,12 +304,8 @@ public Vertex getAdjacentVertex() {
* @return
*/
public V getAdjacentVertexOrdinal() {
var current = adjacentVertexOrdinal;
if (current == null) {
Tetrahedron adjacent = getAdjacent();
current = adjacentVertexOrdinal = adjacent == null ? null : adjacent.ordinalOf(getIncident());
}
return current;
Tetrahedron adjacent = getAdjacent();
return adjacent == null ? null : adjacent.ordinalOf(getIncident());
}

/**
Expand Down Expand Up @@ -428,13 +422,13 @@ private boolean inSphere(Vertex query, Vertex b, Vertex c, Vertex d) {
b = a;
a = tmp;
}
return query.inSphere(a, b, c, d) > 0;
return query.inSphere(a, b, c, d) > 0.0;
}

private boolean isFlippable3ear(Vertex n) {
var opposingFace = getIncident().getFace(n);
opposingFace.getAdjacent().getFace(opposingFace.getAdjacentVertex());
return opposingFace.orientationOf(n) > 0;
return opposingFace.orientationOf(n) > 0.0;

}

Expand Down
Loading

0 comments on commit 07d8cf8

Please sign in to comment.