From 2c29f7b6129697dc14e6bd2493cc48fc6badcaf9 Mon Sep 17 00:00:00 2001
From: Radek Oslejsek <oslejsek@fi.muni.cz>
Date: Mon, 5 Apr 2021 09:17:45 +0200
Subject: [PATCH] Final refactoring of testing app

---
 .../analyst/tests/CurvatureTests.java         | 157 --------------
 .../analyst/tests/EfficiencyTests.java        |  39 ++--
 ...ventListener.java => HeatMapsTestApp.java} | 195 ++++++++++++++----
 3 files changed, 180 insertions(+), 211 deletions(-)
 delete mode 100644 GUI/src/main/java/cz/fidentis/analyst/tests/CurvatureTests.java
 rename GUI/src/main/java/cz/fidentis/analyst/tests/{HeatMapGLEventListener.java => HeatMapsTestApp.java} (57%)

diff --git a/GUI/src/main/java/cz/fidentis/analyst/tests/CurvatureTests.java b/GUI/src/main/java/cz/fidentis/analyst/tests/CurvatureTests.java
deleted file mode 100644
index dfd7e0cd..00000000
--- a/GUI/src/main/java/cz/fidentis/analyst/tests/CurvatureTests.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package cz.fidentis.analyst.tests;
-
-import cz.fidentis.analyst.face.HumanFace;
-import cz.fidentis.analyst.gui.Canvas;
-import cz.fidentis.analyst.gui.ComparisonGLEventListener;
-import cz.fidentis.analyst.mesh.core.MeshPoint;
-import cz.fidentis.analyst.mesh.io.ModelFileFilter;
-import cz.fidentis.analyst.visitors.mesh.Curvature;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import javax.swing.JButton;
-import javax.swing.JColorChooser;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.vecmath.Vector3d;
-
-/**
- * A class for testing curvature algorithms.
- * 
- * @author radek oslejsek
- */
-public class CurvatureTests {
-    
-    private static final JFrame testFrame = new JFrame();
-
-    private static final File faceFile2 = new File("src/test/resources/cz/fidentis/analyst/00002_01_ECA.obj");
-    private static final File girlFile = new File("src/test/resources/cz/fidentis/analyst/average_girl_17-20.obj");
-    private static final File boyFile = new File("src/test/resources/cz/fidentis/analyst/average_boy_17-20.obj");
-    
-    /**
-     * Main method 
-     * @param args Input arguments 
-     * @throws IOException on IO error
-     */
-    public static void main(String[] args) throws IOException {
-        HumanFace face = new HumanFace(girlFile);
-        //HumanFace face = new HumanFace(faceFile2);
-        
-        System.out.println("MODEL: " + face.getMeshModel());
-        
-        Set<MeshPoint> uniqueVerts = new HashSet<>(face.getMeshModel().getFacets().get(0).getVertices());
-        System.out.println("UNIQUE VERTICES: " + uniqueVerts.size());
-        Set<Vector3d> unique2 = new HashSet<>();
-        for (MeshPoint p: face.getMeshModel().getFacets().get(0).getVertices()) {
-            unique2.add(p.getPosition());
-        }
-        //System.out.println("UNIQUE VERTICES: " + unique2.size());
-        //for (Vector3d v: unique2) {
-        //    for (MeshPoint p: uniqueVerts) {
-        //        if (v.equals(p.getPosition())) {
-        //            System.out.println(p);
-        //        }
-        //    }
-        //    System.out.println("----------------");
-        //}
-        
-        boolean print = true;
-        
-        System.out.println();
-        System.out.println("Curvature calculation:");
-        System.out.println(measureCurvature(face, print) + "\tmsec:\tCurvature");
-        System.out.println();
-        
-        createGUI();
-    }
-    
-    private static long measureCurvature(HumanFace face, boolean printDetails) {
-        Curvature vis = new Curvature();
-        long startTime = System.currentTimeMillis();
-        face.getMeshModel().compute(vis);
-        long retTime =  System.currentTimeMillis() - startTime;
-        
-        if (printDetails) {
-            List<Double> distanceList = vis.getGaussianCurvatures().get(face.getMeshModel().getFacets().get(0));
-            Double minDistance = distanceList.stream().mapToDouble(Double::doubleValue).min().getAsDouble();
-            Double maxDistance = distanceList.stream().mapToDouble(Double::doubleValue).max().getAsDouble();
-            System.out.println("Gaus min-max: " + minDistance + " .. " + maxDistance);
-            
-            distanceList = vis.getMeanCurvatures().get(face.getMeshModel().getFacets().get(0));
-            minDistance = distanceList.stream().mapToDouble(Double::doubleValue).min().getAsDouble();
-            maxDistance = distanceList.stream().mapToDouble(Double::doubleValue).max().getAsDouble();
-            System.out.println("Mean min-max: " + minDistance + " .. " + maxDistance);
-        }
-        
-        return retTime;
-    }
-    
-    
-    private static void createGUI() throws IOException {
-        //Declaration
-        JButton gaussButton = new JButton("Show Gaussian curvature");
-        JButton meanButton = new JButton("Show mean curvature");
-        JButton maxButton = new JButton("Show maximum principal curvature");
-        JButton minButton = new JButton("Show minimum principal curvature");
-        JButton hdButton1 = new JButton("Show Hausdorff distance to average boy - p2p abosult");
-        JButton hdButton2 = new JButton("Show Hausdorff distance to average boy - p2p relative");
-
-        Canvas testCanvas = new Canvas();
-        HeatMapGLEventListener colorListener = new HeatMapGLEventListener(testCanvas);
-        testCanvas.setListener(colorListener);
-        
-        gaussButton.addActionListener(e -> colorListener.drawGaussian());
-        meanButton.addActionListener(e -> colorListener.drawMean());
-        maxButton.addActionListener(e -> colorListener.drawMaxPrincipal());
-        minButton.addActionListener(e -> colorListener.drawMinPrincipal());
-        hdButton1.addActionListener(e -> colorListener.drawHausdorffDistanceP2pAbs());
-        hdButton2.addActionListener(e -> colorListener.drawHausdorffDistanceP2pRel());
-
-        testFrame.setLayout(new GridBagLayout());
-        testFrame.setVisible(true);
-        testFrame.setSize(1600, 900);
-
-        // Adding
-        GridBagConstraints c = new GridBagConstraints();
-        c.fill = GridBagConstraints.BOTH;
-        c.gridx = 0;
-        c.gridy = 0;
-        c.weighty = 1;
-        c.weightx = 1;
-
-        c.gridheight = 6;
-        c.gridwidth = 4;
-        c.weightx = 4;
-        testFrame.add(testCanvas, c);
-        c.gridheight = 1;
-        c.gridwidth = 2;
-        c.gridx = 4;
-        c.weightx = 2;
-        //testFrame.add(addButton, c);
-        c.gridy = 1;
-        testFrame.add(gaussButton, c);
-        c.gridy = 2;
-        testFrame.add(meanButton, c);
-        c.gridy = 3;
-        testFrame.add(maxButton, c);
-        c.gridy = 4;
-        testFrame.add(minButton, c);
-        c.gridy = 5;
-        testFrame.add(hdButton1, c);
-        c.gridy = 6;
-        testFrame.add(hdButton2, c);
-        //c.gridwidth = 1;
-        //c.weightx = 1;
-        //testFrame.add(color1, c);
-        //c.gridx = 5;
-        //testFrame.add(color2, c);
-
-    }
-    
-}
diff --git a/GUI/src/main/java/cz/fidentis/analyst/tests/EfficiencyTests.java b/GUI/src/main/java/cz/fidentis/analyst/tests/EfficiencyTests.java
index de5d222f..64a50054 100644
--- a/GUI/src/main/java/cz/fidentis/analyst/tests/EfficiencyTests.java
+++ b/GUI/src/main/java/cz/fidentis/analyst/tests/EfficiencyTests.java
@@ -36,35 +36,36 @@ public class EfficiencyTests {
      * @throws IOException on IO error
      */
     public static void main(String[] args) throws IOException {
-        face1 = new HumanFace(faceFile2);
-        face2 = new HumanFace(faceFile4);
+        face1 = new HumanFace(girlFile);
+        face2 = new HumanFace(boyFile);
         
         boolean relativeDist = false;
-        boolean printDetails = false;
+        boolean printDetails = true;
         
         //face1.getMeshModel().compute(new GaussianCurvature()); // initialize everything, then measure
         
-        System.out.println("Symmetry plane calculation:");
-        printSymmetryPlane(face1, true, SignificantPoints.CurvatureAlg.MEAN);
-        printSymmetryPlane(face1, true, SignificantPoints.CurvatureAlg.GAUSSIAN);
-        printSymmetryPlane(face1, false, SignificantPoints.CurvatureAlg.MEAN);
-        printSymmetryPlane(face1, false, SignificantPoints.CurvatureAlg.GAUSSIAN);
+        //System.out.println("Symmetry plane calculation:");
+        //printSymmetryPlane(face1, true, SignificantPoints.CurvatureAlg.MEAN);
+        //printSymmetryPlane(face1, true, SignificantPoints.CurvatureAlg.GAUSSIAN);
+        //printSymmetryPlane(face1, false, SignificantPoints.CurvatureAlg.MEAN);
+        //printSymmetryPlane(face1, false, SignificantPoints.CurvatureAlg.GAUSSIAN);
         
-        System.out.println();
-        System.out.println(measureKdTreeCreation(face1) + "\tmsec:\tKd-tree creation of first face");
-        System.out.println(measureKdTreeCreation(face2) + "\tmsec:\tKd-tree creation of second face");
+        //System.out.println();
+        //System.out.println(measureKdTreeCreation(face1) + "\tmsec:\tKd-tree creation of first face");
+        //System.out.println(measureKdTreeCreation(face2) + "\tmsec:\tKd-tree creation of second face");
         
         System.out.println();
         System.out.println("Hausdorff distance sequentially:");
-        testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_POINT_DISTANCE_ONLY, false, false), printDetails);
-        testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_POINT, relativeDist, false), printDetails);
-        testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_TRIANGLE_APPROXIMATE, relativeDist, false), printDetails);
+        testAndPrint(face2, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_POINT, relativeDist, false), printDetails);
+        //testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_POINT_DISTANCE_ONLY, false, false), printDetails);
+        //testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_POINT, relativeDist, false), printDetails);
+        //testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_TRIANGLE_APPROXIMATE, relativeDist, false), printDetails);
 
-        System.out.println();
-        System.out.println("Hausdorff distance concurrently:");
-        testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_POINT_DISTANCE_ONLY, false, true), printDetails);
-        testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_POINT, relativeDist, true), printDetails);
-        testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_TRIANGLE_APPROXIMATE, relativeDist, true), printDetails);
+        //System.out.println();
+        //System.out.println("Hausdorff distance concurrently:");
+        //testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_POINT_DISTANCE_ONLY, false, true), printDetails);
+        //testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_POINT, relativeDist, true), printDetails);
+        //testAndPrint(face1, new HausdorffDistance(face2.getMeshModel(), Strategy.POINT_TO_TRIANGLE_APPROXIMATE, relativeDist, true), printDetails);
     }
     
     protected static void testAndPrint(HumanFace face, HausdorffDistance vis, boolean printDetails) {
diff --git a/GUI/src/main/java/cz/fidentis/analyst/tests/HeatMapGLEventListener.java b/GUI/src/main/java/cz/fidentis/analyst/tests/HeatMapsTestApp.java
similarity index 57%
rename from GUI/src/main/java/cz/fidentis/analyst/tests/HeatMapGLEventListener.java
rename to GUI/src/main/java/cz/fidentis/analyst/tests/HeatMapsTestApp.java
index 4f622e30..1a95ee80 100644
--- a/GUI/src/main/java/cz/fidentis/analyst/tests/HeatMapGLEventListener.java
+++ b/GUI/src/main/java/cz/fidentis/analyst/tests/HeatMapsTestApp.java
@@ -8,7 +8,6 @@ import cz.fidentis.analyst.mesh.core.MeshFacet;
 import cz.fidentis.analyst.mesh.core.MeshModel;
 
 import javax.vecmath.Vector3d;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -20,19 +19,30 @@ import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_MODELVIEW_MATRIX;
 import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_PROJECTION_MATRIX;
 import cz.fidentis.analyst.gui.Canvas;
 import cz.fidentis.analyst.gui.GeneralGLEventListener;
+import cz.fidentis.analyst.mesh.core.MeshPoint;
 import cz.fidentis.analyst.visitors.mesh.Curvature;
 import cz.fidentis.analyst.visitors.mesh.HausdorffDistance;
 import cz.fidentis.analyst.visitors.mesh.HausdorffDistance.Strategy;
 import java.awt.Color;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
 import java.io.File;
 import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+import javax.swing.JButton;
+import javax.swing.JFrame;
 import org.openide.util.Exceptions;
 
 /**
+ * Testing application displaying different heat maps in 3D.
  * 
- * @author radek oslejsek
+ * @author Daniel Sokol
+ * @author Radek Oslejsek
  */
-public class HeatMapGLEventListener extends GeneralGLEventListener {
+public class HeatMapsTestApp extends GeneralGLEventListener {
+    
+    private static final JFrame TEST_FRAME = new JFrame();
     
     private Map<MeshFacet, List<Double>> values;
     private final Color minColor = Color.BLUE;
@@ -41,77 +51,193 @@ public class HeatMapGLEventListener extends GeneralGLEventListener {
     private double minDistance;
     private double maxDistance;
 
-
-    public HeatMapGLEventListener(Canvas canvas) {
+    
+    /**
+     * Constructor.
+     * @param canvas Canvas
+     */
+    public HeatMapsTestApp(Canvas canvas) {
         super(canvas);
     }
+    
+    /**
+     * Main method 
+     * @param args Input arguments 
+     * @throws IOException on IO error
+     */
+    public static void main(String[] args) {
+        //Declaration
+        JButton gaussButton = new JButton("Show Gaussian curvature");
+        JButton meanButton = new JButton("Show mean curvature");
+        JButton maxButton = new JButton("Show maximum principal curvature");
+        JButton minButton = new JButton("Show minimum principal curvature");
+        JButton hdButton1 = new JButton("Show Hausdorff distance to average boy - p2p abosult");
+        JButton hdButton2 = new JButton("Show Hausdorff distance to average boy - p2p relative");
+
+        Canvas testCanvas = new Canvas();
+        HeatMapsTestApp colorListener = new HeatMapsTestApp(testCanvas);
+        testCanvas.setListener(colorListener);
+        
+        gaussButton.addActionListener(e -> colorListener.computeGaussian());
+        meanButton.addActionListener(e -> colorListener.computeMean());
+        maxButton.addActionListener(e -> colorListener.computeMaxPrincipal());
+        minButton.addActionListener(e -> colorListener.computeMinPrincipal());
+        hdButton1.addActionListener(e -> colorListener.computeHausdorffDistanceP2pAbs());
+        hdButton2.addActionListener(e -> colorListener.computeHausdorffDistanceP2pRel());
+
+        TEST_FRAME.setLayout(new GridBagLayout());
+        TEST_FRAME.setVisible(true);
+        TEST_FRAME.setSize(1600, 900);
+
+        // Adding
+        GridBagConstraints c = new GridBagConstraints();
+        c.fill = GridBagConstraints.BOTH;
+        c.gridx = 0;
+        c.gridy = 0;
+        c.weighty = 1;
+        c.weightx = 1;
 
-    public void drawGaussian() {
+        c.gridheight = 6;
+        c.gridwidth = 4;
+        c.weightx = 4;
+        TEST_FRAME.add(testCanvas, c);
+        c.gridheight = 1;
+        c.gridwidth = 2;
+        c.gridx = 4;
+        c.weightx = 2;
+        //testFrame.add(addButton, c);
+        c.gridy = 1;
+        TEST_FRAME.add(gaussButton, c);
+        c.gridy = 2;
+        TEST_FRAME.add(meanButton, c);
+        c.gridy = 3;
+        TEST_FRAME.add(maxButton, c);
+        c.gridy = 4;
+        TEST_FRAME.add(minButton, c);
+        c.gridy = 5;
+        TEST_FRAME.add(hdButton1, c);
+        c.gridy = 6;
+        TEST_FRAME.add(hdButton2, c);
+    }
+    
+    @Override
+    public void setModel(MeshModel model) {
+        super.setModel(model);
+        
+        System.err.println();
+        System.err.println("MODEL: " + getModel());
+        
+        Set<MeshPoint> uniqueVerts = new HashSet<>(getModel().getFacets().get(0).getVertices());
+        System.err.println("UNIQUE VERTICES: " + uniqueVerts.size());
+        
+        /*
+        Set<Vector3d> unique2 = new HashSet<>();
+        for (MeshPoint p: getModel().getFacets().get(0).getVertices()) {
+            unique2.add(p.getPosition());
+        }
+        System.out.println("UNIQUE VERTICES: " + unique2.size());
+        for (Vector3d v: unique2) {
+            for (MeshPoint p: uniqueVerts) {
+                if (v.equals(p.getPosition())) {
+                    System.out.println(p);
+                }
+            }
+            System.out.println("----------------");
+        }
+        */
+    }
+
+    /**
+     * Computes curvature
+     */
+    public void computeGaussian() {
         if (this.getModel() == null) {
             return;
         }
+        
+        long startTime = System.currentTimeMillis();
         Curvature vis = new Curvature();
         this.getModel().compute(vis);
         values = vis.getGaussianCurvatures();
+        long duration =  System.currentTimeMillis() - startTime;
+        System.err.println(duration + "\tmsec: Gaussian curvature");
+        
         minDistance = -0.02;
         maxDistance = 0.008;
-        //List<Double> distanceList = values.get(getModel().getFacets().get(0));
-        //minDistance = distanceList.stream().mapToDouble(Double::doubleValue).min().getAsDouble();
-        //maxDistance = distanceList.stream().mapToDouble(Double::doubleValue).max().getAsDouble();
     }
     
-    public void drawMean() {
+    /**
+     * Computes curvature
+     */
+    public void computeMean() {
         if (this.getModel() == null) {
             return;
         }
+        
+        long startTime = System.currentTimeMillis();
         Curvature vis = new Curvature();
         this.getModel().compute(vis);
         values = vis.getMeanCurvatures();
+        long duration =  System.currentTimeMillis() - startTime;
+        System.err.println(duration + "\tmsec: Mean curvature");
+        
         minDistance = 0.0;
         maxDistance = 2.0;
-        //List<Double> distanceList = values.get(getModel().getFacets().get(0));
-        //minDistance = distanceList.stream().mapToDouble(Double::doubleValue).min().getAsDouble();
-        //maxDistance = distanceList.stream().mapToDouble(Double::doubleValue).max().getAsDouble();
     }
     
-    public void drawMinPrincipal() {
+    /**
+     * Computes curvature
+     */
+    public void computeMinPrincipal() {
         if (this.getModel() == null) {
             return;
         }
+        
+        long startTime = System.currentTimeMillis();
         Curvature vis = new Curvature();
         this.getModel().compute(vis);
         values = vis.getMinPrincipalCurvatures();
+        long duration =  System.currentTimeMillis() - startTime;
+        System.err.println(duration + "\tmsec: Minimum principal curvature");
+        
         minDistance = -0.03;
         maxDistance = 0.05;
-        //List<Double> distanceList = values.get(getModel().getFacets().get(0));
-        //minDistance = distanceList.stream().mapToDouble(Double::doubleValue).min().getAsDouble();
-        //maxDistance = distanceList.stream().mapToDouble(Double::doubleValue).max().getAsDouble();
     }
     
-    public void drawMaxPrincipal() {
+    /**
+     * Computes curvature
+     */
+    public void computeMaxPrincipal() {
         if (this.getModel() == null) {
             return;
         }
+        
+        long startTime = System.currentTimeMillis();
         Curvature vis = new Curvature();
         this.getModel().compute(vis);
         values = vis.getMaxPrincipalCurvatures();
+        long duration =  System.currentTimeMillis() - startTime;
+        System.err.println(duration + "\tmsec: Maximum principal curvature");
+        
         minDistance = 0.0;
         maxDistance = 2.0;
-        //List<Double> distanceList = values.get(getModel().getFacets().get(0));
-        //minDistance = distanceList.stream().mapToDouble(Double::doubleValue).min().getAsDouble();
-        //maxDistance = distanceList.stream().mapToDouble(Double::doubleValue).max().getAsDouble();
     }
     
-    public void drawHausdorffDistanceP2pAbs() {
+    /**
+     * Computes absolute HD
+     */
+    public void computeHausdorffDistanceP2pAbs() {
         if (this.getModel() == null) {
             return;
         }
         try {
             HumanFace boy = new HumanFace(new File("src/test/resources/cz/fidentis/analyst/average_boy_17-20.obj"));
+            long startTime = System.currentTimeMillis();
             HausdorffDistance vis = new HausdorffDistance(boy.getMeshModel(), Strategy.POINT_TO_POINT, false, true);
             this.getModel().compute(vis);
             values = vis.getDistances();
-        
+            long duration =  System.currentTimeMillis() - startTime;
+            System.err.println(duration + "\tmsec: Hausdorff distance " + vis.getStrategy() + " " + (vis.relativeDistance() ? "RELATIVE" : "ABSOLUTE"));
         } catch (IOException ex) {
             Exceptions.printStackTrace(ex);
         }
@@ -120,16 +246,21 @@ public class HeatMapGLEventListener extends GeneralGLEventListener {
         maxDistance = distanceList.stream().mapToDouble(Double::doubleValue).max().getAsDouble();
     }
     
-    public void drawHausdorffDistanceP2pRel() {
+    /**
+     * Computes relative HD
+     */
+    public void computeHausdorffDistanceP2pRel() {
         if (this.getModel() == null) {
             return;
         }
         try {
             HumanFace boy = new HumanFace(new File("src/test/resources/cz/fidentis/analyst/average_boy_17-20.obj"));
+            long startTime = System.currentTimeMillis();
             HausdorffDistance vis = new HausdorffDistance(boy.getMeshModel(), Strategy.POINT_TO_POINT, true, true);
             this.getModel().compute(vis);
             values = vis.getDistances();
-        
+            long duration =  System.currentTimeMillis() - startTime;
+            System.err.println(duration + "\tmsec: Hausdorff distance " + vis.getStrategy() + " " + (vis.relativeDistance() ? "RELATIVE" : "ABSOLUTE"));
         } catch (IOException ex) {
             Exceptions.printStackTrace(ex);
         }
@@ -175,13 +306,13 @@ public class HeatMapGLEventListener extends GeneralGLEventListener {
         gl.glFlush();
     }
 
-    public void drawHeatmap(MeshModel model) {
+    protected void drawHeatmap(MeshModel model) {
         for (int i = 0; i < model.getFacets().size(); i++) {
             renderFaceWithHeatmap(model.getFacets().get(i), values.get(model.getFacets().get(i)), minDistance, maxDistance);
         }
     }
 
-    public void renderFaceWithHeatmap(MeshFacet facet, List<Double> distancesList, Double minDistance, Double maxDistance) {
+    protected void renderFaceWithHeatmap(MeshFacet facet, List<Double> distancesList, Double minDistance, Double maxDistance) {
         gl.glBegin(GL2.GL_TRIANGLES); //vertices are rendered as triangles
 
         // get the normal and tex coords indicies for face i
@@ -203,20 +334,14 @@ public class HeatMapGLEventListener extends GeneralGLEventListener {
         gl.glPopAttrib();
     }
 
-    public Color getColor(Double currentDistance, Double minDistance, Double maxDistance) {
+    protected Color getColor(Double currentDistance, Double minDistance, Double maxDistance) {
         double currentParameter = ((currentDistance - minDistance) / (maxDistance - minDistance));
-        //return new Color((float)currentParameter, 0.5f, 0.5f);
         
         if (currentDistance > maxDistance) {
             currentParameter = 1.0;
-        } else if (currentDistance < minDistance) { 
+        } else if (currentDistance < minDistance || (maxDistance - minDistance) == 0) { 
             currentParameter = 0.0;
         }
-        //currentParameter *= 10;
-        //if (currentParameter > maxDistance) {
-        //    currentParameter = 1.0;
-        //}
-        //System.out.println("AAA " + currentParameter + " " + minDistance + " " + maxDistance);
         
         float[] hsb1 = Color.RGBtoHSB(minColor.getRed(), minColor.getGreen(), minColor.getBlue(), null);
         double h1 = hsb1[0];
-- 
GitLab