diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/ComparisonGLEventListener.java b/GUI/src/main/java/cz/fidentis/analyst/gui/ComparisonGLEventListener.java index 07544697696f3196a729bdf7b374d6e2f2bff84e..217c189c6458581332d02115c2cb71116d9d89c9 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/gui/ComparisonGLEventListener.java +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/ComparisonGLEventListener.java @@ -6,6 +6,7 @@ import com.jogamp.opengl.GLAutoDrawable; import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.mesh.core.MeshFacet; import cz.fidentis.analyst.mesh.core.MeshModel; +import cz.fidentis.analyst.visitors.mesh.HausdorffDistance; import javax.vecmath.Vector3d; import java.awt.*; @@ -19,20 +20,19 @@ import static com.jogamp.opengl.GL2GL3.GL_FILL; import static com.jogamp.opengl.GL2GL3.GL_LINE; import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_MODELVIEW_MATRIX; import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_PROJECTION_MATRIX; -import cz.fidentis.analyst.visitors.mesh.Curvature; -import cz.fidentis.analyst.visitors.mesh.HausdorffDistance; /** - * - * @author radek oslejsek + * + * @author Daniel Sokol + * + * Rendering face with heatmap. */ public class ComparisonGLEventListener extends GeneralGLEventListener { - private Map<MeshFacet, List<Double>> distances = new HashMap<>(); - private HumanFace comparedFace; boolean renderHeatmap; Color minColor; Color maxColor; - + private Map<MeshFacet, List<Double>> distances = new HashMap<>(); + private HumanFace comparedFace; public ComparisonGLEventListener(Canvas canvas) { @@ -47,12 +47,9 @@ public class ComparisonGLEventListener extends GeneralGLEventListener { } public void compare(Color minColor, Color maxColor) { - //HausdorffDistance hVisitor = new HausdorffDistance(getModel(), HausdorffDistance.Strategy.POINT_TO_POINT, false, false); - //comparedFace.getMeshModel().compute(hVisitor); - //distances = hVisitor.getDistances(); - Curvature visitor = new Curvature(); - comparedFace.getMeshModel().compute(visitor); - distances = visitor.getGaussianCurvatures(); + HausdorffDistance hVisitor = new HausdorffDistance(getModel(), HausdorffDistance.Strategy.POINT_TO_POINT, false, false); + comparedFace.getMeshModel().compute(hVisitor); + distances = hVisitor.getDistances(); renderHeatmap = true; this.minColor = minColor; this.maxColor = maxColor; @@ -104,11 +101,6 @@ public class ComparisonGLEventListener extends GeneralGLEventListener { List<Double> distanceList = distances.get(model.getFacets().get(i)); Double minDistance = distanceList.stream().mapToDouble(Double::doubleValue).min().getAsDouble(); Double maxDistance = distanceList.stream().mapToDouble(Double::doubleValue).max().getAsDouble(); - minDistance = -0.05; // !!! - maxDistance = 0.01; // !!! - //minDistance = -0.2; // !!! min - //maxDistance = 0.05; // !!! min - //System.out.println("AAA" + minDistance + " " + maxDistance); renderFaceWithHeatmap(model.getFacets().get(i), distances.get(model.getFacets().get(i)), minDistance, maxDistance); } } @@ -137,30 +129,20 @@ public class ComparisonGLEventListener extends GeneralGLEventListener { 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 || currentDistance < minDistance) { // !!! - currentParameter = 1.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]; - double s1 = hsb1[1]; - double b1 = hsb1[2]; + float h1 = hsb1[0]; + float s1 = hsb1[1]; + float b1 = hsb1[2]; float[] hsb2 = Color.RGBtoHSB(maxColor.getRed(), maxColor.getGreen(), maxColor.getBlue(), null); - double h2 = hsb2[0]; - double s2 = hsb2[1]; - double b2 = hsb2[2]; + float h2 = hsb2[0]; + float s2 = hsb2[1]; + float b2 = hsb2[2]; // determine clockwise and counter-clockwise distance between hues - double distCCW; - double distCW; + float distCCW; + float distCW; if (h1 >= h2) { distCCW = h1 - h2; @@ -170,12 +152,12 @@ public class ComparisonGLEventListener extends GeneralGLEventListener { distCW = h2 - h1; } - double hue; + float hue; if (distCW >= distCCW) { - hue = h1 + (distCW * currentParameter); + hue = (float) (h1 + (distCW * currentParameter)); } else { - hue = h1 - (distCCW * currentParameter); + hue = (float) (h1 - (distCCW * currentParameter)); } if (hue < 0) { @@ -184,12 +166,10 @@ public class ComparisonGLEventListener extends GeneralGLEventListener { if (hue > 1) { hue = hue - 1; } - - double saturation = (1 - currentParameter) * s1 + currentParameter * s2; - double brightness = (1 - currentParameter) * b1 + currentParameter * b2; - //System.out.println("AAA " + hue); + float saturation = (float) ((1 - currentParameter) * s1 + currentParameter * s2); + float brightness = (float) ((1 - currentParameter) * b1 + currentParameter * b2); - return Color.getHSBColor((float)hue, (float)saturation, (float)brightness); + return Color.getHSBColor(hue, saturation, brightness); } } diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/TestInterface.java b/GUI/src/main/java/cz/fidentis/analyst/gui/TestInterface.java index 5a2026195e84b63a35a76a945180a146480f2a15..1d67ec08a6aee2dd6775cba7e0cd4c1e5f433e18 100644 --- a/GUI/src/main/java/cz/fidentis/analyst/gui/TestInterface.java +++ b/GUI/src/main/java/cz/fidentis/analyst/gui/TestInterface.java @@ -8,13 +8,19 @@ import java.awt.*; import java.io.File; import java.io.IOException; +/** + * @author Daniel Sokol + * <p> + * Temporary interface to test rendering heatmap. + */ + + public class TestInterface { private static final JFrame testFrame = new JFrame(); private static HumanFace comparedModel; public static void main(String[] args) { - //Declaration JButton addButton = new JButton("Load face to compare"); JButton compareButton = new JButton("Show differences"); @@ -34,7 +40,6 @@ public class TestInterface { colorMaxFrame.add(colorChooserMax); colorMaxFrame.pack(); - // Settings addButton.addActionListener(e -> { try { JFileChooser jFileChooser1 = new JFileChooser(); @@ -65,7 +70,6 @@ public class TestInterface { testFrame.setVisible(true); testFrame.setSize(1200, 700); - // Adding GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; @@ -93,3 +97,4 @@ public class TestInterface { } } +