Skip to content

Commit

Permalink
heavy refactor. update to java 22, use mvnw
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Jul 21, 2024
1 parent 5c40e9e commit c3ef8e1
Show file tree
Hide file tree
Showing 15 changed files with 1,667 additions and 1,317 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: 3.9.4
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: graalvm
with:
java-version: '22'
distribution: 'graalvm'
cache: 'maven'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build with Maven
run: mvn -batch-mode --update-snapshots clean install --file pom.xml
run: ./mvnw -batch-mode --update-snapshots clean install --file pom.xml
19 changes: 19 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip
Original file line number Diff line number Diff line change
@@ -1,33 +1,54 @@
/**
* Copyright (C) 2010 Hal Hildebrand. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/

package com.hellblazer.luciferase.lucien.grid;

import com.hellblazer.luciferase.common.OaHashSet;

import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import com.hellblazer.luciferase.common.OaHashSet;

/**
* @author <a href="mailto:hal.hildebrand@gmail.com">Hal Hildebrand</a>
*
*/
public class EarSet implements StarVisitor {
private List<OrientedFace> ears = new LinkedList<>();
private Set<Ear> visited = new OaHashSet<>();

public List<OrientedFace> getEars() {
return ears;
}

@Override
public void visit(V vertex, Tetrahedron t, Vertex x, Vertex y, Vertex z) {
OrientedFace face = t.getFace(z);
if (visited.add(new Ear(face))) {
ears.add(face);
}
face = t.getFace(x);
if (visited.add(new Ear(face))) {
ears.add(face);
}
face = t.getFace(y);
if (visited.add(new Ear(face))) {
ears.add(face);
}
}

private static class Ear {
final OrientedFace face;
final int hashcode;
Expand All @@ -45,8 +66,8 @@ private static class Ear {
public boolean equals(Object obj) {
if (obj instanceof Ear) {
Ear ear = (Ear) obj;
if ((face.getIncident() == ear.face.getIncident() && face.getAdjacent() == ear.face.getAdjacent()) ||
(face.getAdjacent() == ear.face.getIncident() && face.getIncident() == ear.face.getAdjacent())) {
if ((face.getIncident() == ear.face.getIncident() && face.getAdjacent() == ear.face.getAdjacent()) || (
face.getAdjacent() == ear.face.getIncident() && face.getIncident() == ear.face.getAdjacent())) {
return true;
}
}
Expand All @@ -58,27 +79,4 @@ public int hashCode() {
return hashcode;
}
}

private List<OrientedFace> ears = new LinkedList<>();
private Set<Ear> visited = new OaHashSet<>();

public List<OrientedFace> getEars() {
return ears;
}

@Override
public void visit(V vertex, Tetrahedron t, Vertex x, Vertex y, Vertex z) {
OrientedFace face = t.getFace(z);
if (visited.add(new Ear(face))) {
ears.add(face);
}
face = t.getFace(x);
if (visited.add(new Ear(face))) {
ears.add(face);
}
face = t.getFace(y);
if (visited.add(new Ear(face))) {
ears.add(face);
}
}
}
105 changes: 44 additions & 61 deletions lucien/src/main/java/com/hellblazer/luciferase/lucien/grid/Grid.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
/**
* Copyright (C) 2009-2023 Hal Hildebrand. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.hellblazer.luciferase.lucien.grid;

import static com.hellblazer.luciferase.lucien.grid.V.A;
import static com.hellblazer.luciferase.lucien.grid.V.B;
import static com.hellblazer.luciferase.lucien.grid.V.C;
import static com.hellblazer.luciferase.lucien.grid.V.D;

import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import com.hellblazer.luciferase.common.IdentitySet;

import javax.vecmath.Tuple3f;
import java.util.*;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import com.hellblazer.luciferase.common.IdentitySet;
import static com.hellblazer.luciferase.lucien.grid.V.*;

/**
* A Delaunay tetrahedralization. This implementation is optimized for
Expand All @@ -51,10 +40,10 @@
* topology. Because we throw the tetrahedra away on every rebuild, there's
* really little need for an index and so random walk is used. It is assumed
* that the vast majority, if not damn near entirety of operations concerning
* the Sentinel and its tracked components and topology will be operating with a
* vertex after the tetrahedralization has occurred. Consequently operations on
* Vertex and Tetrahedron are the defacto operation origination rather at the
* Sentinel level.
* the Grid and its tracked components and topology will be operating with a
* vertex after the tetrahedralization has occurred. Consequently, operations on
* Vertex and Tetrahedron are the de facto operation origination rather at the
* Grid level.
*
* @author <a href="mailto:hal.hildebrand@gmail.com">Hal Hildebrand</a>
*/
Expand All @@ -63,26 +52,42 @@ public class Grid implements Iterable<Vertex> {
/**
* Cannonical enumeration of the vertex ordinals
*/
public static final V[] VERTICES = { A, B, C, D };
public static final V[] VERTICES = { A, B, C, D };
/**
* A pre-built table of all the permutations of remaining faces to check in
* location.
*/
protected static final V[][][] ORDER = new V[][][] { { { B, C, D }, { C, B, D }, { C, D, B }, { B, D, C },
{ D, B, C }, { D, C, B } },
protected static final V[][][] ORDER = new V[][][] {
{ { B, C, D }, { C, B, D }, { C, D, B }, { B, D, C }, { D, B, C }, { D, C, B } },

{ { A, C, D }, { C, A, D }, { C, D, A }, { A, D, C },
{ D, A, C }, { D, C, A } },
{ { A, C, D }, { C, A, D }, { C, D, A }, { A, D, C }, { D, A, C }, { D, C, A } },

{ { B, A, D }, { A, B, D }, { A, D, B }, { B, D, A },
{ D, B, A }, { D, A, B } },
{ { B, A, D }, { A, B, D }, { A, D, B }, { B, D, A }, { D, B, A }, { D, A, B } },

{ { B, C, A }, { C, B, A }, { C, A, B }, { B, A, C },
{ A, B, C }, { A, C, B } } };
{ { B, C, A }, { C, B, A }, { C, A, B }, { B, A, C }, { A, B, C }, { A, C, B } } };
/**
* Scale of the universe
*/
private static float SCALE = (float) Math.pow(2, 16);
private static float SCALE = (float) Math.pow(2, 16);
/**
* The four corners of the maximally bounding tetrahedron
*/
protected final Vertex[] fourCorners;
/**
* the Head of the vertices list
*/
protected Vertex head;
/**
* The number of points in this Grid
*/
protected int size = 0;
Grid(Vertex[] fourCorners) {
this.fourCorners = fourCorners;
}
Grid(Vertex[] fourCorners, Vertex head) {
this(fourCorners);
this.head = head;
}

public static Vertex[] getFourCorners() {
Vertex[] fourCorners = new Vertex[4];
Expand All @@ -107,28 +112,6 @@ public static Tetrahedron myOwnPrivateIdaho(Grid s) {
return new Tetrahedron(U);
}

/**
* The four corners of the maximally bounding tetrahedron
*/
protected final Vertex[] fourCorners;
/**
* the Head of the vertices list
*/
protected Vertex head;
/**
* The number of points in this Grid
*/
protected int size = 0;

Grid(Vertex[] fourCorners) {
this.fourCorners = fourCorners;
}

Grid(Vertex[] fourCorners, Vertex head) {
this(fourCorners);
this.head = head;
}

/**
* Answer the four corners of the universe
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
/**
* Copyright (C) 2023 Hal Hildebrand. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.hellblazer.luciferase.lucien.grid;

import java.util.Random;

import javax.vecmath.Tuple3f;
import java.util.Random;

/**
* @author hal.hildebrand
*/
public class GridLocator {
private Tetrahedron last;

public GridLocator(Tetrahedron initial) {
last = initial;
}

/**
* Locate the tetrahedron which contains the query point via a stochastic walk
* through the delaunay triangulation. This location algorithm is a slight
* variation of the 3D jump and walk algorithm found in: "Fast randomized point
* location without preprocessing in two- and three-dimensional Delaunay
* triangulations", Computational Geometry 12 (1999) 63-83.
* Locate the tetrahedron which contains the query point via a stochastic walk through the delaunay triangulation.
* This location algorithm is a slight variation of the 3D jump and walk algorithm found in: "Fast randomized point
* location without preprocessing in two- and three-dimensional Delaunay triangulations", Computational Geometry 12
* (1999) 63-83. z
*
* @param query - the query point
* @return the Tetrahedron containing the query
*/
public Tetrahedron locate(Tuple3f query, Random entropy) {
return last.locate(query, entropy);
return last = last.locate(query, entropy);
}
}
Loading

0 comments on commit c3ef8e1

Please sign in to comment.