Skip to content
Snippets Groups Projects
Commit 8c73572d authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Merge branch '66-3d-heatmap-visualization' into 'master'

Resolve "3D heatmap visualization"

Closes #66

See merge request grp-fidentis/analyst2!84
parents e14874dc ae0c9741
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ import com.jogamp.opengl.GLAutoDrawable; ...@@ -6,6 +6,7 @@ import com.jogamp.opengl.GLAutoDrawable;
import cz.fidentis.analyst.face.HumanFace; import cz.fidentis.analyst.face.HumanFace;
import cz.fidentis.analyst.mesh.core.MeshFacet; import cz.fidentis.analyst.mesh.core.MeshFacet;
import cz.fidentis.analyst.mesh.core.MeshModel; import cz.fidentis.analyst.mesh.core.MeshModel;
import cz.fidentis.analyst.visitors.mesh.HausdorffDistance;
import javax.vecmath.Vector3d; import javax.vecmath.Vector3d;
import java.awt.*; import java.awt.*;
...@@ -19,20 +20,19 @@ import static com.jogamp.opengl.GL2GL3.GL_FILL; ...@@ -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.GL2GL3.GL_LINE;
import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_MODELVIEW_MATRIX; import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_MODELVIEW_MATRIX;
import static com.jogamp.opengl.fixedfunc.GLMatrixFunc.GL_PROJECTION_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 { public class ComparisonGLEventListener extends GeneralGLEventListener {
private Map<MeshFacet, List<Double>> distances = new HashMap<>();
private HumanFace comparedFace;
boolean renderHeatmap; boolean renderHeatmap;
Color minColor; Color minColor;
Color maxColor; Color maxColor;
private Map<MeshFacet, List<Double>> distances = new HashMap<>();
private HumanFace comparedFace;
public ComparisonGLEventListener(Canvas canvas) { public ComparisonGLEventListener(Canvas canvas) {
...@@ -47,12 +47,9 @@ public class ComparisonGLEventListener extends GeneralGLEventListener { ...@@ -47,12 +47,9 @@ public class ComparisonGLEventListener extends GeneralGLEventListener {
} }
public void compare(Color minColor, Color maxColor) { public void compare(Color minColor, Color maxColor) {
//HausdorffDistance hVisitor = new HausdorffDistance(getModel(), HausdorffDistance.Strategy.POINT_TO_POINT, false, false); HausdorffDistance hVisitor = new HausdorffDistance(getModel(), HausdorffDistance.Strategy.POINT_TO_POINT, false, false);
//comparedFace.getMeshModel().compute(hVisitor); comparedFace.getMeshModel().compute(hVisitor);
//distances = hVisitor.getDistances(); distances = hVisitor.getDistances();
Curvature visitor = new Curvature();
comparedFace.getMeshModel().compute(visitor);
distances = visitor.getGaussianCurvatures();
renderHeatmap = true; renderHeatmap = true;
this.minColor = minColor; this.minColor = minColor;
this.maxColor = maxColor; this.maxColor = maxColor;
...@@ -104,11 +101,6 @@ public class ComparisonGLEventListener extends GeneralGLEventListener { ...@@ -104,11 +101,6 @@ public class ComparisonGLEventListener extends GeneralGLEventListener {
List<Double> distanceList = distances.get(model.getFacets().get(i)); List<Double> distanceList = distances.get(model.getFacets().get(i));
Double minDistance = distanceList.stream().mapToDouble(Double::doubleValue).min().getAsDouble(); Double minDistance = distanceList.stream().mapToDouble(Double::doubleValue).min().getAsDouble();
Double maxDistance = distanceList.stream().mapToDouble(Double::doubleValue).max().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); renderFaceWithHeatmap(model.getFacets().get(i), distances.get(model.getFacets().get(i)), minDistance, maxDistance);
} }
} }
...@@ -137,30 +129,20 @@ public class ComparisonGLEventListener extends GeneralGLEventListener { ...@@ -137,30 +129,20 @@ public class ComparisonGLEventListener extends GeneralGLEventListener {
Color getColor(Double currentDistance, Double minDistance, Double maxDistance) { Color getColor(Double currentDistance, Double minDistance, Double maxDistance) {
double currentParameter = ((currentDistance - minDistance) / (maxDistance - minDistance)); 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); float[] hsb1 = Color.RGBtoHSB(minColor.getRed(), minColor.getGreen(), minColor.getBlue(), null);
double h1 = hsb1[0]; float h1 = hsb1[0];
double s1 = hsb1[1]; float s1 = hsb1[1];
double b1 = hsb1[2]; float b1 = hsb1[2];
float[] hsb2 = Color.RGBtoHSB(maxColor.getRed(), maxColor.getGreen(), maxColor.getBlue(), null); float[] hsb2 = Color.RGBtoHSB(maxColor.getRed(), maxColor.getGreen(), maxColor.getBlue(), null);
double h2 = hsb2[0]; float h2 = hsb2[0];
double s2 = hsb2[1]; float s2 = hsb2[1];
double b2 = hsb2[2]; float b2 = hsb2[2];
// determine clockwise and counter-clockwise distance between hues // determine clockwise and counter-clockwise distance between hues
double distCCW; float distCCW;
double distCW; float distCW;
if (h1 >= h2) { if (h1 >= h2) {
distCCW = h1 - h2; distCCW = h1 - h2;
...@@ -170,12 +152,12 @@ public class ComparisonGLEventListener extends GeneralGLEventListener { ...@@ -170,12 +152,12 @@ public class ComparisonGLEventListener extends GeneralGLEventListener {
distCW = h2 - h1; distCW = h2 - h1;
} }
double hue; float hue;
if (distCW >= distCCW) { if (distCW >= distCCW) {
hue = h1 + (distCW * currentParameter); hue = (float) (h1 + (distCW * currentParameter));
} else { } else {
hue = h1 - (distCCW * currentParameter); hue = (float) (h1 - (distCCW * currentParameter));
} }
if (hue < 0) { if (hue < 0) {
...@@ -184,12 +166,10 @@ public class ComparisonGLEventListener extends GeneralGLEventListener { ...@@ -184,12 +166,10 @@ public class ComparisonGLEventListener extends GeneralGLEventListener {
if (hue > 1) { if (hue > 1) {
hue = 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);
} }
} }
...@@ -8,13 +8,19 @@ import java.awt.*; ...@@ -8,13 +8,19 @@ import java.awt.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
/**
* @author Daniel Sokol
* <p>
* Temporary interface to test rendering heatmap.
*/
public class TestInterface { public class TestInterface {
private static final JFrame testFrame = new JFrame(); private static final JFrame testFrame = new JFrame();
private static HumanFace comparedModel; private static HumanFace comparedModel;
public static void main(String[] args) { public static void main(String[] args) {
//Declaration
JButton addButton = new JButton("Load face to compare"); JButton addButton = new JButton("Load face to compare");
JButton compareButton = new JButton("Show differences"); JButton compareButton = new JButton("Show differences");
...@@ -34,7 +40,6 @@ public class TestInterface { ...@@ -34,7 +40,6 @@ public class TestInterface {
colorMaxFrame.add(colorChooserMax); colorMaxFrame.add(colorChooserMax);
colorMaxFrame.pack(); colorMaxFrame.pack();
// Settings
addButton.addActionListener(e -> { addButton.addActionListener(e -> {
try { try {
JFileChooser jFileChooser1 = new JFileChooser(); JFileChooser jFileChooser1 = new JFileChooser();
...@@ -65,7 +70,6 @@ public class TestInterface { ...@@ -65,7 +70,6 @@ public class TestInterface {
testFrame.setVisible(true); testFrame.setVisible(true);
testFrame.setSize(1200, 700); testFrame.setSize(1200, 700);
// Adding
GridBagConstraints c = new GridBagConstraints(); GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH; c.fill = GridBagConstraints.BOTH;
c.gridx = 0; c.gridx = 0;
...@@ -93,3 +97,4 @@ public class TestInterface { ...@@ -93,3 +97,4 @@ public class TestInterface {
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment