Skip to content
Snippets Groups Projects
Commit 90b834f5 authored by Daniel Schramm's avatar Daniel Schramm
Browse files

Stream replaced with for-loop

parent 659c352c
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ import cz.fidentis.analyst.visitors.face.HausdorffDistancePrioritized; ...@@ -10,6 +10,7 @@ import cz.fidentis.analyst.visitors.face.HausdorffDistancePrioritized;
import cz.fidentis.analyst.visitors.mesh.HausdorffDistance.Strategy; import cz.fidentis.analyst.visitors.mesh.HausdorffDistance.Strategy;
import java.awt.Color; import java.awt.Color;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.Collection;
import java.util.DoubleSummaryStatistics; import java.util.DoubleSummaryStatistics;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -142,15 +143,20 @@ public class DistanceAction extends ControlPanelAction { ...@@ -142,15 +143,20 @@ public class DistanceAction extends ControlPanelAction {
final Map<FeaturePointType, Double> featurePointWeights = new HashMap<>(faceWeights.size()); final Map<FeaturePointType, Double> featurePointWeights = new HashMap<>(faceWeights.size());
for (final Map.Entry<FeaturePointType, Map<MeshFacet, Double>> fpWeights: faceWeights.entrySet()) { for (final Map.Entry<FeaturePointType, Map<MeshFacet, Double>> fpWeights: faceWeights.entrySet()) {
featurePointWeights.put( final Collection<Double> weightsList = fpWeights.getValue().values();
fpWeights.getKey(),
fpWeights.getValue() final double average;
.values() if (weightsList.isEmpty()) {
.stream() average = Double.NaN;
.mapToDouble(weight -> weight) } else {
.average() double sum = 0;
.orElse(Double.NaN) for (final double weight: weightsList) {
); sum += weight;
}
average = sum / weightsList.size();
}
featurePointWeights.put(fpWeights.getKey(), average);
} }
controlPanel.updateFeaturePointWeights(featurePointWeights); controlPanel.updateFeaturePointWeights(featurePointWeights);
......
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