Commit 659c352c authored by Daniel Schramm's avatar Daniel Schramm
Browse files

Overview of feature point weights implemented

parent 009fae15
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ public class DistanceAction extends ControlPanelAction {
            case DistancePanel.ACTION_COMMAND_WEIGHTED_DIST_RECOMPUTE:
                this.visitor = null; // recompute
                setHeatmap();
                setFeaturePointWeigths();
                break;
            default:
                // to nothing
@@ -130,6 +131,31 @@ public class DistanceAction extends ControlPanelAction {
        );
    }
    
    private void setFeaturePointWeigths() {
        if (!weightedDist) {
            controlPanel.updateFeaturePointWeights(Map.of());
            return;
        }
        
        final Map<FeaturePointType, Map<MeshFacet, Double>> faceWeights = visitor.getFeaturePointWeights()
                .get(getSecondaryDrawableFace().getHumanFace());
        
        final Map<FeaturePointType, Double> featurePointWeights = new HashMap<>(faceWeights.size());
        for (final Map.Entry<FeaturePointType, Map<MeshFacet, Double>> fpWeights: faceWeights.entrySet()) {
            featurePointWeights.put(
                    fpWeights.getKey(),
                    fpWeights.getValue()
                            .values()
                            .stream()
                            .mapToDouble(weight -> weight)
                            .average()
                            .orElse(Double.NaN)
            );
        }
        
        controlPanel.updateFeaturePointWeights(featurePointWeights);
    }

    private Map<MeshFacet, List<Double>> calculateHausdorffDistance() {
        if (weightedDist) {
            // TODO Merge the map of distances with the map of priorities
+30 −1
Original line number Diff line number Diff line
@@ -3,17 +3,21 @@ package cz.fidentis.analyst.distance;
import cz.fidentis.analyst.core.ControlPanel;
import cz.fidentis.analyst.core.ControlPanelBuilder;
import cz.fidentis.analyst.feature.FeaturePoint;
import cz.fidentis.analyst.feature.FeaturePointType;
import cz.fidentis.analyst.scene.DrawableFeaturePoints;
import cz.fidentis.analyst.symmetry.SymmetryPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

/**
@@ -47,6 +51,7 @@ public class DistancePanel extends ControlPanel {
    public static final String STRATEGY_POINT_TO_POINT = "Point to point";
    public static final String STRATEGY_POINT_TO_TRIANGLE = "Point to triangle";
    
    private final JPanel featurePointsStats;
    private final JLabel avgHD, maxHD, minHD;
    
    /**
@@ -111,7 +116,8 @@ public class DistancePanel extends ControlPanel {
            
            fpBuilder.addLine();
        }
        builder.addScrollPane(featurePointsPanel);
        builder.addScrollPane(featurePointsPanel)
                .setBorder(BorderFactory.createTitledBorder("Feature points"));
        builder.addLine();
        
        final JButton recomputeButton = builder.addButton(
@@ -174,6 +180,15 @@ public class DistancePanel extends ControlPanel {
        builder.addGap();
        builder.addLine();
        
        featurePointsStats = new JPanel();
        final JScrollPane fpStatsScrollPanel = builder.addScrollPane(featurePointsStats);
        fpStatsScrollPanel.setBorder(BorderFactory.createTitledBorder("Feature point weights"));
        fpStatsScrollPanel.setVisible(false);
        weightedDistChBx.addActionListener((ActionEvent ae) -> {
            fpStatsScrollPanel.setVisible(weightedDistChBx.isSelected());
        });
        builder.addLine();
        
        builder.addVerticalStrut();
    }
    
@@ -197,4 +212,18 @@ public class DistancePanel extends ControlPanel {
        minHD.setText(Double.toString(minDist));
    }
    
    public void updateFeaturePointWeights(Map<FeaturePointType, Double> featurePointWeights) {
        featurePointsStats.removeAll();
        
        final ControlPanelBuilder fpBuilder = new ControlPanelBuilder(featurePointsStats);
        for (final Map.Entry<FeaturePointType, Double> fpStats: featurePointWeights.entrySet()) {
            fpBuilder.addOptionText(fpStats.getKey().getName());
            fpBuilder.addGap();
            
            fpBuilder.addLabelLine(Double.toString(fpStats.getValue()));
            fpBuilder.addGap();
            fpBuilder.addLine();
        }
    }

}