From dc79931f9024a513e0ce152792eb6b88c4f46032 Mon Sep 17 00:00:00 2001
From: Radek Oslejsek <oslejsek@fi.muni.cz>
Date: Mon, 19 Oct 2020 16:05:44 +0200
Subject: [PATCH] Code refactoring

---
 .../cz/fidentis/analyst/symmetry/Plane.java   |  56 +-
 .../analyst/symmetry/SymmetryEstimator.java   | 535 +++++++++---------
 .../fidentis/analyst/gui/SymmetryPanel.java   |   2 +-
 3 files changed, 285 insertions(+), 308 deletions(-)

diff --git a/Comparison/src/main/java/cz/fidentis/analyst/symmetry/Plane.java b/Comparison/src/main/java/cz/fidentis/analyst/symmetry/Plane.java
index cb9cfaa3..4c099e46 100644
--- a/Comparison/src/main/java/cz/fidentis/analyst/symmetry/Plane.java
+++ b/Comparison/src/main/java/cz/fidentis/analyst/symmetry/Plane.java
@@ -1,22 +1,16 @@
 package cz.fidentis.analyst.symmetry;
 
-import cz.fidentis.analyst.mesh.core.MeshFacet;
-import cz.fidentis.analyst.mesh.core.MeshFacetImpl;
-import cz.fidentis.analyst.mesh.core.MeshPointImpl;
-import javax.vecmath.Vector3d;
-
 /**
- *
- * @author Natália Bebjaková
+ * Symmetry plane.
  * 
- * Representation of the symmetry plane 
+ * @author Natalia Bebjakova
  */
 public class Plane {
+   
     public double a;
     public double b;
     public double c;
     public double d;
-    private static MeshFacet facet;
 
     /**
      * Creates new plane 
@@ -45,50 +39,6 @@ public class Plane {
         d /= normalLength;
     }
     
-    /**
-     * Returns plane that is represented by mesh which can be merged with model  
-     * 
-     * @param centroid middle point of the plane 
-     * @param a a coordinate
-     * @param b b coordinate
-     * @param scale distance of points given by bounding box
-     * @return plane represented as mesh 
-     */
-    public static SymmetryEstimator createPlaneMesh(Vector3d centroid, Vector3d a, Vector3d b, double scale) {
-        Vector3d[] points = new Vector3d[4];
-        
-        Vector3d aScaled = new Vector3d(a);
-        Vector3d bScaled = new Vector3d(b);
-        aScaled.scale(scale);
-        bScaled.scale(scale);
-        
-        points[0] = new Vector3d(centroid);
-        points[0].sub(aScaled);
-        points[0].sub(bScaled);
-        
-        points[1] = new Vector3d(centroid);
-        points[1].sub(aScaled);
-        points[1].add(bScaled);
-        
-        points[2] = new Vector3d(centroid);
-        points[2].add(aScaled);
-        points[2].add(bScaled);
-        
-        points[3] = new Vector3d(centroid);
-        points[3].add(aScaled);
-        points[3].sub(bScaled);
-        
-        facet = new MeshFacetImpl();
-        for (Vector3d point : points) {
-            facet.addVertex(new MeshPointImpl(point, null, null));
-        }
-        facet.calculateVertexNormals();
-
-        SymmetryEstimator planeMesh = new SymmetryEstimator(facet, Config.getDefault());
-        
-        return planeMesh;
-    }
-    
     /**
      * Returns string description of the plane
      * 
diff --git a/Comparison/src/main/java/cz/fidentis/analyst/symmetry/SymmetryEstimator.java b/Comparison/src/main/java/cz/fidentis/analyst/symmetry/SymmetryEstimator.java
index 50e9f043..d1027164 100644
--- a/Comparison/src/main/java/cz/fidentis/analyst/symmetry/SymmetryEstimator.java
+++ b/Comparison/src/main/java/cz/fidentis/analyst/symmetry/SymmetryEstimator.java
@@ -3,15 +3,13 @@ package cz.fidentis.analyst.symmetry;
 import cz.fidentis.analyst.mesh.core.CornerTableRow;
 import cz.fidentis.analyst.mesh.core.MeshFacet;
 import cz.fidentis.analyst.mesh.core.MeshPoint;
-import cz.fidentis.analyst.mesh.core.MeshPointImpl;
 import cz.fidentis.analyst.mesh.core.BoundingBox;
+import cz.fidentis.analyst.mesh.core.MeshFacetImpl;
+import cz.fidentis.analyst.mesh.core.MeshPointImpl;
 import cz.fidentis.analyst.mesh.core.MeshTriangle;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import javax.swing.ImageIcon;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
@@ -20,40 +18,58 @@ import javax.swing.UIManager;
 import javax.vecmath.Vector3d;
 
 /**
- *
- * @author Natália Bebjaková
- * 
  * Main class for computing approximate plane of symmetry of the 3D model.
  * For computing the symmetry, for every 
  * Default values of the configuration are given due to the best results on tested objects.
  * On many different 3D models, it exists other values of config that will have better impact on result. 
  * 
+ * @author Natalia Bebjakova
  */
 public class SymmetryEstimator {
+    
+    private final MeshFacet facet; // Facet of the model on which symmetry is computed 
+    
+    private TriangleVertexAreas[] areas; // Representation for areas of Voronoi region of triangles
+    
+    private BoundingBox boundingBox; // Represent min-max box. It is automatically maintained by given point array.
+    
+    private List<MeshTriangle> triangles; // Helping array of triangles computed from corner table 
+    
+    private JPanel panel; // panel for configuration of symmetry counting 
+    
+    private final Config config;
+    
     /**
-     * Facet of the model on which symmetry is computed 
-     */
-    private final MeshFacet facet;   
-    /**
-     * Representation for areas of Voronoi region of triangles
-     */
-    private TriangleVertexAreas[] areas;
-    /**
-     * Represent min-max box. It is automatically maintained by given point array.
-     */
-    private BoundingBox boundingBox;
-    /**
-     * Helping array of triangles computed from corner table 
+     * Constructor.
+     * 
+     * @param f facet on which the symmetry will be computed 
+     * @param config configuration of optional parameters of the algorithm
      */
-    private List<MeshTriangle> triangles;
+    public SymmetryEstimator(MeshFacet f, Config config) {
+        this.facet = f;
+        this.config = config;
+        
+        this.triangles = f.asTriangles();
+        
+        this.areas = new TriangleVertexAreas[triangles.size()];
+        for (int i = 0; i < areas.length; i++) {
+            areas[i] = computeTriangleVertexAreas(triangles.get(i));
+        }
+
+        boundingBox = facet.getBoundingBox();
+    }
     
     /**
-     * panel for configuration of symmetry counting 
+     * Helper constructor.
+     * @param centroid Centroid
+     * @param a A
+     * @param b B
+     * @param scale Scale
      */
-    private JPanel panel;
+    protected SymmetryEstimator(Vector3d centroid, Vector3d a, Vector3d b, double scale) {
+        this(createMeshFacet(centroid, a, b, scale), Config.getDefault());
+    }
     
-    private final Config config;
-
     /**
      * 
      * @return configuration of optional parameters of the algorithm
@@ -78,7 +94,6 @@ public class SymmetryEstimator {
         this.panel = panel;
     }
     
-
     /**
      * 
      * @return Facet of the model on which symmetry is computed 
@@ -88,35 +103,258 @@ public class SymmetryEstimator {
     }
 
     /**
-     * Creates new class for computing symmetry
+     * If bounding box is not created yet, it creates new one. 
      * 
-     * @param f facet on which symmetry will be computed 
-     * @param config configuration of optional parameters of the algorithm
+     * @return Represent min-max box of the boundries of the model. 
      */
-    public SymmetryEstimator(MeshFacet f, Config config) {
-        this.facet = f;
-        this.config = config;
+    public BoundingBox getBoundingBox() {
+        if (boundingBox == null) {
+            boundingBox = facet.getBoundingBox();
+        }
+        return boundingBox; 
+    }
+    
+    /**
+     * Computes the approximate plane of symmetry.
+     * @return approximate plane of symmtetry
+     */
+    public Plane getApproxSymmetryPlane() {
         
-        this.triangles = f.asTriangles();
+        UIManager.put("ProgressMonitor.progressText", "Counting symmetry...");
+ 
+        ArrayList<AproxSymmetryPlane> planes = new ArrayList<>();
+        //List<Vector3d> normals = calculateNormals();
+        if (!facet.hasVertexNormals()) {
+            facet.calculateVertexNormals();
+        }
+        double[] curvatures = new double[facet.getNumberOfVertices()];
+        for (int i = 0; i < facet.getNumberOfVertices(); i++) {
+            if (facet.getNumberOfVertices() == 2500) {
+                curvatures[i] = this.getMaxCurvature(i);
+            } else {
+                curvatures[i] = this.getGaussianCurvature(i);
+            }
+            if (Double.isNaN(curvatures[i])){
+                curvatures[i] = Double.MIN_VALUE;
+            }
+        }
+        ArrayList<Double> sortedCurvatures = new ArrayList<>();
+        for (int i = 0; i < curvatures.length; i++) {
+            sortedCurvatures.add(curvatures[i]);
+        }
+        Collections.sort(sortedCurvatures);
+           
+        if(config.getSignificantPointCount() > facet.getNumberOfVertices()) {
+            config.setSignificantPointCount((facet.getNumberOfVertices()) - 1);
+        }
+        double bottomCurvature = sortedCurvatures.get(sortedCurvatures.size() - 1 - config.getSignificantPointCount());   
         
-        this.areas = new TriangleVertexAreas[triangles.size()];
-        for (int i = 0; i < areas.length; i++) {
-            areas[i] = computeTriangleVertexAreas(triangles.get(i));
+        ArrayList<Integer> significantPoints = new ArrayList<>();
+        ArrayList<Double> significantCurvatures = new ArrayList<>();
+        
+        for (int i = 0; i < facet.getNumberOfVertices(); i++) {
+            if (curvatures[i] >= bottomCurvature) {
+                significantCurvatures.add(curvatures[i]);
+                significantPoints.add(i);
+            }
+        }
+        
+        Plane plane = new Plane(0, 0, 0, 0);
+        int lastVotes = 0;
+        
+        ProgressMonitor progressMonitor;
+        progressMonitor = new ProgressMonitor(panel, "Cunting...",
+                "Steps", 0, significantPoints.size());
+        
+        double onePercent = significantCurvatures.size() / 100.0;
+        double percentsPerStep = 1 / onePercent;
+        for (int i = 0; i < significantPoints.size(); i++) {
+            for (int j = 0; j < significantPoints.size(); j++) {
+                if (i != j) {
+                    double minRatio = config.getMinCurvRatio();
+                    double maxRatio = 1.0 / minRatio;
+                    if (significantCurvatures.get(i) / significantCurvatures.get(j) >= minRatio && significantCurvatures.get(i) /
+                            significantCurvatures.get(j) <= maxRatio) {
+                        
+                        Vector3d p1 = new Vector3d(facet.getVertex(significantPoints.get(i)).getPosition());
+                        Vector3d p2 = new Vector3d(facet.getVertex(significantPoints.get(j)).getPosition());
+                        
+                        Vector3d avrg = new Vector3d(p1);
+                        avrg.add(p2);
+                        avrg.scale(0.5);
+                        
+                        Vector3d normal = new Vector3d(p1);
+                        normal.sub(p2);
+                        normal.normalize();
+                        
+                        double d = -(normal.x * avrg.x) - (normal.y * avrg.y) - (normal.z * avrg.z);
+                       
+                        Vector3d ni = new Vector3d(facet.getVertex(significantPoints.get(i)).getNormal());
+                        Vector3d nj = new Vector3d(facet.getVertex(significantPoints.get(j)).getNormal());
+                        ni.normalize();
+                        nj.normalize();
+
+                        Vector3d normVec = ni;
+                        normVec.sub(nj);
+                        normVec.normalize();
+                        double normCos = normVec.dot(normal);
+
+                        if (Math.abs(normCos) >= config.getMinNormAngleCos()) {
+                            Plane newPlane = new Plane(normal.x, normal.y, normal.z, d);
+                            int currentVotes = getVotes(newPlane, 
+                                significantCurvatures, 
+                                significantPoints, 
+                                config.getMinCurvRatio(), 
+                                config.getMinAngleCos(), 
+                                config.getMinNormAngleCos(), 
+                                boundingBox.getMaxDiag() * config.getMaxRelDistance());
+
+                            planes.add(new AproxSymmetryPlane(newPlane, currentVotes));
+                            
+                            if (currentVotes > lastVotes) {
+                                lastVotes = currentVotes;
+                                plane = newPlane;
+                            }
+                        }
+                        
+                    }
+                }
+            }
+            progressMonitor.setNote("Task step: " + (int) ((i + 1) * percentsPerStep));
+            progressMonitor.setProgress(i);
+        }
+        
+        Collections.sort(planes);
+        ArrayList<AproxSymmetryPlane> finalPlanes = new ArrayList<>();
+        for (int i = 0; i < planes.size(); i++) {
+            if (planes.get(i).votes == lastVotes){
+                finalPlanes.add(planes.get(i));
+            }
         }
+        Plane finalPlane = new Plane(0, 0, 0, 0);
+        Vector3d refDir = new Vector3d(finalPlanes.get(0).a, finalPlanes.get(0).b, finalPlanes.get(0).c);
+        for (int i = 0; i < finalPlanes.size(); i++) {
+            Vector3d normDir = new Vector3d(finalPlanes.get(i).a, finalPlanes.get(i).b, finalPlanes.get(i).c);
+            if (normDir.dot(refDir) < 0) {
+                finalPlane.a -= finalPlanes.get(i).a;
+                finalPlane.b -= finalPlanes.get(i).b;
+                finalPlane.c -= finalPlanes.get(i).c;
+                finalPlane.d -= finalPlanes.get(i).d;
+            } else {
+                finalPlane.a += finalPlanes.get(i).a;
+                finalPlane.b += finalPlanes.get(i).b;
+                finalPlane.c += finalPlanes.get(i).c;
+                finalPlane.d += finalPlanes.get(i).d;
+            }
+        }
+        finalPlane.normalize();
+        if (config.isAveraging()){
+            plane = finalPlane;
+        }
+        JOptionPane.showMessageDialog(panel, "Symmetry estimate done.", "Done", 0,
+                new ImageIcon(getClass().getResource("/cz/fidentis/analyst/gui/resources/exportedModel.png")));
 
-        boundingBox = facet.getBoundingBox();
+        progressMonitor.close();
+        return plane;
     }
     
     /**
-     * If bounding box is not created yet, it creates new one. 
      * 
-     * @return Represent min-max box of the boundries of the model. 
+     * @param plane Plane computed as symmetry plane
+     * @return mesh that represents facet with computed plane of approximate symmetry
      */
-    public BoundingBox getBoundingBox() {
-        if (boundingBox == null) {
-            boundingBox = facet.getBoundingBox();
+    public SymmetryEstimator mergeWithPlane(Plane plane) {
+        Vector3d normal = new Vector3d(plane.a, plane.b, plane.c);
+        Vector3d midPoint = boundingBox.getMidPoint().getPosition();
+
+        double alpha = -((plane.a * midPoint.x) + 
+                (plane.b * midPoint.y) + (plane.c * midPoint.z) +
+                plane.d) / (normal.dot(normal));
+        
+        Vector3d midPointOnPlane = new Vector3d(midPoint);
+        Vector3d nn = new Vector3d(normal);
+        nn.scale(alpha);
+        midPointOnPlane.add(nn);
+
+        double val = plane.a * midPointOnPlane.x + plane.b *
+                midPointOnPlane.y + plane.c *
+                midPointOnPlane.z + plane.d;
+
+        Vector3d a = new Vector3d();
+        if (Math.abs(normal.dot(new Vector3d(0.0, 1.0, 0.0))) > Math.abs(normal.dot(new Vector3d (1.0, 0.0, 0.0)))) {
+            a.cross(normal, new Vector3d(1.0, 0.0, 0.0));
+        } else {
+            a.cross(normal, new Vector3d(0.0, 1.0, 0.0));
         }
-        return boundingBox; 
+        a.normalize();
+
+        Vector3d b = new Vector3d();
+        b.cross(normal,a);
+        b.normalize();
+        
+        SymmetryEstimator planeMesh = new SymmetryEstimator(midPointOnPlane, a, b,
+                (boundingBox.getMaxPoint().subtractPosition(boundingBox.getMinPoint())).getPosition().x);
+       
+        return mergeMeshWith(planeMesh);
+    }
+    
+    /**
+     * 
+     * @param s mesh that will be merged
+     * @return mesh with merged vertices from both meshes 
+     */
+    public SymmetryEstimator mergeMeshWith(SymmetryEstimator s) {
+        CornerTableRow row1 = new CornerTableRow(facet.getNumberOfVertices(), -1);
+        CornerTableRow row2 = new CornerTableRow(facet.getNumberOfVertices() + 1, facet.getNumberOfVertices() + 3);
+        CornerTableRow row3 = new CornerTableRow(facet.getNumberOfVertices() + 2, -1);
+        CornerTableRow row4 = new CornerTableRow(facet.getNumberOfVertices() + 2, -1);
+        CornerTableRow row5 = new CornerTableRow(facet.getNumberOfVertices() + 3, facet.getNumberOfVertices() + 1);
+        CornerTableRow row6 = new CornerTableRow(facet.getNumberOfVertices(), -1);
+        
+        facet.getCornerTable().addRow(row1);
+        facet.getCornerTable().addRow(row2);
+        facet.getCornerTable().addRow(row3);
+        facet.getCornerTable().addRow(row4);
+        facet.getCornerTable().addRow(row5);
+        facet.getCornerTable().addRow(row6);
+
+        for(int n = 0; n < 4; n++) {
+            facet.addVertex(s.getFacet().getVertices().get(n));
+        }        
+        return this;
+    }
+
+    private static MeshFacet createMeshFacet(Vector3d centroid, Vector3d a, Vector3d b, double scale) {
+        Vector3d[] points = new Vector3d[4];
+        
+        Vector3d aScaled = new Vector3d(a);
+        Vector3d bScaled = new Vector3d(b);
+        aScaled.scale(scale);
+        bScaled.scale(scale);
+        
+        points[0] = new Vector3d(centroid);
+        points[0].sub(aScaled);
+        points[0].sub(bScaled);
+        
+        points[1] = new Vector3d(centroid);
+        points[1].sub(aScaled);
+        points[1].add(bScaled);
+        
+        points[2] = new Vector3d(centroid);
+        points[2].add(aScaled);
+        points[2].add(bScaled);
+        
+        points[3] = new Vector3d(centroid);
+        points[3].add(aScaled);
+        points[3].sub(bScaled);
+        
+        MeshFacet facet = new MeshFacetImpl();
+        for (Vector3d point : points) {
+            facet.addVertex(new MeshPointImpl(point, null, null));
+        }
+        facet.calculateVertexNormals();
+        
+        return facet;
     }
 
     /**
@@ -428,7 +666,6 @@ public class SymmetryEstimator {
             double minAngleCos,
             double minNormAngleCos,
             double maxDist) {
-        
         plane.normalize();
         
         Vector3d normal = new Vector3d(plane.a, plane.b, plane.c);
@@ -481,214 +718,4 @@ public class SymmetryEstimator {
         return votes;
     }
     
-    /**
-     * 
-     * 
-     * @return approximate plane of symmtetry
-     */
-    public Plane getAproxSymmetryPlane() {
-        
-        UIManager.put("ProgressMonitor.progressText", "Counting symmetry...");
- 
-        ArrayList<AproxSymmetryPlane> planes = new ArrayList<>();
-        //List<Vector3d> normals = calculateNormals();
-        if (!facet.hasVertexNormals()) {
-            facet.calculateVertexNormals();
-        }
-        double[] curvatures = new double[facet.getNumberOfVertices()];
-        for (int i = 0; i < facet.getNumberOfVertices(); i++) {
-            if (facet.getNumberOfVertices() == 2500) {
-                curvatures[i] = this.getMaxCurvature(i);
-            } else {
-                curvatures[i] = this.getGaussianCurvature(i);
-            }
-            if (Double.isNaN(curvatures[i])){
-                curvatures[i] = Double.MIN_VALUE;
-            }
-        }
-        ArrayList<Double> sortedCurvatures = new ArrayList<>();
-        for (int i = 0; i < curvatures.length; i++) {
-            sortedCurvatures.add(curvatures[i]);
-        }
-        Collections.sort(sortedCurvatures);
-           
-        if(config.getSignificantPointCount() > facet.getNumberOfVertices()) {
-            config.setSignificantPointCount((facet.getNumberOfVertices()) - 1);
-        }
-        double bottomCurvature = sortedCurvatures.get(sortedCurvatures.size() - 1 - config.getSignificantPointCount());   
-        
-        ArrayList<Integer> significantPoints = new ArrayList<>();
-        ArrayList<Double> significantCurvatures = new ArrayList<>();
-        
-        for (int i = 0; i < facet.getNumberOfVertices(); i++) {
-            if (curvatures[i] >= bottomCurvature) {
-                significantCurvatures.add(curvatures[i]);
-                significantPoints.add(i);
-            }
-        }
-        
-        Plane plane = new Plane(0, 0, 0, 0);
-        int lastVotes = 0;
-        
-        ProgressMonitor progressMonitor;
-        progressMonitor = new ProgressMonitor(panel, "Cunting...",
-                "Steps", 0, significantPoints.size());
-        
-        double onePercent = significantCurvatures.size() / 100.0;
-        double percentsPerStep = 1 / onePercent;
-        for (int i = 0; i < significantPoints.size(); i++) {
-            for (int j = 0; j < significantPoints.size(); j++) {
-                if (i != j) {
-                    double minRatio = config.getMinCurvRatio();
-                    double maxRatio = 1.0 / minRatio;
-                    if (significantCurvatures.get(i) / significantCurvatures.get(j) >= minRatio && significantCurvatures.get(i) /
-                            significantCurvatures.get(j) <= maxRatio) {
-                        
-                        Vector3d p1 = new Vector3d(facet.getVertex(significantPoints.get(i)).getPosition());
-                        Vector3d p2 = new Vector3d(facet.getVertex(significantPoints.get(j)).getPosition());
-                        
-                        Vector3d avrg = new Vector3d(p1);
-                        avrg.add(p2);
-                        avrg.scale(0.5);
-                        
-                        Vector3d normal = new Vector3d(p1);
-                        normal.sub(p2);
-                        normal.normalize();
-                        
-                        double d = -(normal.x * avrg.x) - (normal.y * avrg.y) - (normal.z * avrg.z);
-                       
-                        Vector3d ni = new Vector3d(facet.getVertex(significantPoints.get(i)).getNormal());
-                        Vector3d nj = new Vector3d(facet.getVertex(significantPoints.get(j)).getNormal());
-                        ni.normalize();
-                        nj.normalize();
-
-                        Vector3d normVec = ni;
-                        normVec.sub(nj);
-                        normVec.normalize();
-                        double normCos = normVec.dot(normal);
-
-                        if (Math.abs(normCos) >= config.getMinNormAngleCos()) {
-                            Plane newPlane = new Plane(normal.x, normal.y, normal.z, d);
-                            int currentVotes = getVotes(newPlane, 
-                                significantCurvatures, 
-                                significantPoints, 
-                                config.getMinCurvRatio(), 
-                                config.getMinAngleCos(), 
-                                config.getMinNormAngleCos(), 
-                                boundingBox.getMaxDiag() * config.getMaxRelDistance());
-
-                            planes.add(new AproxSymmetryPlane(newPlane, currentVotes));
-                            
-                            if (currentVotes > lastVotes) {
-                                lastVotes = currentVotes;
-                                plane = newPlane;
-                            }
-                        }
-                        
-                    }
-                }
-            }
-            progressMonitor.setNote("Task step: " + (int) ((i + 1) * percentsPerStep));
-            progressMonitor.setProgress(i);
-        }
-        
-        Collections.sort(planes);
-        ArrayList<AproxSymmetryPlane> finalPlanes = new ArrayList<>();
-        for (int i = 0; i < planes.size(); i++) {
-            if (planes.get(i).votes == lastVotes){
-                finalPlanes.add(planes.get(i));
-            }
-        }
-        Plane finalPlane = new Plane(0, 0, 0, 0);
-        Vector3d refDir = new Vector3d(finalPlanes.get(0).a, finalPlanes.get(0).b, finalPlanes.get(0).c);
-        for (int i = 0; i < finalPlanes.size(); i++) {
-            Vector3d normDir = new Vector3d(finalPlanes.get(i).a, finalPlanes.get(i).b, finalPlanes.get(i).c);
-            if (normDir.dot(refDir) < 0) {
-                finalPlane.a -= finalPlanes.get(i).a;
-                finalPlane.b -= finalPlanes.get(i).b;
-                finalPlane.c -= finalPlanes.get(i).c;
-                finalPlane.d -= finalPlanes.get(i).d;
-            } else {
-                finalPlane.a += finalPlanes.get(i).a;
-                finalPlane.b += finalPlanes.get(i).b;
-                finalPlane.c += finalPlanes.get(i).c;
-                finalPlane.d += finalPlanes.get(i).d;
-            }
-        }
-        finalPlane.normalize();
-        if (config.isAveraging()){
-            plane = finalPlane;
-        }
-        JOptionPane.showMessageDialog(panel, "Symmetry estimate done.", "Done", 0,
-                new ImageIcon(getClass().getResource("/cz/fidentis/analyst/gui/resources/exportedModel.png")));
-
-        progressMonitor.close();
-        return plane;
-    }
-    
-    /**
-     * 
-     * @param plane Plane computed as symmetry plane
-     * @return mesh that represents facet with computed plane of approximate symmetry
-     */
-    public SymmetryEstimator mergeWithPlane(Plane plane) {
-        Vector3d normal = new Vector3d(plane.a, plane.b, plane.c);
-        Vector3d midPoint = boundingBox.getMidPoint().getPosition();
-
-        double alpha = -((plane.a * midPoint.x) + 
-                (plane.b * midPoint.y) + (plane.c * midPoint.z) +
-                plane.d) / (normal.dot(normal));
-        
-        Vector3d midPointOnPlane = new Vector3d(midPoint);
-        Vector3d nn = new Vector3d(normal);
-        nn.scale(alpha);
-        midPointOnPlane.add(nn);
-
-        double val = plane.a * midPointOnPlane.x + plane.b *
-                midPointOnPlane.y + plane.c *
-                midPointOnPlane.z + plane.d;
-
-        Vector3d a = new Vector3d();
-        if (Math.abs(normal.dot(new Vector3d(0.0, 1.0, 0.0))) > Math.abs(normal.dot(new Vector3d (1.0, 0.0, 0.0)))) {
-            a.cross(normal, new Vector3d(1.0, 0.0, 0.0));
-        } else {
-            a.cross(normal, new Vector3d(0.0, 1.0, 0.0));
-        }
-        a.normalize();
-
-        Vector3d b = new Vector3d();
-        b.cross(normal,a);
-        b.normalize();
-       
-        SymmetryEstimator planeMesh = Plane.createPlaneMesh(midPointOnPlane, a, b,
-                (boundingBox.getMaxPoint().subtractPosition(boundingBox.getMinPoint())).getPosition().x);
-
-        return mergeMeshWith(planeMesh);
-    }
-    
-    /**
-     * 
-     * @param s mesh that will be merged
-     * @return mesh with merged vertices from both meshes 
-     */
-    public SymmetryEstimator mergeMeshWith(SymmetryEstimator s) {
-        CornerTableRow row1 = new CornerTableRow(facet.getNumberOfVertices(), -1);
-        CornerTableRow row2 = new CornerTableRow(facet.getNumberOfVertices() + 1, facet.getNumberOfVertices() + 3);
-        CornerTableRow row3 = new CornerTableRow(facet.getNumberOfVertices() + 2, -1);
-        CornerTableRow row4 = new CornerTableRow(facet.getNumberOfVertices() + 2, -1);
-        CornerTableRow row5 = new CornerTableRow(facet.getNumberOfVertices() + 3, facet.getNumberOfVertices() + 1);
-        CornerTableRow row6 = new CornerTableRow(facet.getNumberOfVertices(), -1);
-        
-        facet.getCornerTable().addRow(row1);
-        facet.getCornerTable().addRow(row2);
-        facet.getCornerTable().addRow(row3);
-        facet.getCornerTable().addRow(row4);
-        facet.getCornerTable().addRow(row5);
-        facet.getCornerTable().addRow(row6);
-
-        for(int n = 0; n < 4; n++) {
-            facet.addVertex(s.getFacet().getVertices().get(n));
-        }        
-        return this;
-    }
 }
diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/SymmetryPanel.java b/GUI/src/main/java/cz/fidentis/analyst/gui/SymmetryPanel.java
index 2a9889fe..5335736e 100644
--- a/GUI/src/main/java/cz/fidentis/analyst/gui/SymmetryPanel.java
+++ b/GUI/src/main/java/cz/fidentis/analyst/gui/SymmetryPanel.java
@@ -156,7 +156,7 @@ public final class SymmetryPanel extends javax.swing.JPanel {
         canvas.changeModel(canvas.getLoadedModel());
         symCounter = new SymmetryEstimator(canvas.getModel().getFacets().get(0), config);
         symCounter.setPanel(this);
-        finalPlane = symCounter.getAproxSymmetryPlane();
+        finalPlane = symCounter.getApproxSymmetryPlane();
         SymmetryEstimator counted = symCounter.mergeWithPlane(finalPlane);
         model.addFacet(counted.getFacet());
         
-- 
GitLab