From 922f2d12cff04609fd731d336c9a0a5655552194 Mon Sep 17 00:00:00 2001
From: Matej Lukes <456316@mail.muni.cz>
Date: Wed, 13 May 2020 23:57:05 +0200
Subject: [PATCH] minor changes

---
 .../analyst/comparison/ComparisonMethod.java  |  6 ---
 .../analyst/comparison/HausdorffDistance.java | 44 ++++++++++---------
 2 files changed, 23 insertions(+), 27 deletions(-)
 delete mode 100644 Comparison/src/main/java/cz/fidentis/analyst/comparison/ComparisonMethod.java

diff --git a/Comparison/src/main/java/cz/fidentis/analyst/comparison/ComparisonMethod.java b/Comparison/src/main/java/cz/fidentis/analyst/comparison/ComparisonMethod.java
deleted file mode 100644
index 376762df..00000000
--- a/Comparison/src/main/java/cz/fidentis/analyst/comparison/ComparisonMethod.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package cz.fidentis.analyst.comparison;
-
-public enum ComparisonMethod {
-    HAUSDORFF_DISTANCE_TO_VERTEX_OF_MESH,
-    HAUSDORFF_DISTANCE_TO_POINT_ON_MESH
-}
diff --git a/Comparison/src/main/java/cz/fidentis/analyst/comparison/HausdorffDistance.java b/Comparison/src/main/java/cz/fidentis/analyst/comparison/HausdorffDistance.java
index d5597999..2483bafb 100644
--- a/Comparison/src/main/java/cz/fidentis/analyst/comparison/HausdorffDistance.java
+++ b/Comparison/src/main/java/cz/fidentis/analyst/comparison/HausdorffDistance.java
@@ -17,24 +17,26 @@ import java.util.stream.Collectors;
  * @author Matej Lukes
  */
 public class HausdorffDistance {
-    private MeshFacet firstFacet;
-    private MeshFacet secondFacet;
+    private MeshFacet mainFacet;
+    private MeshFacet comparedFacet;
 
     private AtomicInteger progress = new AtomicInteger();
     private int numberOfVertices;
 
     /**
-     * @param firstFacet
-     * @param secondFacet
+     * @param mainFacet     main MeshFacet
+     * @param comparedFacet compared MeshFacet
      */
-    public HausdorffDistance(MeshFacet firstFacet, MeshFacet secondFacet) {
-        this.firstFacet = firstFacet;
-        this.secondFacet = secondFacet;
-        this.numberOfVertices = firstFacet.getNumberOfVertices();
+    public HausdorffDistance(MeshFacet mainFacet, MeshFacet comparedFacet) {
+        this.mainFacet = mainFacet;
+        this.comparedFacet = comparedFacet;
+        this.numberOfVertices = mainFacet.getNumberOfVertices();
     }
 
     /**
-     * @return
+     * returns progress percentage
+     *
+     * @return progress
      */
     public double getProgressPercentage() {
         return ((double) progress.get() / numberOfVertices) * 100;
@@ -47,7 +49,7 @@ public class HausdorffDistance {
      * @return vertex, nearest vertex from second facet, distance
      */
     private ClosestVertices getNearestVertex(MeshPoint vertex) {
-        Optional<Pair<MeshPoint, Double>> closestVertexAndDistance = secondFacet.getVertices().parallelStream()
+        Optional<Pair<MeshPoint, Double>> closestVertexAndDistance = comparedFacet.getVertices().parallelStream()
                 .map((meshPoint) -> new Pair<>(meshPoint, getDistanceBetweenPoints(vertex, meshPoint.getPosition())))
                 .max((Comparator.comparingDouble(Pair::getValue)));
         return closestVertexAndDistance.map(vector3dDoublePair -> new ClosestVertices(vertex,
@@ -76,11 +78,11 @@ public class HausdorffDistance {
      */
     public List<ClosestVertices> calculateHausdorffDistanceToVertices() {
         progress.set(0);
-        int numberOfVertices = firstFacet.getNumberOfVertices();
+        int numberOfVertices = mainFacet.getNumberOfVertices();
         List<Future<ClosestVertices>> closestVerticesFutures = new ArrayList<>(numberOfVertices);
         ExecutorService executor = Executors.newCachedThreadPool();
 
-        for (final MeshPoint vertex : firstFacet.getVertices()) {
+        for (final MeshPoint vertex : mainFacet.getVertices()) {
             closestVerticesFutures.add(executor.submit(() -> {
                 ClosestVertices result = getNearestVertex(vertex);
                 progress.addAndGet(1);
@@ -115,7 +117,7 @@ public class HausdorffDistance {
      */
     public List<ClosestVertices> calculateHausdorffDistanceToVertices2() {
         progress.set(0);
-        return firstFacet.getVertices().parallelStream()
+        return mainFacet.getVertices().parallelStream()
                 .map((vertex) -> {
                     ClosestVertices result = getNearestVertex(vertex);
                     progress.addAndGet(1);
@@ -132,15 +134,15 @@ public class HausdorffDistance {
      */
     public List<ClosestVertices> calculateHausdorffDistanceToMesh() {
         progress.set(0);
-        int numberOfVertices = firstFacet.getNumberOfVertices();
+        int numberOfVertices = mainFacet.getNumberOfVertices();
         List<Future<ClosestVertices>> closestPointsFutures = new ArrayList<>(numberOfVertices);
         ExecutorService executor = Executors.newCachedThreadPool();
 
-        for (final MeshPoint vertex : firstFacet.getVertices()) {
+        for (final MeshPoint vertex : mainFacet.getVertices()) {
             closestPointsFutures.add(executor.submit(() -> {
                 ClosestVertices result = CalculateNearestPointOnMesh(vertex,
-                        secondFacet.getCornerTable()
-                                .getTriangleIndexesByVertexIndex(secondFacet.getVertices()
+                        comparedFacet.getCornerTable()
+                                .getTriangleIndexesByVertexIndex(comparedFacet.getVertices()
                                         .indexOf(getNearestVertex(vertex)
                                                 .getSecondVertex())));
                 progress.addAndGet(1);
@@ -174,11 +176,11 @@ public class HausdorffDistance {
      */
     public List<ClosestVertices> calculateHausdorffDistanceToMesh2() {
         progress.set(0);
-        return firstFacet.getVertices().parallelStream()
+        return mainFacet.getVertices().parallelStream()
                 .map((meshPoint) -> {
                     ClosestVertices result = CalculateNearestPointOnMesh(meshPoint,
-                            secondFacet.getCornerTable()
-                                    .getTriangleIndexesByVertexIndex(secondFacet.getVertices()
+                            comparedFacet.getCornerTable()
+                                    .getTriangleIndexesByVertexIndex(comparedFacet.getVertices()
                                             .indexOf(getNearestVertex(meshPoint)
                                                     .getSecondVertex())));
                     progress.addAndGet(1);
@@ -200,7 +202,7 @@ public class HausdorffDistance {
         Vector3d helperVector = new Vector3d();
 
         for (int index : indicesOfTrianglesOfVertex) {
-            List<Vector3d> triangle = secondFacet.getVerticesOfTriangle(index).stream()
+            List<Vector3d> triangle = comparedFacet.getVerticesOfTriangle(index).stream()
                     .map(MeshPoint::getPosition)
                     .collect(Collectors.toList());
             Vector3d projection = getProjectionToTrianglePlane(vertexPosition, triangle);
-- 
GitLab