From 7897422d15a84737970ed8838e6483ade79f900d Mon Sep 17 00:00:00 2001
From: Thomas <thomas.musset@pasteur.fr>
Date: Mon, 3 Feb 2025 15:35:57 +0100
Subject: [PATCH] updated to v2.0.0-a.2, updated to Java 23, clean some classes

---
 pom.xml                                       |  11 +---
 .../java/plugins/adufour/quickhull/Face.java  |   7 ++-
 .../plugins/adufour/quickhull/FaceList.java   |   2 +-
 .../plugins/adufour/quickhull/HalfEdge.java   |   2 +-
 .../plugins/adufour/quickhull/QuickHull.java  |   9 ++-
 .../adufour/quickhull/QuickHull2D.java        |   4 +-
 .../adufour/quickhull/QuickHull3D.java        |  58 +++++++++++-------
 .../plugins/adufour/quickhull/Vertex.java     |   3 +-
 .../plugins/adufour/quickhull/VertexList.java |   2 +-
 .../adufour/quickhull}/quickhull.png          | Bin
 10 files changed, 52 insertions(+), 46 deletions(-)
 rename src/main/resources/{ => plugins/adufour/quickhull}/quickhull.png (100%)

diff --git a/pom.xml b/pom.xml
index b3cfb94..0834e88 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,11 +7,11 @@
     <parent>
         <groupId>org.bioimageanalysis.icy</groupId>
         <artifactId>pom-icy</artifactId>
-        <version>3.0.0-a.1</version>
+        <version>3.0.0-a.3</version>
     </parent>
 
     <artifactId>quickhull</artifactId>
-    <version>2.0.0-a.1</version>
+    <version>2.0.0-a.2</version>
 
     <name>QuickHull</name>
     <description>
@@ -24,11 +24,4 @@
             <artifactId>vecmath</artifactId>
         </dependency>
     </dependencies>
-
-    <repositories>
-        <repository>
-            <id>icy</id>
-            <url>https://nexus-icy.pasteur.cloud/repository/icy/</url>
-        </repository>
-    </repositories>
 </project>
\ No newline at end of file
diff --git a/src/main/java/plugins/adufour/quickhull/Face.java b/src/main/java/plugins/adufour/quickhull/Face.java
index 2afe11a..91d9b5a 100644
--- a/src/main/java/plugins/adufour/quickhull/Face.java
+++ b/src/main/java/plugins/adufour/quickhull/Face.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2024. Institut Pasteur.
+ * Copyright (c) 2010-2025. Institut Pasteur.
  *
  * This file is part of Icy.
  * Icy is free software: you can redistribute it and/or modify
@@ -18,6 +18,7 @@
 
 package plugins.adufour.quickhull;
 
+import org.bioimageanalysis.icy.system.logging.IcyLogger;
 import org.jetbrains.annotations.NotNull;
 
 import javax.vecmath.Vector3d;
@@ -65,7 +66,7 @@ public class Face {
         computeNormal(normal);
 
         if (area < minArea) {
-            System.out.println("area=" + area);
+            IcyLogger.debug(this.getClass(), "area=" + area);
             // make the normal more robust by removing
             // components parallel to the longest edge
 
@@ -288,7 +289,7 @@ public class Face {
         final StringBuilder s = new StringBuilder();
         HalfEdge he = he0;
         do {
-            if (s.length() == 0) {
+            if (s.isEmpty()) {
                 s.append(he.head().index);
             }
             else {
diff --git a/src/main/java/plugins/adufour/quickhull/FaceList.java b/src/main/java/plugins/adufour/quickhull/FaceList.java
index be6d7b2..fac5a90 100644
--- a/src/main/java/plugins/adufour/quickhull/FaceList.java
+++ b/src/main/java/plugins/adufour/quickhull/FaceList.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2024. Institut Pasteur.
+ * Copyright (c) 2010-2025. Institut Pasteur.
  *
  * This file is part of Icy.
  * Icy is free software: you can redistribute it and/or modify
diff --git a/src/main/java/plugins/adufour/quickhull/HalfEdge.java b/src/main/java/plugins/adufour/quickhull/HalfEdge.java
index e31d21e..1d4c128 100644
--- a/src/main/java/plugins/adufour/quickhull/HalfEdge.java
+++ b/src/main/java/plugins/adufour/quickhull/HalfEdge.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2024. Institut Pasteur.
+ * Copyright (c) 2010-2025. Institut Pasteur.
  *
  * This file is part of Icy.
  * Icy is free software: you can redistribute it and/or modify
diff --git a/src/main/java/plugins/adufour/quickhull/QuickHull.java b/src/main/java/plugins/adufour/quickhull/QuickHull.java
index 5277b47..a15438b 100644
--- a/src/main/java/plugins/adufour/quickhull/QuickHull.java
+++ b/src/main/java/plugins/adufour/quickhull/QuickHull.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2024. Institut Pasteur.
+ * Copyright (c) 2010-2025. Institut Pasteur.
  *
  * This file is part of Icy.
  * Icy is free software: you can redistribute it and/or modify
@@ -21,7 +21,6 @@ package plugins.adufour.quickhull;
 import org.bioimageanalysis.icy.extension.plugin.abstract_.Plugin;
 import org.bioimageanalysis.icy.extension.plugin.annotation_.IcyPluginIcon;
 import org.bioimageanalysis.icy.extension.plugin.annotation_.IcyPluginName;
-import org.bioimageanalysis.icy.extension.plugin.interface_.PluginLibrary;
 
 /**
  * Main class of the QuickHull library for Icy
@@ -32,7 +31,7 @@ import org.bioimageanalysis.icy.extension.plugin.interface_.PluginLibrary;
  * @author Alexandre Dufour
  */
 @IcyPluginName("QuickHull")
-@IcyPluginIcon(path = "/quickhull.png")
-public class QuickHull extends Plugin implements PluginLibrary {
-
+@IcyPluginIcon(path = "/plugins/adufour/quickhull/quickhull.png")
+public class QuickHull extends Plugin {
+    //
 }
diff --git a/src/main/java/plugins/adufour/quickhull/QuickHull2D.java b/src/main/java/plugins/adufour/quickhull/QuickHull2D.java
index df97cf9..290935a 100644
--- a/src/main/java/plugins/adufour/quickhull/QuickHull2D.java
+++ b/src/main/java/plugins/adufour/quickhull/QuickHull2D.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2024. Institut Pasteur.
+ * Copyright (c) 2010-2025. Institut Pasteur.
  *
  * This file is part of Icy.
  * Icy is free software: you can redistribute it and/or modify
@@ -19,6 +19,7 @@
 package plugins.adufour.quickhull;
 
 import org.bioimageanalysis.icy.extension.plugin.abstract_.Plugin;
+import org.bioimageanalysis.icy.extension.plugin.annotation_.IcyPluginIcon;
 import org.bioimageanalysis.icy.extension.plugin.annotation_.IcyPluginName;
 import org.jetbrains.annotations.NotNull;
 
@@ -28,6 +29,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 @IcyPluginName("QuickHull 2D")
+@IcyPluginIcon(path = "/plugins/adufour/quickhull/quickhull.png")
 public class QuickHull2D extends Plugin {
     public static @NotNull List<Point2D> computeConvexEnvelope(final @NotNull List<Point2D> points) {
         final ArrayList<Point2D> envelope = new ArrayList<>();
diff --git a/src/main/java/plugins/adufour/quickhull/QuickHull3D.java b/src/main/java/plugins/adufour/quickhull/QuickHull3D.java
index d370f79..8ede2f6 100644
--- a/src/main/java/plugins/adufour/quickhull/QuickHull3D.java
+++ b/src/main/java/plugins/adufour/quickhull/QuickHull3D.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2024. Institut Pasteur.
+ * Copyright (c) 2010-2025. Institut Pasteur.
  *
  * This file is part of Icy.
  * Icy is free software: you can redistribute it and/or modify
@@ -15,6 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with Icy. If not, see <https://www.gnu.org/licenses/>.
  */
+
 package plugins.adufour.quickhull;
 
 import org.bioimageanalysis.icy.system.logging.IcyLogger;
@@ -339,12 +340,14 @@ public class QuickHull3D {
     }
 
     protected void setFromQhull(final double[] coords, final int nump, final boolean triangulate) {
-        String commandStr = "./qhull i";
-        if (triangulate) {
-            commandStr += " -Qt";
-        }
+        final String[] commandStr;
+        if (triangulate)
+            commandStr = new String[]{"./qhull", "i", "-Qt"};
+        else
+            commandStr = new String[]{"./qhull", "i"};
+
         try {
-            final Process proc = Runtime.getRuntime().exec(commandStr); // FIXME change command from String to String[]
+            final Process proc = Runtime.getRuntime().exec(commandStr);
             final PrintStream ps = new PrintStream(proc.getOutputStream());
             final StreamTokenizer stok = new StreamTokenizer(new InputStreamReader(proc.getInputStream()));
 
@@ -365,8 +368,8 @@ public class QuickHull3D {
                 stok.nextToken();
             }
             if (stok.ttype != StreamTokenizer.TT_NUMBER) {
-                System.out.println("Expecting number of faces");
-                System.exit(1);
+                IcyLogger.fatal(this.getClass(), "Expecting number of faces");
+                System.exit(1); // TODO replace with runtime exception ?
             }
             final int numf = (int) stok.nval;
             stok.nextToken(); // clear EOL
@@ -375,8 +378,8 @@ public class QuickHull3D {
                 indexList.clear();
                 while (stok.nextToken() != StreamTokenizer.TT_EOL) {
                     if (stok.ttype != StreamTokenizer.TT_NUMBER) {
-                        System.out.println("Expecting face index");
-                        System.exit(1);
+                        IcyLogger.fatal(this.getClass(), "Expecting face index");
+                        System.exit(1); // TODO replace with runtime exception ?
                     }
                     indexList.addFirst((int) stok.nval);
                 }
@@ -655,11 +658,19 @@ public class QuickHull3D {
         }
 
         if (debug) {
-            System.out.println("initial vertices:");
+            IcyLogger.debug(
+                    this.getClass(),
+                    "initial vertices:",
+                    vtx[0].index + ": " + vtx[0].pnt,
+                    vtx[1].index + ": " + vtx[1].pnt,
+                    vtx[2].index + ": " + vtx[2].pnt,
+                    vtx[3].index + ": " + vtx[3].pnt
+            );
+            /*System.out.println("initial vertices:");
             System.out.println(vtx[0].index + ": " + vtx[0].pnt);
             System.out.println(vtx[1].index + ": " + vtx[1].pnt);
             System.out.println(vtx[2].index + ": " + vtx[2].pnt);
-            System.out.println(vtx[3].index + ": " + vtx[3].pnt);
+            System.out.println(vtx[3].index + ": " + vtx[3].pnt);*/
         }
 
         final Face[] tris = new Face[4];
@@ -925,12 +936,12 @@ public class QuickHull3D {
             if (maxFace != null) {
                 addPointToFace(vtx, maxFace);
                 if (debug && vtx.index == findIndex) {
-                    System.out.println(findIndex + " CLAIMED BY " + maxFace.getVertexString());
+                    IcyLogger.debug(this.getClass(), findIndex + " CLAIMED BY " + maxFace.getVertexString());
                 }
             }
             else {
                 if (debug && vtx.index == findIndex) {
-                    System.out.println(findIndex + " DISCARDED");
+                    IcyLogger.debug(this.getClass(), findIndex + " DISCARDED");
                 }
             }
         }
@@ -1003,7 +1014,7 @@ public class QuickHull3D {
 
             if (merge) {
                 if (debug) {
-                    System.out.println("  merging " + face.getVertexString() + "  and  " + oppFace.getVertexString());
+                    IcyLogger.debug(this.getClass(), "  merging " + face.getVertexString() + "  and  " + oppFace.getVertexString());
                 }
 
                 final int numd = face.mergeAdjacentFace(hedge, discardedFaces);
@@ -1011,7 +1022,7 @@ public class QuickHull3D {
                     deleteFacePoints(discardedFaces[i], face);
                 }
                 if (debug) {
-                    System.out.println("  result: " + face.getVertexString());
+                    IcyLogger.debug(this.getClass(), "  result: " + face.getVertexString());
                 }
                 return true;
             }
@@ -1028,7 +1039,7 @@ public class QuickHull3D {
         deleteFacePoints(face, null);
         face.mark = Face.DELETED;
         if (debug) {
-            System.out.println("  visiting face " + face.getVertexString());
+            IcyLogger.debug(this.getClass(), "  visiting face " + face.getVertexString());
         }
         HalfEdge edge;
         if (edge0 == null) {
@@ -1047,7 +1058,7 @@ public class QuickHull3D {
                 else {
                     horizon.add(edge);
                     if (debug) {
-                        System.out.println("  adding horizon edge " + edge.getVertexString());
+                        IcyLogger.debug(this.getClass(), "  adding horizon edge " + edge.getVertexString());
                     }
                 }
             }
@@ -1071,7 +1082,7 @@ public class QuickHull3D {
         for (final HalfEdge horizonHe : horizon) {
             final HalfEdge hedgeSide = addAdjoiningFace(eyeVtx, horizonHe);
             if (debug) {
-                System.out.println("new face: " + hedgeSide.face.getVertexString());
+                IcyLogger.debug(this.getClass(), "new face: " + hedgeSide.face.getVertexString());
             }
             if (hedgeSidePrev != null) {
                 hedgeSide.next.setOpposite(hedgeSidePrev);
@@ -1105,13 +1116,14 @@ public class QuickHull3D {
         }
     }
 
+    @SuppressWarnings("StatementWithEmptyBody")
     protected void addPointToHull(final Vertex eyeVtx) {
         horizon.clear();
         unclaimed.clear();
 
         if (debug) {
-            System.out.println("Adding point: " + eyeVtx.index);
-            System.out.println(" which is " + eyeVtx.face.distanceToPlane(eyeVtx.pnt) + " above face " + eyeVtx.face.getVertexString());
+            IcyLogger.debug(this.getClass(), "Adding point: " + eyeVtx.index);
+            IcyLogger.debug(this.getClass(), " which is " + eyeVtx.face.distanceToPlane(eyeVtx.pnt) + " above face " + eyeVtx.face.getVertexString());
         }
         removePointFromFace(eyeVtx, eyeVtx.face);
         calculateHorizon(eyeVtx.pnt, null, eyeVtx.face, horizon);
@@ -1149,12 +1161,12 @@ public class QuickHull3D {
             addPointToHull(eyeVtx);
             cnt++;
             if (debug) {
-                System.out.println("iteration " + cnt + " done");
+                IcyLogger.debug(this.getClass(), "iteration " + cnt + " done");
             }
         }
         reindexFacesAndVertices();
         if (debug) {
-            System.out.println("hull done");
+            IcyLogger.debug(this.getClass(), "hull done");
         }
     }
 
diff --git a/src/main/java/plugins/adufour/quickhull/Vertex.java b/src/main/java/plugins/adufour/quickhull/Vertex.java
index cdbbfc3..d49d98c 100644
--- a/src/main/java/plugins/adufour/quickhull/Vertex.java
+++ b/src/main/java/plugins/adufour/quickhull/Vertex.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2024. Institut Pasteur.
+ * Copyright (c) 2010-2025. Institut Pasteur.
  *
  * This file is part of Icy.
  * Icy is free software: you can redistribute it and/or modify
@@ -71,5 +71,4 @@ public class Vertex {
         pnt = new Vector3d(x, y, z);
         index = idx;
     }
-
 }
diff --git a/src/main/java/plugins/adufour/quickhull/VertexList.java b/src/main/java/plugins/adufour/quickhull/VertexList.java
index 2b6816f..5237c56 100644
--- a/src/main/java/plugins/adufour/quickhull/VertexList.java
+++ b/src/main/java/plugins/adufour/quickhull/VertexList.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2024. Institut Pasteur.
+ * Copyright (c) 2010-2025. Institut Pasteur.
  *
  * This file is part of Icy.
  * Icy is free software: you can redistribute it and/or modify
diff --git a/src/main/resources/quickhull.png b/src/main/resources/plugins/adufour/quickhull/quickhull.png
similarity index 100%
rename from src/main/resources/quickhull.png
rename to src/main/resources/plugins/adufour/quickhull/quickhull.png
-- 
GitLab