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;
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);
}
}
......@@ -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 {
}
}
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